Hi, I’ve read a lot, many topics and solved lots of problems on my own, but I’m stuck and I have a feeling that with every new possible solution I find somewhere it gets more and more complicated.
I simply want to take the state of a weather sensor and change the color of my lights depending on it (if that works, I would maybe use forecast instead, implement an on/off switch and a 10 second flash every hour before reverting to the state before).
I read about templates and template sensors, years ago I worked with Python (but never got really fluent) and in general I know what a dictionary is and I guess this might be useful to shorten this automation, but I didn’t get it implemented so I chose this solution with choose… Which is not working (“Message malformed: required key not provided @ data[‘action’]”).
Here’s my code:
alias: Licht Wetterinfo
description: ""
trigger:
- entity_id: sensor.openweathermap_condition
platform: state
action:
- choose:
- alias: Option 1
- conditions:
- condition: state
entity_id: sensor.openweathermap_condition
state: clear-night
sequence:
- data:
scene_id: before
snapshot_entities: light.color_schlafzimmer
service: scene.create
- data:
color_name: navy
brightness_pct: 100
entity_id: light.color_schlafzimmer
flash: long
entity_id: light.color_schlafzimmer
service: light.turn_on
- delay: "00:00:10"
- data: {}
entity_id: scene.before
service: scene.turn_on
default: []
- choose:
- alias: Option 2
- conditions:
- condition: state
entity_id: sensor.openweathermap_condition
state: sunny
sequence:
- data:
scene_id: before
snapshot_entities: light.color_schlafzimmer
service: scene.create
- data:
color_name: yellow
brightness_pct: 100
entity_id: light.color_schlafzimmer
flash: long
entity_id: light.color_schlafzimmer
service: light.turn_on
- delay: "00:00:10"
- data: {}
entity_id: scene.before
service: scene.turn_on
default: []
- choose:
- alias: Option 3
- conditions:
- condition: state
entity_id: sensor.openweathermap_condition
state: cloudy
sequence:
- data:
scene_id: before
snapshot_entities: light.color_schlafzimmer
service: scene.create
- data:
color_name: maroon
brightness_pct: 100
entity_id: light.color_schlafzimmer
flash: long
entity_id: light.color_schlafzimmer
service: light.turn_on
- delay: "00:00:10"
- data: {}
entity_id: scene.before
service: scene.turn_on
default: []
- choose:
- alias: Option 4
- conditions:
- condition: state
entity_id: sensor.openweathermap_condition
state: fog
sequence:
- data:
scene_id: before
snapshot_entities: light.color_schlafzimmer
service: scene.create
- data:
color_name: yellowgreen
brightness_pct: 100
entity_id: light.color_schlafzimmer
flash: long
entity_id: light.color_schlafzimmer
service: light.turn_on
- delay: "00:00:10"
- data: {}
entity_id: scene.before
service: scene.turn_on
default: []
- choose:
- alias: Option 5
- conditions:
- condition: state
entity_id: sensor.openweathermap_condition
state: partlycloudy
sequence:
- data:
scene_id: before
snapshot_entities: light.color_schlafzimmer
service: scene.create
- data:
color_name: indianred
brightness_pct: 100
entity_id: light.color_schlafzimmer
flash: long
entity_id: light.color_schlafzimmer
service: light.turn_on
- delay: "00:00:10"
- data: {}
entity_id: scene.before
service: scene.turn_on
default: []
- choose:
- alias: Option 6
- conditions:
- condition: state
entity_id: sensor.openweathermap_condition
state: rainy
sequence:
- data:
scene_id: before
snapshot_entities: light.color_schlafzimmer
service: scene.create
- data:
color_name: lawngreen
brightness_pct: 100
entity_id: light.color_schlafzimmer
flash: long
entity_id: light.color_schlafzimmer
service: light.turn_on
- delay: "00:00:10"
- data: {}
entity_id: scene.before
service: scene.turn_on
default: []
- choose:
- alias: Option 7
- conditions:
- condition: state
entity_id: sensor.openweathermap_condition
state: windy
sequence:
- data:
scene_id: before
snapshot_entities: light.color_schlafzimmer
service: scene.create
- data:
color_name: darkorange
brightness_pct: 100
entity_id: light.color_schlafzimmer
flash: long
entity_id: light.color_schlafzimmer
service: light.turn_on
- delay: "00:00:10"
- data: {}
entity_id: scene.before
service: scene.turn_on
default: []
- choose:
- alias: Option 8
- conditions:
- condition: state
entity_id: sensor.openweathermap_condition
state: snowy
sequence:
- data:
scene_id: before
snapshot_entities: light.color_schlafzimmer
service: scene.create
- data:
color_name: green
brightness_pct: 100
entity_id: light.color_schlafzimmer
flash: long
entity_id: light.color_schlafzimmer
service: light.turn_on
- delay: "00:00:10"
- data: {}
entity_id: scene.before
service: scene.turn_on
default: []
- choose:
- alias: Option 9
- conditions:
- condition: state
entity_id: sensor.openweathermap_condition
state: snowy-rainy
sequence:
- data:
scene_id: before
snapshot_entities: light.color_schlafzimmer
service: scene.create
- data:
color_name: limegreen
brightness_pct: 100
entity_id: light.color_schlafzimmer
flash: long
entity_id: light.color_schlafzimmer
service: light.turn_on
- delay: "00:00:10"
- data: {}
entity_id: scene.before
service: scene.turn_on
default: []
- choose:
- alias: Option 10
- conditions:
- condition: state
entity_id: sensor.openweathermap_condition
state: pouring
sequence:
- data:
scene_id: before
snapshot_entities: light.color_schlafzimmer
service: scene.create
- data:
color_name: teal
brightness_pct: 100
entity_id: light.color_schlafzimmer
flash: long
entity_id: light.color_schlafzimmer
service: light.turn_on
- delay: "00:00:10"
- data: {}
entity_id: scene.before
service: scene.turn_on
default: []
- choose:
- alias: Option 11
- conditions:
- condition: state
entity_id: sensor.openweathermap_condition
state: lightning
sequence:
- data:
scene_id: before
snapshot_entities: light.color_schlafzimmer
service: scene.create
- data:
color_name: red
brightness_pct: 100
entity_id: light.color_schlafzimmer
flash: long
entity_id: light.color_schlafzimmer
service: light.turn_on
- delay: "00:00:10"
- data: {}
entity_id: scene.before
service: scene.turn_on
default: []
- choose:
- alias: Option 12
- conditions:
- condition: state
entity_id: sensor.openweathermap_condition
state: hail
sequence:
- data:
scene_id: before
snapshot_entities: light.color_schlafzimmer
service: scene.create
- data:
color_name: aquamarine
brightness_pct: 100
entity_id: light.color_schlafzimmer
flash: long
entity_id: light.color_schlafzimmer
service: light.turn_on
- delay: "00:00:10"
- data: {}
entity_id: scene.before
service: scene.turn_on
default: []
- choose:
- alias: Option 13
- conditions:
- condition: state
entity_id: sensor.openweathermap_condition
state: windy-variant
sequence:
- data:
scene_id: before
snapshot_entities: light.color_schlafzimmer
service: scene.create
- data:
color_name: lightsalmon
brightness_pct: 100
entity_id: light.color_schlafzimmer
flash: long
entity_id: light.color_schlafzimmer
service: light.turn_on
- delay: "00:00:10"
- data: {}
entity_id: scene.before
service: scene.turn_on
default: []
- choose:
- alias: Option 14
- conditions:
- condition: state
entity_id: sensor.openweathermap_condition
state: lightning-rainy
sequence:
- data:
scene_id: before
snapshot_entities: light.color_schlafzimmer
service: scene.create
- data:
color_name: crimson
brightness_pct: 100
entity_id: light.color_schlafzimmer
flash: long
entity_id: light.color_schlafzimmer
service: light.turn_on
- delay: "00:00:10"
- data: {}
entity_id: scene.before
service: scene.turn_on
default: []
Thank you for ideas, hints or help in advance.