Qwikswitch API

Hi All. I’m new to HA and struggling to setup Qwikswitch relays using the Qwikswitch wifi bridge (no QwikSwitch QSUSB Hub). The following GET calls to the QS API works perfectly to switch a Qwikswitch relay on, of or get the status of the switch:

#switch off:
https://qwikswitch.com/api/v1/control/:API_KEY?device=:DEVICE_ID&setlevel=0

#switch on:
https://qwikswitch.com/api/v1/control/:API_KEY?device=DEVICE_ID&setlevel=100

status:
https://qwikswitch.com/api/v1/state/:API_KEY/

Any idea how to get this working in HA as a switch? Restful command or restful switch doesn’t work, I suspect I need to create a custom component?

Thanks for the assistance

A command_line switch using curl would probably work, I think (if you are on a linux box of some descirption)

Hi Keith

Thanks for pointing me in the right direction. I’ve added the following to my config file, but unfortuneately it doesn’t work:

switch:
platform: command_line
switches:
bedroom_light:
command_on: “/usr/bin/curl -X GET https://qwikswitch.com/api/v1/control/APIKEY?device=@257ba0&setlevel=100
command_off: “/usr/bin/curl -X GET https://qwikswitch.com/api/v1/control/APIKEY?device=@257ba0&setlevel=0
friendly_name: Bedroom Light

When I SSH to home assistant as root, the curl command works fine to switch on/off the light. However, when I try running the curl command from the HASS configurator “execute shell command” tool, I get the error:[Errno 2] No such file or directory ‘usr/bin/curl’ Not sure if this is related to the issue, perhaps some permissions issue?

Thanks again

You may need to add sudo /usr/bin/curl … and/or give HA permissions to use curl/any command, I think you can do this by adding HA to the sudoers list.

Thanks, seems like not even root can use sudo if I run Hassio. Sounds like I need to start over using Hassbian instead :frowning:

Hmmm well you would be better off using the Hassio forum page to get better results :stuck_out_tongue: As I understand it Hassio doesn’t use a standard linux distribution and is in a docker container so cannot use the standard commands. Try asking in the Hassio forum pages :slight_smile:

Hi Guys, I have plugged my USB QS hub into my Raspberry pi 4 B and tried installing the code from the Joulco-Square/ qsusb source as none of the other braches of code above seem to be compatible with pi 4 or the latest
HA 2020.12.2 (and newer). Can anyone help me get the custom integration installed from the HACS in HA?

Not sure of answer was ever done here… I got mine to work like this.

rest_command:

hallwaylight_on:

url: “https://qwikswitch.com/api/v1/control/1234-5678-9012-1234?device=@0c000&setlevel=100

method: get

hallwaylight_off:

url: “https://qwikswitch.com/api/v1/control/1234-5678-9012-1234?device=@0c000&setlevel=0

method: get

and then created a script to to call on and off, and then a switch so i can call individual scripts to turn it on and off.

as added created a helper to chnage the switch from switch to light.

@Jaco_Muller @HybridRCG I’ve created a rudimentary integration for the Qwikswitch API at GitHub - rhanekom/hass-qwikswitch-api: Home Assistant Integration for Qwikswitch switches, using the API.

Still early stages, so I’m sure there are some issues to resolve - but should be a lower friction route to control your Qwikswitch lights.