I understand that when you add a condition in a script (via Hass.io script editor), everything after that condition is subjected to it. However, I have the problem that also things before the condition do not get executed except for the first one. Bug or my mistake?
Your understanding is correct. The script will execute until a condition returns false. What does your script code look like?
'1542482716836':
alias: Guten Morgen
sequence:
- data:
entity_id: media_player.wohnzimmer
volume_level: '0.2'
service: media_player.volume_set
- data:
entity_id: media_player.wohnzimmer
source: Whispering Solo Piano
service: media_player.select_source
- data:
entity_id: switch.bilderrahmen
service: switch.turn_on
- before: sunrise
condition: sun
- data:
brightness: '137'
color_temp: '441'
entity_id: light.galerie
service: light.turn_on
- data:
brightness: '126'
entity_id: light.fibaro_system_fgd212_dimmer_2_level_2
service: light.turn_on
probably best to first rewrite like this:
'1542482716836':
alias: Guten Morgen
sequence:
- service: media_player.volume_set
data:
entity_id: media_player.wohnzimmer
volume_level: 0.2
- service: media_player.select_source
data:
entity_id: media_player.wohnzimmer
source: Whispering Solo Piano
- service: switch.turn_on
entity_id: switch.bilderrahmen
- condition: sun
before: sunrise
- service: light.turn_on
data:
brightness: 137
color_temp: 441
entity_id: light.galerie
- service: light.turn_on
data:
brightness: 126
entity_id: light.fibaro_system_fgd212_dimmer_2_level_2
I find it easiest to start the service with the actual service, then the entity_id, followed by extra data. Except t for the lights I’ve reordered like that, and taken out the quotes, which aren’t necessary, at least not according to the docs, and my own scripts and added the correct spacing.
Thanks @Mariusthvdb. The script is actually auto generated by the Hass.io script generator that’s why I was wondering if there may be a bug in Hass.io. Will give it a try when I am back.
check. the auto generators aren’t known for their humanly understandable syntaxes…
just an extra suggestion: write your lights in a scene, and call that scene in the script.
you might have other scripts for different parts of the day, and creating scripts with the same setup/construction makes things easier to adjust and maintain, debug even.
doing that with lighting scenes per script/setting is very easy and expandable, and makes sure your scripts don’t need all lighting details, and therefor are less error-prone.
in this case make a lighting scene.guten_morgen, call it in the script and you’re done.
scene:
- name: Guten Morgen
entities:
light.galerie:
state: on
transition: 4
brightness: 137
color_temp: 441
# hs_color: [14,83]
light.fibaro_system_fgd212_dimmer_2_level_2:
state: on
transition: 4
brightness: 26
# rgb_color: [255,94,42]
in the script add:
- service: scene.turn_on
entity_id: scene.guten_morgen