rudders / homebridge-http

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

JSON Power Status #69

Closed JonnyBoy333 closed 7 years ago

JonnyBoy333 commented 7 years ago

This PR adds a feature to be able to specify a JSON object for the status_on config parameter. This will help in cases where you need to check if multiple properties of an accessory are in a certain state for it to be considered "ON." One example might be a speaker that needs to have all of the following properties to be considered "ON."

{
    "playMode": "PLAY",
    "source": "STREAMING",
    "mute": "OFF"
}

When the plugin gets the power state it will check that all the config file object properties exist and have the same value as the response from the accessory.

This in reference to issue #68.

NovaGL commented 7 years ago

Thanks for this. It's good to have constant improvements that don't stray too far from the original vision of this plugin

DJay-X commented 7 years ago

I hope this isn't to off-topic. Thanks in advance for your friendly help.

Do you guys see a way how I could get the correct status to the switch? At the moment it's just an on/off not in relation to the real state of the robot.

{ "accessory": "Http", "name": "HomBot", "on_url": "http://xxx.xxx.xxx.xx:6260/json.cgi?%7b%22COMMAND%22:%22CLEAN_START%22%7d", "on_body": "{\"state\":\"On\"}", "off_url": "http://xxx.xxx.xxx.xx:6260/json.cgi?%7b%22COMMAND%22:%22HOMING%22%7d", "off_body": "{\"state\":\"Off\"}", "username": "", "password": "", "sendimmediately": "", "switchHandling": "realtime", "http_method": "GET", "service": "Switch", "brightnessHandling": "no" },

But the HomBot delivers a state in a separate html page with Robot-state: in the first line. http://xxx.xxx.xxx.xx:6260/status.html

Robot-state: CHARGING Batt-Perc: 100 Program Version: lg.srv, V2.51 compiled 18.11.2016, by fx2 Client Commands: 0 Cmd per second: 0.000000 Http requests: 26 Cpu-Idle: 85.16 Cpu-User: 1.76 Cpu-Sys: 13.06 Cpu-Nice: 0.00 Mem-Usage: 0.680 MB Turbo: false Repeat: false Mode: ZZ Version: 16552 Nickname: HOMBOT Bumping: 2215 Last-Clean: 2017/06/27/17/07/35.518662

There are several states possible. OFF = CHARGING, STANDBY ON = BACKMOVING_INIT, WORKING, PAUSE, HOMING, DOCKING

NovaGL commented 7 years ago

Hi DJay79.

This plugin only does simple on off commands. So it will never say charging standby.

Open an issue any way and @JonnyBoy333

I don't think it's personally possible but I didn't make this pull release.

@JonnyBoy333 If you want to add your PR to my other repo https://github.com/NovaGL/homebridge-http-advanced

You can go wild there and add all sorts of characteristics.

JonnyBoy333 commented 7 years ago

@DJay79 The plugin right now doesn't handle more intricate operators for the ON or OFF states. So you can't say this value OR this value or this value AND this value mean the switch is on.

That being said, in my fork I have worked on a way to have an array of ON or OFF values that you can write more complex configurations for. I realize this functionality is better suited for the homebridge-http-advanced plugin so if I have time this weekend I'll do a PR into that repo.

NovaGL commented 7 years ago

@DJay79 Thought you might like this repo. Control HomeKit over MQTT https://github.com/hobbyquaker/homekit2mqtt