Skip to content

Instantly share code, notes, and snippets.

@curtis86
Created January 6, 2020 07:10
Show Gist options
  • Select an option

  • Save curtis86/cc1c1d5c79367fac1757f2e720bae221 to your computer and use it in GitHub Desktop.

Select an option

Save curtis86/cc1c1d5c79367fac1757f2e720bae221 to your computer and use it in GitHub Desktop.
Xiaomi lywsd02 python
# 1. Get MAC address - 'lescan' is persistent, look out for 'LYWSD02' and then CTRL+C and note MAC address:
hcitool lescan
# 2. Install python3 package:
pip3 install lywsd02
# 3. Python3 script:
#!/usr/bin/env python3
from lywsd02 import Lywsd02Client
mac = 'YO:UR:MA:CA:DD:RE:SS'
client = Lywsd02Client(mac)
temperature = client.temperature
humidity = client.humidity
battery = client.battery
print(temperature,humidity,battery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment