QwikSwitch Config For API

HI ALL,

I have a QwikSwitch configured to connect to API. I down’t have a QUSB so I have to use API

I got it working to get to switch on and off but i can’t get the state to show correct n the front page.

Here is the config i used in the configuration.yaml

The values that i get back is as follows
{“success”:true,"@yyyy":“NOT_SUPPORTED”,"@xxxx":{“type”:“RELAY QS-R-S5”,“firmware”:“32”,“epoch”:“1560592193”,“rssi”:“41%”,“value”:1}}

So Value:1 is on and if value:0 its off.

I tried a couple of things but I cant get it to work correct.

Hi @eugenep

I use grep to extract the value. e.g
command_state: ‘curl -v --silent GET "https://qwikswitch.com/api/v1/state/xxxx?" --stderr - | grep -c “@yyyy…value.:1}”’

You need to count the spaces carefully and replace with the full stops otherwise it won’t match the output of the GET, so try without the grep first (as you have done) and count the number of characters between the switch id (@yyyy) and the value field to be replaced with the full stops. It works for me, but if you find a more elegant way please let me know!

Thanks Jaco,

It works awesome.

I was struggling with this for a long time.

Thanks for all the help

Hi there,

I am struggling with the exact same thing. I am able to switch my light on from HA but it wont switch off again. This is my yaml:

  - platform: command_line
    switches:
      qwikswitch_ligh_on:
        command_on: /usr/bin/curl -X GET "https://qwikswitch.com/api/v1/control/xxxx-xxxx-xxxx-xxxx/?device=@yyyyyy&setlevel=100"
        command_off: /usr/bin/curl -X GET "https://qwikswitch.com/api/v1/control/xxxx-xxxx-xxxx/?device=@yyyyyy&setlevel=0"
        command_state:  'curl -v --silent GET "https://qwikswitch.com/api/v1/state/xxxx-xxxx-xxxx-xxxx" --stderr - | grep -c "@yyyyyy   value :1}"'
        friendly_name: Qwikswitch On
        value_template: '{{ value == 1 }}'

Would it be possible to post the script of your solution here please? I’ve new to HA with QS devices, and I would like to get this working.

Thank you in advance.