Hi everybody, I’m just quite a new boy in HA world. Using RasPi 3B+, Hass.io, Sonoff Tasmota. Almost everything is working. Now I’m facing a new challenge to use ELKO EP devices (https://www.elkoep.com/wireless-rf-control) which are not supported by HA yet. Is it this right thread here to ask about developing questions please?
I have several LED switches, which are controlled over LAN. Here is a sample how I can control them from HA:
- platform: command_line
switches:
elkoep_led_lab:
command_on: /usr/bin/curl -X PUT http://192.168.90.10/api/devices/33633 -d'{"brightness":100}'
command_off: /usr/bin/curl -X PUT http://192.168.90.10/api/devices/33633 -d'{"brightness":0}'
command_state: /usr/bin/curl -X GET http://192.168.90.10/api/devices/33633/state
value_template: '{{value_json.brightness != 0}}'
friendly_name: "LED LAB"
Currently I’m able only turn it on and of in preset brightness. I wish to have some dim able function using brightness values. Any ideas how to implement this? Maybe from some different products?
But this is probably not good approach. Not only because it is not working I wish to implement it as a new platform. I think it should be very similar as other IOT devices.
This is partly new to me, so I don’t have a ready made example for you. We can figure it out together though. I think you’ll need shell commands instead of a command line switch. A switch only allows on & off, so no brightness setting. You’ll want to replace the command line switch with a light template.
So shell commands probably something like this:
shell_command:
led_on: /usr/bin/curl -X PUT http://192.168.90.10/api/devices/33633 -d'{"brightness":100}'
led_off: /usr/bin/curl -X PUT http://192.168.90.10/api/devices/33633 -d'{"brightness":0}'
led_brightness: /usr/bin/curl -X PUT http://192.168.90.10/api/devices/33633 -d'{"brightness:"{{bri}}}'
You’ll have to try if they work for you like this. I’m not sure about the quotes and curlies.
Thank you very much Emphyrio! But I’m still not able to transfer brightness parameter.
shell_command working. But only in first two cases. Last one with parameter not. I’m trying to run it from Developer Tolls / Services and as DATA I put 100. I also tried this:
led_brightness: /usr/bin/curl -X PUT http://192.168.90.10/api/devices/33633 -d'{{bri}}'
and as data I used: {“brightness”: 100} but still no sucess.
That last calculation is for converting the default brightness scale (0-255) to a percentage scale (0-100). I’m not sure about the curlies and quotes, don’t have any experience with such a URL construct. You might need to escape some of those characters.