Supereg / homebridge-http-switch

Powerful http switch for Homebridge: https://github.com/homebridge/homebridge
ISC License
222 stars 37 forks source link

Can't get status… #130

Open albi opened 3 months ago

albi commented 3 months ago

I try to get the audio source status of my amp for the stateful http-switch. Switching the state already works, but I can't get the status right. The status response is:

{"type":"0","ch":"0","mode":"43","loop":"4","eq":"0","vendor":"","status":"stop","curpos":"0","offset_pts":"0","totlen":"0","Title":"556E6B6E6F776E","Artist":"556E6B6E6F776E","Album":"556E6B6E6F776E","alarmflag":"0","plicount":"0","plicurr":"0","vol":"50","mute":"0"}

Where "mode", when set to 43, should reflect as "true" for the switch. When "mode" is another value, it should be seen as "false".

My config for the switch is:

{ "accessory": "HTTP-SWITCH", "name": "TV Audio Test", "switchType": "stateful", "onUrl": "https://10.0.1.23/httpapi.asp?command=setPlayerCmd:switchmode:optical", "offUrl": "https://10.0.1.23/httpapi.asp?command=setPlayerCmd:switchmode:wifi", "statusUrl": "https://10.0.1.23/httpapi.asp?command=getPlayerStatus", "statusPattern": "/\"mode\":\"43\"/g" }

Supereg commented 2 months ago

Hey, could you try the following for the status pattern:

{
  "statusPattern": "\"mode\":\"43\""
}

You do not need to need regex string literals /.../g

albi commented 2 months ago

Currently my config is:

{ "accessory": "HTTP-SWITCH", "name": "TV Audio Test", "switchType": "stateful", "onUrl": "https://10.0.1.23/httpapi.asp?command=setPlayerCmd:switchmode:optical", "offUrl": "https://10.0.1.23/httpapi.asp?command=setPlayerCmd:switchmode:wifi", "statusUrl": "https://10.0.1.23/httpapi.asp?command=getPlayerStatus", "http_method": "GET", "status_pattern": "\"mode\":\"43\"", "statusResponseType": "json", "pollingInterval": 10, "timeout": 5000 }

But it won't update the status.