Contact sensor always false
Closed this issue · 12 comments
First, thank you for this plugin. I think it will be very handy.
I am trying my first contact sensor.
I added
{
"platform": "HttpWebHooks",
"webhook_port": "51828",
"webhook_listen_host": "0.0.0.0",
"sensors": [
{
"id": "MyQ007",
"name": "MyQ",
"type": "contact",
"autoRelease": false
}
]
}
And no matter if I use true
or false
I get the same response.
{"success":true,"state":false}
I'm sure I've done something wrong, but I don't see what it is and I don't see anything in the homebridge logs.
What is the url you are calling?
I've tried the privateIP from inside my network and a public IP with port forwarding turned on the router:
curl http://[privateIP]:51828/?accessoryId=Q007&state=true
curl http://[puplicIP]:51828/?accessoryId=Q007&state=true
In both cases I get a success (the server is reached) but the response is always state:false.
Could you turn on debug log for your homebridge and post the log here removing any sensitive information?
[11/12/2023, 8:59:14 PM] Loaded plugin: homebridge-http-webhooks@0.1.18
[11/12/2023, 8:59:14 PM] Registering platform 'homebridge-http-webhooks.HttpWebHooks'
[11/12/2023, 8:59:14 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookSensor'
[11/12/2023, 8:59:14 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookSwitch'
[11/12/2023, 8:59:14 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookPushButton'
[11/12/2023, 8:59:14 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookLight'
[11/12/2023, 8:59:14 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookThermostat'
[11/12/2023, 8:59:14 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookOutlet'
[11/12/2023, 8:59:14 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookSecurity'
[11/12/2023, 8:59:14 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookGarageDoorOpener'
[11/12/2023, 8:59:14 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookStatelessSwitch'
[11/12/2023, 8:59:14 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookLockMechanism'
[11/12/2023, 8:59:14 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookWindowCovering'
[11/12/2023, 8:59:14 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookFanv2'
[11/12/2023, 8:59:14 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookCarbonDioxideSensor'
[11/12/2023, 8:59:14 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookValve'
[11/12/2023, 8:59:24 PM] Loading 8 platforms...
[11/12/2023, 8:59:24 PM] [Nest] Initializing Nest platform...
[11/12/2023, 8:59:24 PM] [Nest] Initializing child bridge ***3
[11/12/2023, 8:59:25 PM] Initializing platform accessory 'Now'...
[11/12/2023, 8:59:25 PM] Initializing platform accessory 'MyQ'...
[11/12/2023, 8:59:25 PM] Loading 22 accessories...
[11/12/2023, 8:59:34 PM] [Homebridge UI] [HapClient] Discovery :: Found HAP device with username ***
[11/12/2023, 8:59:34 PM] [Homebridge UI] [HapClient] Discovery :: Testing *** via http://192.168.0.19:45766/accessories
[11/12/2023, 8:59:35 PM] [Homebridge UI] [HapClient] Discovery :: Success *** via http://192.168.0.19:45766/accessories
[11/12/2023, 8:59:35 PM] [Homebridge UI] [HapClient] Discovery :: [192.168.0.19:45766 (***)] Instance Registered
[11/12/2023, 8:59:35 PM] [Homebridge UI] [HapClient] Discovery :: Found HAP device with username ***2
[11/12/2023, 8:59:35 PM] [Homebridge UI] [HapClient] Discovery :: Testing ***2 via http://192.168.0.19:32728/accessories
[11/12/2023, 8:59:35 PM] [Homebridge UI] [HapClient] Discovery :: Found HAP device with username ***3
[11/12/2023, 8:59:35 PM] [Homebridge UI] [HapClient] Discovery :: Testing ***3 via http://192.168.0.19:52365/accessories
[11/12/2023, 8:59:35 PM] [Homebridge UI] [HapClient] Discovery :: Success ***3 via http://192.168.0.19:52365/accessories
[11/12/2023, 8:59:35 PM] [Homebridge UI] [HapClient] Discovery :: Success ***2 via http://192.168.0.19:32728/accessories
[11/12/2023, 8:59:36 PM] [Homebridge UI] [HapClient] Discovery :: [192.168.0.19:52365 (***3)] Instance Registered
[11/12/2023, 8:59:36 PM] [Homebridge UI] [HapClient] Discovery :: [192.168.0.19:32728 (***2)] returned an error while attempting connection: Request failed with status code 470
[11/12/2023, 8:59:36 PM] [Homebridge UI] [HapClient] Discovery :: Could not register to device with username ***2
[11/12/2023, 8:59:37 PM] [Rachio] To test Webhook setup, navigate to http://app13:e4FuECKCmuH@private.thebiermans.net:12453/test to ensure port forwarding is configured correctly.
Note: For local config this will not work from this server, you cannot be connected to the same router doing the fowarding.
The best way to test this is from a cell phone, with WiFi off.
[11/12/2023, 8:59:58 PM] [Homebridge UI] [HapClient] Discovery :: Ended
Please start in debug mode an send log again.
I appreciate the help, but I don't understand the request. Debugging was turned on (debug: true in the json). And Homebridge was restarted.
I tried to filter out things that seemed unrelated. Is there something specific you are looking for? It would be a lot easier than trying to filter out everything that is private from the entire log.
One of these days maybe homebridge will provide a sanitized log feature.
I think @benzman81 means:
Homebridge Settings > Homebridge Debug Mode > set switch to ON
Then restart Homebridge
You will see many more log entries.
11/11/2023, 7:55:24 PM] Registering accessory 'homebridge-http-switch.HTTP-SWITCH'
[11/11/2023, 7:55:24 PM] ---
[11/11/2023, 7:55:24 PM] [Homebridge UI] [HapClient] Discovery :: Success 1B:20:2D:1A:1B:4B via http://192.168.0.1:51681/accessories
[11/11/2023, 7:55:26 PM] Loaded plugin: homebridge-http-webhooks@0.1.18
[11/11/2023, 7:55:26 PM] Registering platform 'homebridge-http-webhooks.HttpWebHooks'
[11/11/2023, 7:55:26 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookSensor'
[11/11/2023, 7:55:26 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookSwitch'
[11/11/2023, 7:55:26 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookPushButton'
[11/11/2023, 7:55:26 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookLight'
[11/11/2023, 7:55:26 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookThermostat'
[11/11/2023, 7:55:26 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookOutlet'
[11/11/2023, 7:55:26 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookSecurity'
[11/11/2023, 7:55:26 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookGarageDoorOpener'
[11/11/2023, 7:55:26 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookStatelessSwitch'
[11/11/2023, 7:55:26 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookLockMechanism'
[11/11/2023, 7:55:26 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookWindowCovering'
[11/11/2023, 7:55:26 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookFanv2'
[11/11/2023, 7:55:26 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookCarbonDioxideSensor'
[11/11/2023, 7:55:26 PM] Registering accessory 'homebridge-http-webhooks.HttpWebHookValve'
[11/11/2023, 7:55:26 PM] ---
[11/11/2023, 7:55:36 PM] [HttpWebHooks] Initializing HttpWebHooks platform...
[11/11/2023, 7:55:37 PM] [HttpWebHooks] Started server for webhooks on port '51828' listening for host '0.0.0.0'.
[11/11/2023, 7:55:37 PM] Initializing platform accessory 'MyQ'...
[11/14/2023, 2:52:24 PM] [HttpWebHooks] No urlValue
[11/14/2023, 2:52:30 PM] [HttpWebHooks] No urlValue
Note 192.168.0.1 is not the homebridge IP if that matters.
@mbierman the state parameter was not found.
i found this on stackoverflow:
If you see your CURL command, you will notice that you are using & to pass multiple values to your request parameters in this GET call/request.
curl http://[puplicIP]:51828/?accessoryId=Q007&state=true
In the Linux/Unix environment, & has a pre-defined interpretation. It is used to run any command in the background. So if & is present after any text, then the text is interpreted as a command and & means to run this command in the background.
Any text after & is treated as a new command. So your above Curl get request is interpreted by Linux as 2 different commands:
i. http://[puplicIP]:51828/?accessoryId=Q007&
ii. state=true
Solution : The solution to avoid this interpretation by Unix/Linux is to surround your url with double quotes "
curl „http://[puplicIP]:51828/?accessoryId=Q007&state=true“
@benzman81 sounds exactly right! Note: on an English keyboard and in English language the " quotation mark character is " so the command becomes:
curl "http://[puplicIP]:51828/?accessoryId=Q007&state=true"
That is a bit embarrassing. I should have figured that out. Thank you! @benzman81 @jsiegenthaler