Integrate entity with HTTP API call?

I’d like to integrate a device as an entity that can only be accessed via HTTP API call. I assume this works with the REST API in Hassio. I have, however, never used REST for myself.

Could anybody let me know please what to put into the configuration.yaml that this will work so I can turn the light on and off through the Hassio GUI?

Turn ON light:

http://user:[email protected]/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1

Turn OFF light:

http://user:[email protected]/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=0

Check status if light is ON

http://user:[email protected]/cgi-bin/coaxialControlIO.cgi?action=getStatus&channel=1
status.status.Speaker=Off
status.status.WhiteLight=On

1 Like

To add too @flamingm0e try using curl first to get the command working exactly how you want it then transfer it using the integration above.

Do I really need the curl command? because just using the http line is enough when put into the browser to trigger it. So won’t this work with the Rest API in hassio?

See

I would have thought a RESTful switch would work for that ?

Then use a light template to make the switch a light

1 Like

I have tried integrating it using the Rest Switch but unfortunately, it does not work. It won’t even create a switch entity. It is obvious, I made some kind of stupid mistake… Hope someone can correct my config.yaml integration:

switch:
  - platform: rest
    name: CameraLED
    resource: http://192.168.8.109/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1
    username: user
    password: password
    body_on: 'info[0].IO=1'
    body_off: 'info[0].IO=0'
    is_on_template: '{{ value_json.is_active }}'
    headers:
      Content-Type: application/json
    verify_ssl: false

This is the line I’ve to put into my browser to turn it on:

http://user:[email protected]/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1

and this to turn it off:

http://user:[email protected]/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=0

Have you tried using quotes around your URL?

I’ve just tried the URL with quotes but it does not make any difference…

Maybe try just http://192.168.8.109/cgi-bin for the resource and the rest for the body
If maybe try ARC for Chrome or similar so you make sure it works there first.

I’ve tried it with just http://192.168.8.109/cgi-bin and the rest for body but it did not work. I have also tried it with the Chrome extension but I did not get it to work as there are too many possible settings there.

Could try:

http://user:[email protected]/cgi-bin/

and remove the user and password entries in the config

Also, try removing the headers entry

Looking at the docs for the camera, it uses GET to switch the light/speaker on/off and I think the RESTful switch only supports POST and PUT

Try, in ARC using GET and POST, with one of the urls above in the Request URL.

@enigma2k - I’m basically going through the same process as you for my cameras. What solution did you end up going with? and can you share your config?

command_line:
  - switch:
      name: Back Porch Camera White Light
      command_on: >
        curl --silent --digest -g "http://admin:pass@IP_ADDR/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1"
      command_off: >
        curl --silent --digest -g "http://admin:pass@IP_ADDR/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=0"
      command_state: >
        curl --silent --digest -g "http://admin:pass@IP_ADDR/cgi-bin/coaxialControlIO.cgi?action=getStatus&channel=0" | grep -q "status.status.WhiteLight=On"