deconz-community / node-red-contrib-deconz

Node-Red Nodes for deCONZ connectivity.
GNU General Public License v3.0
81 stars 16 forks source link

Smart Lock does not work with homekit node #213

Closed Nazarbayevv closed 1 year ago

Nazarbayevv commented 1 year ago

Current Behavior

Deconz outpoot node doesn't respond to homekit's node requests, when I use Homekit type of commands: image image

Expected Behavior

I think, simmilar situation was with Window Covering from Issue#196 https://github.com/deconz-community/node-red-contrib-deconz/issues/196

Steps To Reproduce

When close lock from homekit, I can see log, but it's empty in deconz out

image

Example flow

[{"id":"ab582bdc079357b5","type":"deconz-input","z":"f7380f55.3bcd1","name":"","topic":"","config_version":2,"server":"da76db0b.163948","statustext":"","statustext_type":"auto","search_type":"device","device_list":["lights/uniqueid/58:8e:81:ff:fe:43:d8:24-01"],"device_name":"","query":"{}","outputs":1,"output_rules":[{"type":"homekit","format":"single","onstart":true,"onerror":true,"payload":["__auto__"]}],"x":180,"y":4280,"wires":[["e3ec1d0789b467fb"]]},{"id":"e3ec1d0789b467fb","type":"homekit-service","z":"f7380f55.3bcd1","isParent":true,"hostType":"0","bridge":"c887541e.9bc998","accessoryId":"","parentService":"","name":"Замок","serviceName":"LockMechanism","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.4.3","serialNo":"Default Serial Number","firmwareRev":"1.4.3","hardwareRev":"1.4.3","softwareRev":"1.4.3","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"x":350,"y":4280,"wires":[["960567e2e3f935db","48a59e531d240bcf"],[]]},{"id":"960567e2e3f935db","type":"debug","z":"f7380f55.3bcd1","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":4320,"wires":[]},{"id":"48a59e531d240bcf","type":"deconz-output","z":"f7380f55.3bcd1","name":"Замок","config_version":2,"server":"da76db0b.163948","statustext":"","statustext_type":"default","search_type":"device","device_list":["lights/uniqueid/58:8e:81:ff:fe:43:d8:24-01"],"device_name":"","query":"{}","commands":[{"arg":{"payload":{"type":"msg","value":"payload"},"transitiontime":{"type":"num","value":""},"retryonerror":{"type":"num","value":"0"},"aftererror":{"type":"continue","value":""}},"type":"homekit","domain":"","uniqueId":"ui-id-29"}],"specific":{"delay":{"type":"num","value":"50"},"result":{"type":"at_end","value":""}},"x":530,"y":4260,"wires":[["083f42c3e337807c"]]},{"id":"083f42c3e337807c","type":"debug","z":"f7380f55.3bcd1","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":4320,"wires":[]},{"id":"da76db0b.163948","type":"deconz-server","name":"Deconz","config_version":1,"ip":"192.168.88.9","port":"80","ws_port":"443","secure":false,"polling":"15"},{"id":"c887541e.9bc998","type":"homekit-bridge","bridgeName":"Node-RED_Access","pinCode":"400-44-000","port":"","allowInsecureRequest":false,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":false}]

Environment

Zehir commented 1 year ago

LockMechanism is not a thing currently supported, could you send the device data from Deconz to see what it's look like to know what I should map LockTargetState to ?

Zehir commented 1 year ago

Does he have a config.lock value ?

Zehir commented 1 year ago

Could you try with the 2.3.4 version @Nazarbayevv ?

Nazarbayevv commented 1 year ago

Hello,

I will try after backup. Give me, please, 1 day.

Nazarbayevv commented 1 year ago

Hello, sorry for my so long feedback.

I updated and tested lock: 1-st deconz input node with homekit outputs works incorrect. It needs "LockTargetState" and "LockCurrentState" messeges for homekit node, but lock send "On" messege like lamp. Deconz identified lock as light. image

2-nd for deconz output something wrong: image debug after deconz output is empty: image

I can share my working example via state output. I hope it will explane you how it works: image [{"id":"110ba9cdae27650a","type":"deconz-output","z":"f7380f55.3bcd1","name":"Замок on","config_version":2,"server":"da76db0b.163948","statustext":"","statustext_type":"default","search_type":"device","device_list":["lights/uniqueid/58:8e:81:ff:fe:43:d8:24-01"],"device_name":"","query":"{}","commands":[{"arg":{"on":{"type":"set","value":"true"},"alert":{"type":"str","value":""},"effect":{"type":"str","value":""},"colorloopspeed":{"type":"num","value":""},"transitiontime":{"type":"num","value":""},"retryonerror":{"type":"num","value":"0"},"aftererror":{"type":"continue","value":""},"bri":{"direction":"set","type":"num","value":""},"sat":{"direction":"set","type":"num","value":""},"hue":{"direction":"set","type":"num","value":""},"ct":{"direction":"set","type":"num","value":""},"xy":{"direction":"set","type":"json","value":"[]"}},"type":"deconz_state","domain":"lights"}],"specific":{"delay":{"type":"num","value":"50"},"result":{"type":"at_end","value":""}},"x":1100,"y":4400,"wires":[[]]},{"id":"f4915c5b4fd683af","type":"inject","z":"f7380f55.3bcd1","name":"on","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":950,"y":4400,"wires":[["110ba9cdae27650a"]]},{"id":"6e93eb03b7d6deae","type":"deconz-output","z":"f7380f55.3bcd1","name":"Замок off","config_version":2,"server":"da76db0b.163948","statustext":"","statustext_type":"default","search_type":"device","device_list":["lights/uniqueid/58:8e:81:ff:fe:43:d8:24-01"],"device_name":"","query":"{}","commands":[{"arg":{"on":{"type":"set","value":"false"},"alert":{"type":"str","value":""},"effect":{"type":"str","value":""},"colorloopspeed":{"type":"num","value":""},"transitiontime":{"type":"num","value":""},"retryonerror":{"type":"num","value":"0"},"aftererror":{"type":"continue","value":""},"bri":{"direction":"set","type":"num","value":""},"sat":{"direction":"set","type":"num","value":""},"hue":{"direction":"set","type":"num","value":""},"ct":{"direction":"set","type":"num","value":""},"xy":{"direction":"set","type":"json","value":"[]"}},"type":"deconz_state","domain":"lights"}],"specific":{"delay":{"type":"num","value":"50"},"result":{"type":"at_end","value":""}},"x":1100,"y":4340,"wires":[[]]},{"id":"ec4ea8cb505f2bc4","type":"inject","z":"f7380f55.3bcd1","name":"off","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":950,"y":4320,"wires":[["6e93eb03b7d6deae"]]},{"id":"ab582bdc079357b5","type":"deconz-input","z":"f7380f55.3bcd1","name":"","topic":"","config_version":2,"server":"da76db0b.163948","statustext":"","statustext_type":"auto","search_type":"device","device_list":["lights/uniqueid/58:8e:81:ff:fe:43:d8:24-01"],"device_name":"","query":"{}","outputs":2,"output_rules":[{"type":"homekit","format":"single","onstart":true,"onerror":true,"payload":["auto"],"uniqueId":"ui-id-15"},{"type":"state","format":"single","output":"always","onstart":true,"payload":["complete"],"uniqueId":"ui-id-16"}],"x":170,"y":4320,"wires":[[],["7042b87e20273577","18382ccc937250d8","9f087948122d7f12"]]},{"id":"e3ec1d0789b467fb","type":"homekit-service","z":"f7380f55.3bcd1","isParent":true,"hostType":"0","bridge":"c887541e.9bc998","accessoryId":"","parentService":"","name":"Замок","serviceName":"LockMechanism","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.4.3","serialNo":"Default Serial Number","firmwareRev":"1.4.3","hardwareRev":"1.4.3","softwareRev":"1.4.3","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"x":790,"y":4340,"wires":[["cef78d621d76a75a"],[]]},{"id":"cef78d621d76a75a","type":"switch","z":"f7380f55.3bcd1","name":"","property":"payload.LockTargetState","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":940,"y":4360,"wires":[["6e93eb03b7d6deae"],["110ba9cdae27650a"]]},{"id":"7042b87e20273577","type":"debug","z":"f7380f55.3bcd1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":190,"y":4380,"wires":[]},{"id":"18382ccc937250d8","type":"switch","z":"f7380f55.3bcd1","name":"","property":"payload.on","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":410,"y":4340,"wires":[["c2979f7762d6c180"],["775ee7ac43460d57"]]},{"id":"463da68b2ce4f687","type":"change","z":"f7380f55.3bcd1","name":"Замкнено","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"LockCurrentState\": 1}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":4280,"wires":[["e3ec1d0789b467fb"]]},{"id":"eff13cef69783981","type":"change","z":"f7380f55.3bcd1","name":"Відімкнено","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"LockCurrentState\": 0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":4400,"wires":[["e3ec1d0789b467fb"]]},{"id":"c2979f7762d6c180","type":"change","z":"f7380f55.3bcd1","name":"Замикаю","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"LockTargetState\": 1}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":4320,"wires":[["e3ec1d0789b467fb","51060ecac2273e5f"]]},{"id":"775ee7ac43460d57","type":"change","z":"f7380f55.3bcd1","name":"Відмикаю","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"LockTargetState\": 0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":4360,"wires":[["e3ec1d0789b467fb","c53c856c8ca528c4"]]},{"id":"51060ecac2273e5f","type":"delay","z":"f7380f55.3bcd1","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":560,"y":4280,"wires":[["463da68b2ce4f687"]]},{"id":"c53c856c8ca528c4","type":"delay","z":"f7380f55.3bcd1","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":540,"y":4400,"wires":[["eff13cef69783981"]]},{"id":"d35548bd61a56198","type":"inject","z":"f7380f55.3bcd1","name":"Замкнути","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":380,"y":4380,"wires":[["c2979f7762d6c180"]]},{"id":"a216f7761ba89c9e","type":"inject","z":"f7380f55.3bcd1","name":"Відімкнути","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":380,"y":4420,"wires":[["775ee7ac43460d57"]]},{"id":"da76db0b.163948","type":"deconz-server","name":"Deconz","config_version":1,"ip":"192.168.88.9","port":"80","ws_port":"443","secure":false,"polling":"15"},{"id":"c887541e.9bc998","type":"homekit-bridge","bridgeName":"Node-RED_Access","pinCode":"400-44-000","port":"","allowInsecureRequest":false,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":false}]

Zehir commented 1 year ago

It's confuse me, it's look like it's using the on state instead of the config.lock value.

Could you send me the response of theses requests in multiple case, when the lock is locked, when the lock is unlocked ?

http://{HOST:PORT}/api/{API KEY}/devices/58:8e:81:ff:fe:43:d8:24-01
http://{HOST:PORT}/api/{API KEY}/devices/58:8e:81:ff:fe:43:d8:24-01/ddffull
Nazarbayevv commented 1 year ago

In unlocked state:

{
    "lastannounced":"2022-09-10T13:51:40Z",
    "lastseen":"2022-09-12T08:54Z",
    "manufacturername":"Danalock",
    "modelid":"V3-BTZBE",
    "name":"Замок",
    "productid":"Danalock V3",
    "subdevices":[
        {
            "state":{
                "alert":{
                    "lastupdated":"2022-08-15T18:25:14Z",
                    "value":"none"
                },
                "on":{
                    "lastupdated":"2022-09-12T09:59:17Z",
                    "value":false
                },
                "reachable":{
                    "lastupdated":"2022-09-10T09:42:08Z",
                    "value":true
                }
            },
            "type":"Door Lock",
            "uniqueid":"58:8e:81:ff:fe:43:d8:24-01"
        }
    ],
    "swversion":"20210512",
    "uniqueid":"58:8e:81:ff:fe:43:d8:24"
}

In locked state:

{
    "lastannounced":"2022-09-12T09:05:26Z",
    "lastseen":"2022-09-12T09:05Z",
    "manufacturername":"Danalock",
    "modelid":"V3-BTZBE",
    "name":"Замок",
    "productid":"Danalock V3",
    "subdevices":[
        {
            "state":{
                "alert":{
                    "lastupdated":"2022-08-15T18:25:14Z",
                    "value":"none"
                },
                "on":{
                    "lastupdated":"2022-09-12T12:06:12Z",
                    "value":true
                },
                "reachable":{
                    "lastupdated":"2022-09-10T09:42:08Z",
                    "value":true
                }
            },
            "type":"Door Lock",
            "uniqueid":"58:8e:81:ff:fe:43:d8:24-01"
        }
    ],
    "swversion":"20210512",
    "uniqueid":"58:8e:81:ff:fe:43:d8:24"
}
Zehir commented 1 year ago

Could you try with version 2.3.5 ?

Nazarbayevv commented 1 year ago

It worts correctly vs 2.3.5. Thank you.