NRCHKB / node-red-contrib-homekit-bridged

Node-RED Contribution - HomeKit Bridged : Node-RED nodes to simulate Apple HomeKit devices.
https://nrchkb.github.io
MIT License
420 stars 52 forks source link

[Setup Help]: Updating icon status without triggering output action #338

Closed michaltaberski closed 3 years ago

michaltaberski commented 3 years ago

Setup Help I am controlling Shelly1 device using MQTT. I created a virtual light bulb using homekit in NodeRed. It works. I can turn on and off the light - that's fine. The issue I dealing with is to keep the right icon status always in the iPhone home app. The problem happens when I switch off / on the light manually via the wall switch or another source. Then the icon in the home app gets unsynced. So my question is: Can I programmatically toggle the icon status without actually making the homekit throwing an output?

caitken-com commented 3 years ago

Can you post your flow or screenshot of your flow?

Shaquu commented 3 years ago

@michaltaberski like mentioned by @caitken-com best option would be if you share your Node-RED flow with us then we would see directly what is your issue and need. You can do that in Node-RED by going to top right menu and clicking export (and following on screen form). Zrzut ekranu 2020-11-13 o 23 54 10

Regarding changing status of icon in Home.app you have to listen for status change of real device in Node-RED and connect it with your HomeKit node in Node-RED. To change status itself you have to send specific input to our node.

If you are new to Node-RED or our node I would suggest to follow our Wiki DEMO SETUP page which contains great examples.

Also consider joining our Discord for live help:

NRCHKB Discord

michaltaberski commented 3 years ago

The flow as simple as that:

Screenshot 2020-11-14 at 00 00 18
[{"id":"70ce60e8.c3abb","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"50cc1112.ff5f5","type":"homekit-service","z":"70ce60e8.c3abb","isParent":true,"bridge":"5c4f27d3.a4add8","parentService":"","name":"Playroom light","serviceName":"Lightbulb","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","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":640,"y":280,"wires":[[],["92047f6a.6116e"]]},{"id":"7631f0ac.f0f09","type":"mqtt out","z":"70ce60e8.c3abb","name":"MQTT to turn ON/OFF Shelly1","topic":"","qos":"","retain":"","broker":"bf5096c4.38e288","x":970,"y":280,"wires":[]},{"id":"92047f6a.6116e","type":"function","z":"70ce60e8.c3abb","name":"","func":"const { On } = msg.payload;\n\nreturn {\n    topic: \"shellies/shelly1-.../relay/0/command\",\n    payload: On === true ? \"on\" : \"off\",\n};","outputs":1,"noerr":0,"x":775,"y":280,"wires":[["7631f0ac.f0f09"]],"l":false},{"id":"e9fc901b.a8df3","type":"mqtt in","z":"70ce60e8.c3abb","name":"MQTT from Shelly1 with status update","topic":"shellies/shelly1-.../relay/0","qos":"2","datatype":"auto","broker":"bf5096c4.38e288","x":290,"y":280,"wires":[["84e9cdfe.9d54c"]]},{"id":"84e9cdfe.9d54c","type":"function","z":"70ce60e8.c3abb","name":"","func":"return {\n    payload: {\n        On: msg.payload === \"on\"\n    },\n};","outputs":1,"noerr":0,"x":495,"y":280,"wires":[["50cc1112.ff5f5"]],"l":false},{"id":"5c4f27d3.a4add8","type":"homekit-bridge","z":"","bridgeName":"NodeRed bridge","pinCode":"123-45-678","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":true},{"id":"bf5096c4.38e288","type":"mqtt-broker","z":"","name":"home-pi (mosquitto)","broker":"192.168.1.10","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

And the thing is that the input MQTT might come from another source than the homekit.

Shaquu commented 3 years ago

@michaltaberski great. What is your payload (message) from MQTT? Zrzut ekranu 2020-11-14 o 00 18 07 You can add debug nodes like that to find out. Message will appear in sidebar in Node-RED. Zrzut ekranu 2020-11-14 o 00 18 47

michaltaberski commented 3 years ago

Thanks @Shaquu for the effort! I have solved the problem myself in the end. The issue was in the end that the homekit device status doesn't update on my iPhone for 10s after the deployment. Later it seems to be all fine.

caitken-com commented 3 years ago

You're also using the wrong wire output on your accessories. The top output is what you want to prevent ongoing/pass through messages. I had a feeling this was the case, so I asked for your flow to confirm:

https://github.com/NRCHKB/output-messages