Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding illumination sensor support #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion components/sensor/xiaomi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if device['model'] == 'sensor_ht':
devices.append(XiaomiSensor(device, 'Temperature', 'temperature', gateway))
devices.append(XiaomiSensor(device, 'Humidity', 'humidity', gateway))
elif device['model'] == 'gateway':
devices.append(XiaomiSensor(device, 'Illumination', 'illumination', gateway))
add_devices(devices)


Expand Down Expand Up @@ -65,11 +67,16 @@ def unit_of_measurement(self):
return TEMP_CELSIUS
elif self._data_key == 'humidity':
return '%'
elif self._data_key == 'illumination':
return 'lm'

def parse_data(self, data):
"""Parse data sent by gateway"""
value = data.get(self._data_key)
if value is None:
return False
self.current_value = int(value) / 100
if self._data_key == 'illumination':
self.current_value = int(value)
else:
self.current_value = int(value) / 100
return True