I want to use one of my standing lamps as a notification/status device for some “system” related stuff.
lamp is equipped with 3 yeelight rgb bulbs lined vertically [bulbs named: dwn (down), mid (middle), btm (bottom)]. main idea is to utilize xiaomi’s wireless button, that has an ability to register long clicks - I want to assign a 15-second long click to “home reset” - when I’ll press & hold the button, every 5 seconds one bulb is turned on with red colour, so I know how long should I hold and when to release to reset the house.
I made a script, that you can feed with bulb choice & color, and it should light up what you want in a way you want, and every 5 seconds I call this script with red color and different bulb. color in web HEX format [it is converted to rgb decimal] and bulb number [don’t want to use names in case when I’ll use other bulbs too - so numbers are translated to bulb name in the script]. it looks like this:
script:
custom_light:
sequence:
- service: light.turn_on
data_template:
entity_id: >
{% set temp = 'light.yeelight_' %}
{% set bulbs = {'1':'dwn','2':'mid','3':'btm'} %}
{% if what_bulb|string in bulbs.keys() %}{{ (temp,bulbs[what_bulb|string])|join }}{% endif %}
rgb_color: >-
'[{{ (what_color[0],what_color[1])|join|int(0,16) }},{{ (what_color[2],what_color[3])|join|int(0,16) }},{{ (what_color[4],what_color[5])|join|int(0,16) }}]'
brightness_pct: '75'
transition: '1'
I’m calling this script with for example:
- service: script.custom_light
data:
what_bulb: 2
what_color: "FF0000"
and this is what I get in the log:
2018-10-27 16:54:07 ERROR (MainThread) [homeassistant.core] Invalid service data for light.turn_on: None for dictionary value @ data['rgb_color']. Got "'[250,0,14]'"
2018-10-27 16:54:07 ERROR (MainThread) [homeassistant.helpers.service] Template rendered invalid service:
templates when tested - worked fine, so I really don’t know what’s going on… as always - I am here to ask the community for hints