python-lightify icon indicating copy to clipboard operation
python-lightify copied to clipboard

Missing support for motion and contact sensors

Open OleksandrBerchenko opened this issue 6 years ago • 4 comments

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.

OleksandrBerchenko avatar Jan 10 '19 16:01 OleksandrBerchenko

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.

tfriedel avatar Jan 30 '19 19:01 tfriedel

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.

OleksandrBerchenko avatar Jan 30 '19 21:01 OleksandrBerchenko

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.

OleksandrBerchenko avatar Feb 02 '19 17:02 OleksandrBerchenko

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.

OleksandrBerchenko avatar Feb 02 '19 17:02 OleksandrBerchenko