benzman81 / homebridge-http-webhooks

A http plugin with support of webhooks for Homebridge: https://github.com/nfarina/homebridge
GNU General Public License v3.0
180 stars 57 forks source link

Question: How to set state in Homekit for a switch #190

Open ringostarlet opened 8 months ago

ringostarlet commented 8 months ago

Hi,

I am using a switch to turn the nightmode of my Sonos system on and off using the sonos http api webhooks. Now when I change the nightmode outside of homekit it is not reflected on homekit. How can I achieve to have hmekit query the state with a webhook so it s "in sync" with what set in my Sonos device?

jsiegenthaler commented 8 months ago

You would have to actively poll the state of night mode at regular intervals

ringostarlet commented 8 months ago

Yes, but my question is if the web hook plugin has a functionality that can update the switch state...I can poll the state using the Sonos http api, it returns a json string.

benzman81 commented 8 months ago

Hi, polling of states is not and will not be implemented by this pluin for now as this is a bad pattern. If Sonos can call api on changes, then you can call the api of this plugin to switch the state.

ACWAKKERMANS commented 5 months ago

A work around I use on my Shellys is to create a motion sensor using this plugin.

I have a virtual switch on HomeKit which, through a native automation, uses HTTP to switch a Shelly Switch On/Off. Obviously, the Shelly does not report back, and so if I switch the Shelly on/off outside HomeKit, the true state is no longer reflected in HomeKit... Same problem you have.

The workaround: Create a motion sensor (or other device, Motion Sensor is unobtrusive in my scenario) within HomeKit using this plug-in. The Shelly is set up to report "motion detected" when the Shelly switch is turned on and reports "motion not detected" when the switch is turned off. I now have the state of the Shelly switch reflected in HomeKit. On HomeKit, I have two automations: Turn switch state off when motion not detected, Turn switch state on when motion is detected.

I now, sadly, have 4 automations, however, my Homekit switch is controlling a non-native Shelly and the Shelly state is reflecting accurately back in HomeKit.