0x5e / homebridge-tuya-platform

Make homebridge-tuya-platform great again.
MIT License
207 stars 58 forks source link

Presence sensor doesn't expose light sensor to homekit #343

Open sloukita opened 1 year ago

sloukita commented 1 year ago

Device Infomation JSON File

"category": "hps",
    "product_id": "ztc6ggyl",
    "product_id": "sxm7l9xa",

Detail Informations

Some presence sensors also have light sensor that measure illuminance_value however, in homekit, only the presence_state is exposed and not the lux value.

sloukita commented 1 year ago

Note if I override the category to luminance sensor (ldcg), then the sensor works perfectly as a luminance sensor, but stops working as a presence sensor.

Is there a way to have both presence detection and luminance detection?

            "category": "ldcg",
            "schema": [
                {
                    "code": "illuminance_value",
                    "newCode": "bright_value"
                }
            ]
sloukita commented 1 year ago

My current hacky workaround, override presence sensor as switch, set switch_1 as the presence detections, set switch_2 to true when luminance falls below 100lux

            "category": "kg",
            "schema": [
                {
                    "code": "presence_state",
                    "newCode": "switch_1",
                    "type": "Boolean",
                    "onGet": "(value === 'presence') ? true : false;",
                    "onSet": "(value === true) ? 'presence' : 'none';"
                },
                {
                    "code": "illuminance_value",
                    "newCode": "switch_2",
                    "type": "Boolean",
                    "onGet": "(value < 100) ? true : false;"
                }
            ]