python-lightify
python-lightify copied to clipboard
Missing support for motion and contact sensors
According to https://github.com/noctarius/lightify-binary-protocol, it may be possible to read "Battery value", "Enabled value" and "Triggered value" for motion sensors.
Unfortunately, I don't have one and can't help here.
I have one. If I remember correctly the green value will be 1 (or some other value except 0) for some time when it's triggered. you would have to poll it every one or two second to make use of it.
Well, in theory looks simple :) But I need a real one to make an accurate fix. Also noctarius documentation mentions:
Luminance value / Battery value (Motion Detector)
Red value / Enabled value (Motion Detector)
P.S. Almost finished a HA integration, I will let you know soon.
In theory, support for the sensors in the library itself should be trivial (it just needs to be accurately tested with real devices). It may look something like:
def sensor_values(self):
"""
:return: dict containing parsed sensor values
"""
if self.__devicesubtype == DeviceSubType.MOTION_SENSOR:
return {'battery_level': self.__raw_values[1],
'enabled': bool(self.__raw_values[3]),
'motion_detected': bool(self.__raw_values[4])}
elif self.__devicesubtype == DeviceSubType.CONTACT_SENSOR:
return # boolean state + temperature?
return None
Support on HA side would be more complicated. Currently osramlightify
is only a light module and it can't expose sensors or binary sensors. It should be transformed into a more general module like hue
or xiaomi
that can expose entities of any types.
I'm wondering whether luminance
really means battery level for a motion sensor. I hoped it may work for switches, but it doesn't (at least for my 4-button switches). Currently all my switches display "very good" in the Lightify app, but when I put a battery into a freezer for 15 minutes and when insert it back into the switch, the app starts thinking it's just "good". Despite that luminance
value was always 100.