Hi all,
I’m using ELKOEP automation at home. I configured one sample light already, but I’m not sure if this is proper way. I wish to create ELKOEP integration as a next step as well.
Now what I have and this is working. First I defined RESTfull Sensor which allows me to see STATUS of my LED light. For a status there is URL address in format:
http://192.168.x.x/api/devices//state
# Sensors
sensor:
# RESTful senzor test
- platform: rest
name: JSON LAB
json_attributes:
- automat
- brightness
resource: http://192.168.90.10/api/devices/33633/state
value_template: '{{ value_json.brightness }}'
verify_ssl: false
- platform: template
sensors:
auto:
friendly_name: 'Automat'
value_template: '{{ states.sensor.json_lab.attributes["automat"] }}'
bright:
friendly_name: 'Jas'
value_template: '{{ states.sensor.json_lab.attributes["brightness"] }}'
Then I defines REST Command because my devices have to use PUT syntax. It returns JSON data with several attributes - brightness attribute is most important.
rest_command:
led_brightness:
url: http://192.168.90.10/api/devices/33633
method: PUT
payload: '{"brightness": {{ bright }} }'
content_type: 'application/json; charset=utf-8'
verify_ssl: false
Then I defined LED Template to control LED light and for STATUS update I’m using REST Sensor. I think there is some better way then to use SENSOR. Is it ???
light:
- platform: template
lights:
elkoep_led:
friendly_name: "ElkoEP LED light"
value_template: "{{not is_state_attr('sensor.json_lab', 'brightness', 0) }}"
level_template: "{{((states('sensor.json_lab') | int)*255/100) | int }}"
turn_on:
- service: rest_command.led_brightness
data_template:
bright: >
{{ 100 }}
turn_off:
- service: rest_command.led_brightness
data_template:
bright: >
{{ 0 }}
set_level:
- service: rest_command.led_brightness
data_template:
bright: >
{{ (brightness /255*100) | int }}
Any idea how to do improve it? Or how to create my own integration? I believe there should be some very similar devices like ElkoEP (www.elkoep.com) so I can use this code as a sample. Any experienced user here can help please?