tiberius
(Ttiberi)
March 5, 2019, 4:33pm
1
Hi to all!
I have this error while executing my automation:
Error while executing automation automation.aaaaaaa. Invalid data for call_service at pos 1: None for dictionary value @ data[‘rgb_color’]
what wrong with my code?:
alias: aaaaaaa
trigger:
platform: event
event_type: xiaomi_aqara.click
event_data:
entity_id: binary_sensor.switch_158d000255c3c5
click_type: long_click_press
action:
service: light.turn_on
entity_id: light.gateway_light_7c49eb88c6ec
data_template:
brightness_pct: 20
rgb_color: >
{% set d = (states.sensor.dud_temperature.state) | int %}
{% if d < 23 %}
[0, 0, 255]
{% elif d < 30 %}
[244, 190, 0]
{% else %}
[255, 0, 0]
{% endif %}
If that is how it is truly indented, there are many issues with your code. More wrong than right.
tiberius
(Ttiberi)
March 5, 2019, 4:58pm
3
I’m not so good in coding, but i try. If you can help me with this action, i’ll be very grateful. I need the lamp to turn on with a different color depending on the temperature of water in my boiler.
I am rather new here but YAML requires 2 things to be indented by 2 spaces when they are nested. Like Python, spaces are important in YAML.
Here is my formatting guess. comparing with some of my automations. I do not use data templates yet. I configures my automations from the Lovelace GUI.
Documentation starts here. https://www.home-assistant.io/docs/automation/
- id: aaaaaaa
alias: aaaaaaa
trigger:
platform: event
event_type: xiaomi_aqara.click
event_data:
entity_id: binary_sensor.switch_158d000255c3c5
click_type: long_click_press
condition: []
action:
- data:
service: light.turn_on
entity_id: light.gateway_light_7c49eb88c6ec
data_template:
brightness_pct: 20
rgb_color: >
{% set d = (states.sensor.dud_temperature.state) | int %}
{% if d < 23 %}
[0, 0, 255]
{% elif d < 30 %}
[244, 190, 0]
{% else %}
[255, 0, 0]
{% endif %}
finity
March 5, 2019, 11:49pm
5
try this
alias: aaaaaaa
trigger:
- platform: event
event_type: xiaomi_aqara.click
event_data:
entity_id: binary_sensor.switch_158d000255c3c5
click_type: long_click_press
action:
- service: light.turn_on
entity_id: light.gateway_light_7c49eb88c6ec
data_template:
brightness_pct: 20
rgb_color: >-
{% set d = (states.sensor.dud_temperature.state) | int %}
{% if d < 23 %}
[0, 0, 255]
{% elif d < 30 %}
[244, 190, 0]
{% else %}
[255, 0, 0]
{% endif %}