Control lights using HTTP

Hi guys, I just started learning HA and got stuck trying to configure my lights to show up. I’m using a not so well known webserver for controlling my lights. The lights are controllable using HTTP GET but I don’t know how to add them in HA

Here is the documentation for controlling/checking status http://www.webswitch.se/wp/?page_id=342 it would be great if I could setup hassio to even check the status of the lights. I tried using the “command_line” platform but got “invalid configuration”

switch:
  - platform: command_line
    switches:
      command_on: "/usr/bin/curl -X GET http://192.168.1.236:8080/relaycontrol/on/1"
      command_off: "/usr/bin/curl -X GET http://192.168.1.236:8080/relaycontrol/off/1"
      friendly_name: Golv LED

Should I be using the RESTful switch with a custom template instead?

I’ve just written a simple python script that checks the state of the switch, can I somehow use this in HA or what would be the best approach here?

Thanks

You get an invalid configuration because you are missing the line with the name of the switch. See the first example in the command line switch page.

And you probably could use the restful switch component instead.

Sorry for the late reply, haven’t had the chance to play with HA for a few days.

Thanks, gave it a name and now it works as expected!

I took a closer look at RESTful switch component, and I can’t get it to work, probably because my server doesn’t accept anything else than HTTP GET meaning I have to set on/off state using two different addresses, and check state using a third address.

I also took a look at input boolean, but didn’t manage to set it up properly. I’d like to setup a “dummy-switch” and use Node RED to check the state of the lights on the relayserver and display correct status in HA dash and also automate/toggle the lights on/off

1 Like