Giter Site home page Giter Site logo

lywsd02's Introduction

Lywsd02 – Python library to work with Xiaomi Temperature and Humidifier sensor

PyPI version

WORK IN PROGRESS

Install

  1. Install it via PyPI:

    pip install lywsd02
    

    Note: use pip3 instead of pip on Raspbian and other systems that default to Python 2.

  2. Or directly from the source code:

    git clone https://github.com/h4/lywsd02.git
    python lywsd02/setup.py install
    

    Note: use python3 if your system defaults to Python 2.

Usage

Instantiate client with Lywsd02 mac address

from lywsd02 import Lywsd02Client

mac = '3F:59:C8:80:70:BE'
client = Lywsd02Client(mac)

Read data

print(client.temperature)
print(client.humidity)

Available properties

  • client.temperature – Sensor's temperature data in Celsius degrees. Updates with timeout (See below)
  • client.humidity – Sensor's humidity data in percent. Updates with timeout
  • client.units – Current temperature units displayed on screen. Returns 'C' for Celsius and 'F' for Fahrenheit
  • client.time – Current time and timezone offset. Returns as tuple of datetime.datetime and int
  • client.battery – Sensor's battery level in percent (0 to 100).

Available setters

  • client.units = 'C' – Changes temperature units displayed on screen
  • client.time = datetime.datetime.now() - Changes time. Changing timezone offset is not possible

Configuration

Client may be initialized with additional kwargs.

  • notification_timeout – timeout to wait for temperature and humidity requests. If sensor responds slower then timeout data would not updated. Default value is 5 second.
  • data_request_timeouttemperature and humidity are cached for this period. Default value is 15 second.
from lywsd02 import Lywsd02Client

mac = '3F:59:C8:80:70:BE'
client = Lywsd02Client(mac, notification_timeout=1.0, data_request_timeout=30.0)

lywsd02's People

Contributors

h4 avatar kasparsd avatar seeschloss avatar anekos avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.