luisiam / homebridge-cmdswitch2

CMD Plugin for HomeBridge (API 2.0): https://github.com/nfarina/homebridge
Apache License 2.0
176 stars 29 forks source link

state_cmd #12

Open DJay-X opened 7 years ago

DJay-X commented 7 years ago

Hi and thanks for your work and this plugin. I hope not to bother with this but I'm a bit lost with state_cmd. I want to use my Robot Vacuum Cleaner with cmdswitch2 and hope you can help how to get it to work correct and also knowing the state. Does this look right?

"platforms": [{ "platform": "cmdSwitch2", "name": "CMD Switch", "switches": [{ "name" : "HomBot", "on_cmd": "http://xxx.xxx.xxx.xx:6260/json.cgi?%7b%22COMMAND%22:%22CLEAN_START%22%7d", "off_cmd": "http://xxx.xxx.xxx.xx:6260/json.cgi?%7b%22COMMAND%22:%22HOMING%22%7d", "state_cmd": "http://xxx.xxx.xxx.xx:6260/status.html" },

The status is in the first line. status.html named Robot-state: This state can be "CHARGING","STANDBY","PAUSE" when off and WORKING","BACKMOVING_INIT","HOMING" when on.

Thanks in advance for your help.

luisiam commented 7 years ago

You can use bash script to parse the html and look for specific words.

neptunix commented 7 years ago

Hi guys,

can someone please tell how execution for state_cmd works? I can see the if I cat /some/file and file is empty, I still get true

Is the only option to get false - to have some text in stderr?

casouri commented 6 years ago

I think if you have some script that returns 1 and call it, the result will be considered false

neptunix commented 6 years ago

you are right. Exit code == 0 - is true. Any other is false