Moin zusammen,
ich steuere ein Gerät mittel Web API und habe jeweils einen URL Aufruf für "Fenster auf" und "Fenster zu".
Klappt mit diesem Plugin super:
https://github.com/Supereg/homebridge-http-switch
Allerdings würde ich gerne den aktuellen Status einbinden und scheitere bisher.
Der Server liefert den Status leider nicht mit 1 und 0 zurück, sondern gibt folgenden String aus:
t:swr s:250 e:0 ok:1 ro:0 pos:c fix:1 a:-98 fw:3.4.1-15-g3d0f mem:21824 up:45516206 ip:1001564xxx cid:Hendriks Fenster rssi:-61 time:1556438939 wm:1 wp:3 wst:3 id:600194xxxx
Relevant ist der Punkt "pos:c" für geschlossen und "pos:o" für offen. Bei Position "pos:o" soll der Schalter den Status "an" haben.
Hat jemand Erfahrung mit Status patterns?
Examples for custom statusPatterns
The statusPattern
property can be used to change the phrase which is used to identify if the switch should be turned on or off. So when you want the switch to be turned on when your server sends "true" in the body of the http response you could specify the following pattern:
However using Regular Expressions much more complex patterns are possible. Let's assume your http enabled device responds with the following json string as body, where one property has an random value an the other indicates the status of the switch:
Then you could use the following pattern:
More on how to build regex patterns: https://www.w3schools.com/jsref/jsref_obj_regexp.asp