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

Pushbutton returns success=true but Homekit button state does not change #99

Closed jsiegenthaler closed 4 years ago

jsiegenthaler commented 4 years ago

I've just implemented httpwebhooks, and it is great

But it is unreliable

After a while Homekit stops responding, even though webhooks returns {"success":true} I can reproduce it in my browser:

  1. Go to the URl http://192.168.0.171:51828/?accessoryId=doorbellbutton&state=TRUE
  2. {"success":true} is returned
  3. The state of the button does not change in Homekit

I'd very much like for this to work reliably. Is there any debug info I can gather to assist?

benzman81 commented 4 years ago

What is the config and what does the log look like. You know that a push button switches thes state back right away?

jsiegenthaler commented 4 years ago

Hi benzman81. Thanks for responding so quickly.

I'm using a raspberry pi 4, all installed packages and software is up to date. I'm using Homebridge v1.1.1, but I also tried the new Homebridge beta version, and the symptoms are identical on both

For the log extracts below I reduced the polling trate on another plugin and set debug mode to ON. However I note that no extra log entries occured in debug mode.

My homebridge config is:

       {
            "webhook_port": "51828",
            "sensors": [
                {
                    "id": "doorbellcontact",
                    "type": "contact",
                    "name": "Doorbell Contact",
                    "displayName": "Doorbell Contact",
                    "cache_directory": "./.node-persist/storage",
                    "autoRelease": true,
                    "autoReleaseTime": 2000
                }
            ],
            "pushbuttons": [
                {
                    "id": "doorbellbutton",
                    "name": "Doorbell Button",
                    "displayName": "Doorbell Button",
                    "cache_directory": "./.node-persist/storage",
                    "examplePushUrl": "http://192.168.0.171:51828/?accessoryId=doorbellbutton&state=TRUE",
                    "push_url": ""
                }
            ],
            "platform": "HttpWebHooks"
        }

I have found that the contact sensor works much more reliably than the pushbutton. Here's some log extracts of both the contact sensor and the pushbutton:

Firstly, as a comparision, here is the contact sensor working correctly: I call the url in my browser (Chrome): http://192.168.0.171:51828/?accessoryId=doorbellcontact&state=false Browser shows {"success":true} The accessory in Homekit changes from Closed to Open, and then reverts back to Closed after 2 seconds. Exactly as it should.

The log entry looks like this: [7/26/2020, 07:55:14] [HttpWebHooks] urlValue: false [7/26/2020, 07:55:14] [HttpWebHooks] cached: true [7/26/2020, 07:55:14] [HttpWebHooks] cached !== urlValue: true [7/26/2020, 07:55:14] [HttpWebHooks] Change HomeKit value for contact sensor to 'false'. [7/26/2020, 07:55:14] [Video Doorbell] Ding Dong! [7/26/2020, 07:55:14] [Video Doorbell] Video-doorbell Front Door rang! [7/26/2020, 07:55:15] [Video Doorbell] Snapshot from Front Door at 480x270

Note that I link the contact sensor to the video doorbell doorbell button using an automation.

Trying the same again with the pushbutton:

Call the url: http://192.168.0.171:51828/?accessoryId=doorbellbutton&state=TRUE Browser shows {"success":true} No log entry appears

I even checked to make sure webhooks was properly receiving the command, by changing the id to an id unknown by webhooks: http://192.168.0.171:51828/?accessoryId=doorbellbuttonX&state=false And I got: [ERROR Http WebHook Server] AccessoryId 'doorbellbuttonX' not found. A homebridge log entry occured: [7/26/2020, 08:08:14] [HttpWebHooks] [ERROR Http WebHook Server] AccessoryId 'doorbellbuttonX' not found. Which shows that webhooks was receiving the command correctly.

When I push the doorbell button in Homekit on my iPhone/iPad, the following log entries occur: [7/26/2020, 08:09:32] [HttpWebHooks] Push buttons state change for 'doorbellbutton'... [7/26/2020, 08:09:32] [Video Doorbell] Ding Dong! [7/26/2020, 08:09:32] [Video Doorbell] Video-doorbell Front Door rang!

Again I have the push button linked to the videodoorbell with automation

So everything shows: Webhooks receives to the pushbutton pressed state in the Home app and responds correctly webhooks receives the pushbutton state=true url and sends a success:true message, BUT does not update the HAP protocol with the pushbuttons new state.

Happy to help you debug further This is the last step in my process of adding my 1980s apartment intercom system to Homekit, using a Shelly1 SW switch input via a relay on the doorbell button (using webhooks to bring the SW signal from Shelly1 back to Homekit). The Shelly1 also presses the DOOR OPENER button using the Shelly1 relay.

Could I suggest that you add logging of the webhooks received URL requests? Something like:

[timestamp] [HttpWebHooks] Received http request to change '<accessoryId' state to ''

Then I could see: [timestamp] [HttpWebHooks] Received http request to change 'doorbellbutton' state to 'true'

Which would give me the confidence that the http command has been received

Thanks for helping! Jochen

monza258 commented 4 years ago

Another Information:

You can use the doorbell directly with the camera-ffmpeg plugin. You don't need the Homebridge-Video doorbell Plugin and the doorbell Push button with the http-webhook plugin.

jsiegenthaler commented 4 years ago

Another Information: You can use the doorbell directly with the camera-ffmpeg plugin. You don't need the Homebridge-Video doorbell Plugin and the doorbell Push button with the http-webhook plugin.

Thanks monza258. But how? My doorbell is a 1980s analog intercom system. I am connecting it via a relay to the SW input of a Shelly1. The Shelly1 sends a http command to (in my case) homebridge webhooks. How can I connect a Shelly1 http command directly to the camera ffmeg plugin (which I have) to simulate a video doorbell?. My goal is simple: the doorbell notification must appear when the doorbell is pressed. the electric door opener must be activated when the door is unlocked I haven't yet got the UNLOCK button showing in videodoorbell... don't know if I can.... but if you can tell me how I can add a doorbell pushbutton, and a lockmechanism button into ffmpeg to emulate a videodoorbell, then great!

jsiegenthaler commented 4 years ago

Hi monza258. I use WhatsApp and Apple iMessage. I don't use Telegram. I found the "motion": true and "switches": true options on ffmpeg and am just configuring them now. But it doesn't make it a videodoorbell ;)

benzman81 commented 4 years ago

Please dont discuss off topic stuff here ;-)

You have to send „true“ instead of „TRUE“. The log will appear then.

monza258 commented 4 years ago

Here see my config from FFmpeg plugin:

"motion": true,
"motionTimeout": 1,
"doorbell": true,
"doorbellSwitch": true,
"switches": true,

Then you have also doorbell switch.

Sorry @benzman81 for privat messages. Only will help 😉

jsiegenthaler commented 4 years ago

Thanks @benzman81, That solved the issue. It was confusing because: TRUE produces a result success:true from webhooks, but does not activate the switch in homekit. true produces a result success:true from webhooks, and does activate the switch in homekit.

I didn't realize the url command was case sensitive. Perhaps you could make it non-case sensitive in a future release ?

(@monza258: Ich habe noch fragen, du findest mich auf www.navcoder.com)