rudders / homebridge-http

HTTP Plugin for Homebridge
Apache License 2.0
178 stars 110 forks source link

Enigma 2 Receiver #55

Open Luftloch80 opened 7 years ago

Luftloch80 commented 7 years ago

Hi, this is the Output when asking my sat reciever for its status "false" if on "true" if off

Is it possible to change the Habbit of status_url

NovaGL commented 7 years ago

It is possible but not implemented. I have done it on some projects as a "hack"

The reason I haven't included it in this one is I hard coded it, various people want various options for on and off.

If someone could do a pull release that would include various options for on and off that would be great.

Here is how I would approach it.

var mapObj = {false:1,true:0, off:0, on:1};
            var re = new RegExp(Object.keys(mapObj).join("|"),"gi");
powerState = parseInt(powerState.replace(re, function(matched){return mapObj[matched];}));

You can look at a full example here of what I have done https://github.com/NovaGL/homebridge-openremote

MrsDelish commented 7 years ago

How would it be just to set expected status-on/off in config.json "statusOn": "true"
"statusOff": "false" that way it could be configured to suit different needs. I could probably write some code for it, if you want.

NovaGL commented 7 years ago

Do a pull request and I will have a look you can't make it so it breaks it for people use 0 or 1