benzman81 / homebridge-http-webhooks

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

Unable to configure newly-installed plugin or create accessories #172

Closed shep1976 closed 2 years ago

shep1976 commented 2 years ago

Hi there,

I have installed this plugin, but I simply can't get it to create any accessories with the supplied sample config (I have tried with both a cut down config and the full supplied one from GitHub). I copy and paste the config in and click save, and then the config reverts back to :-

{ "platform": "homebridge-http-webhooks" }

The webhook server is listening ok, but if I was to wget http://192.168.1.3:51828/?accessoryId=1

then I see this in the Hoobs Log

23/10/2022, 18:47:15 Http Webhooks Bridge starting 23/10/2022, 18:47:19 Http Webhooks Bridge Loaded plugin '@kellojo/homebridge-http-webhooks' 23/10/2022, 18:47:19 Http Webhooks Bridge Loading 2 platforms... 23/10/2022, 18:47:19 Http Webhooks Bridge HttpWebHooksStarted server for webhooks on port '51828' listening for host '0.0.0.0'. 23/10/2022, 18:47:19 Http Webhooks Bridge Bridge is running on port 51886. 23/10/2022, 18:53:41 Http Webhooks Bridge HttpWebHooks[ERROR Http WebHook Server] AccessoryId '1' not found.

I have tried the following versions

0.1.16 0.1.15

And the new project

0.1.22

But I get the same symptoms with all 3, so I am wondering if there is something I am doing wrong, but I am following the instructions as written.

I want to use this in connection with some geofencing apps on Android and iOS, to activate / deactivate scenes etc on arrival / departure from the house, as I don't see any other plugin for hoobs that is able to poll an external webhook (IFTTT / Zapier etc).

Thanks

shep1976

benzman81 commented 2 years ago

If you use the config of the readme you must remove any comments. Otherwise this is invalid json.

Calling the url with an unknown AccessoryId will always cause the message you posted.

shep1976 commented 2 years ago

Ahh ok, I assumed the file was ready to go, my apologies.

I have this as the current config (from the Advanced section in Hoobs).

{ "accessories": [], "platforms": [ { "platform": "HttpWebHooks", "webhook_port": "51828", "webhook_listen_host": "::", "webhook_enable_cors": false, "cache_directory": "./.node-persist/storage", "http_auth_user": "test", "http_auth_pass": "test", "https": false, "https_keyfile": "/pathToKeyFile/server.key", "https_certfile": "/pathToKeyFile/server.cert", "sensors": [ { "id": "paul_here", "name": "Paul Present", "type": "occupancy", "autoRelease": false, "autoReleaseTime": 7500 }, { "id": "andrew_here", "name": "Andrew Present", "type": "occupancy", "autoRelease": false, "autoReleaseTime": 7500 } ] } ], "platform": "homebridge-http-webhooks" }

And I can see the 2 occupancy sensors showing in the Hoobs UI.

However I don't seem to be able to set the state.

Just testing using curl at the moment :-

Checking state

paul@linux:~$ curl http://test:test@192.168.1.3:51828/?accessoryId=paul_here {"success":true,"state":false} paul@linux:~$ curl http://test:test@192.168.1.3:51828/?accessoryId=andrew_here {"success":true,"state":false}

Checking invalid accessory ID

paul@linux:~$ curl http://test:test@192.168.1.3:51828/?accessoryId=paul_hero [ERROR Http WebHook Server] AccessoryId 'paul_hero' not found.

Trying to set the state

paul@kinux:~$ curl http://test:test@192.168.1.3:51828/?accessoryId=paul_here&state=true [1] 118 paul@linux:~$ {"success":true,"state":false}

It doesn't seem to change the accessory state in the Hoobs UI (the sensor is still dark rather than lit orange), is this the desired effect? Or am I misunderstanding something? I am rather a newbie to all this, so I am happy to be corrected if I have missed something out.

benzman81 commented 2 years ago

First, I stripped down the json to the really needed stuff:

{
   ...
   ...
   "platforms":[
      ...
      ...
      {
         "platform":"HttpWebHooks",
         "webhook_port":"51828",
         "cache_directory":"./.node-persist/storage",
         "sensors":[
            {
               "id":"paul_here",
               "name":"Paul Present",
               "type":"occupancy"
            },
            {
               "id":"andrew_here",
               "name":"Andrew Present",
               "type":"occupancy"
            }
         ]
      }
      ...
      ...
   ]
   ...
   ...
}

The three dots just show, that there can be other stuff by you. You only need to paste the webhooks platform in the platforms array.

Second, I dont use Hoobs, please try again with native home app.

KE55ARD commented 2 years ago

Very similar issue here. But trying to currently get the status of a HomeBridge dummy switch and it just returns: {"status":-70409}

benzman81 commented 2 years ago

Very similar issue here. But trying to currently get the status of a HomeBridge dummy switch and it just returns: {"status":-70409}

Logs and config would help.

KE55ARD commented 2 years ago

{ "accessories": [], "platforms": [ { "platform": "HttpWebHooks", "cache_directory": "./.node-persist/storage", "https": false, "http_auth_user": "james", "http_auth_pass": "password", "switches": [ { "id": "studymediatoggle", "name": "Study Media Toggle" } ] }, { "platform": "homebridge-http-webhooks" } ] }

shep1976 commented 2 years ago

My issue is fixed (thanks @benzman81), and my occupancy sensors are working as intended. I am leaving this open for others with similar issues.

benzman81 commented 2 years ago

@shep1976 what was the solution?

shep1976 commented 2 years ago

I am not entirely sure, this is my current config.

{
    "accessories": [],
    "platforms": [
        {
            "platform": "HttpWebHooks",
            "webhook_port": "51828",
            "webhook_listen_host": "::",
            "webhook_enable_cors": false,
            "cache_directory": "./.node-persist/storage",
            "http_auth_user": "test",
            "http_auth_pass": "test",
            "https": false,
            "https_keyfile": "/pathToKeyFile/server.key",
            "https_certfile": "/pathToKeyFile/server.cert",
            "sensors": [
                {
                    "id": "paul_here",
                    "name": "Paul Present",
                    "type": "occupancy",
                    "autoRelease": false,
                    "autoReleaseTime": 7500
                },
                {
                    "id": "andrew_here",
                    "name": "Andrew Present",
                    "type": "occupancy",
                    "autoRelease": false,
                    "autoReleaseTime": 7500
                }
            ]
        }
    ],
    "platform": "homebridge-http-webhooks"
}

Which is working fine. I am currently using Locative (https://www.locative.app) on my iPhone as the trigger. My friend who uses Android, is using an IFTTT button trigger to achieve the same result.

benzman81 commented 2 years ago

Ok, then I close this issue.

@KE55ARD your problem sounds different, so please open a new issue if the problem persists.