Closed mabiste closed 4 years ago
Must I have as result of the regex compilation just a 'Full match' like the example referenzed on the readme.md of homebridge-http-switch? Or as the exmaple on your comment to issue #35 (Cannot read stare from status url) of the homebridge-http-switch plugin?
Yes, I've solved the problem by using this statusPattern:
\"value\":\s\"1\"
With this pattern, I just get a 'Full match' when value is "1":
When the value is "0", I get no match:
And also on the debug log I can see correct parsing:
getPowerState() request returned successfully (200). Body: '{"LL": { "control": "dev/sps/io/LK207001/state", "value": "0", "Code": "200"}} getPowerState() power is currently OFF
Great, you already figured it out by yourself 👏
Regarding your original pattern ("value":\s"(-?[0-9]):
). The problem here was that you would math any one digit number ([0-9]
) ad event any negative number (-?
). The plugin considers anything which matches as ON an and anything that doesn't match as off. This is special for the on characteristic as it only as two states on
and off
. So the thing you figured out yourself is the perfect regex for your problem 😃
Hey Andi,
first of all, thank you very much for your great plugins! I'm using them together with the http-notification-server which is very nice!
Currently, I have an issue with parsing the 'On' status of the light bulb from statusUrl response body.
When I request the On status I get a JSON body like this one:
-> "value" is "1" when the light is on and "0" when the light is off
I've set the statusPattern to \"value\":\s\"(-?[0-9]):
...and tested it on https://regex101.com with my response body:
But when I open my Home app on my iPhone, I always get the light 'On' status is 'on'. On the debug log I can see the right status on the response body (value = "0"), but it was parsed as 'ON'':
Can you tell me what's wrong? Thank you!
Kind regards! Marco