Script to call scene doesn't work

Hi all,

I’m trying to create a script to call a specific scene. I call the script from my floorplan. When i add the script and reboot hassio, i get and error that default.config could not setup dependancies.

'movie_scene_toggle': 
  sequence:
  - service: scene.turn_on
    data_template:
      entity_id: >
        {% if states.light.0xec1bbdfffea31ba3_light.attributes.brightness == 20 %}
          scene.livingroom_normal
        {% else %}
          scene.livingroom_dim
        {% endif %}

You should remove the quotes around movie_scene_toggle. What file is this script in?

Also, you don’t need to restart Home Assistant to reload a script, you can just reload it at Configuration > Server Controls > Reload Scripts. Along those lines, you should always run a config check before restarting Home Assistant.

What he said : - }}}}}

it should look something like :

script:
  sc_switch_bin_clock_timer:
    alias: Switch Bin Clock Timer Script
    sequence:
    - service: switch.turn_on
      entity_id: switch.switch_fibaro_bin_clock
    - delay: "00:00:{{ (((states('input_number.in_switch_bin_clock_run') | float) *60) -4) | int }}"
    - service: switch.turn_off
      entity_id: switch.switch_fibaro_bin_clock

The scene call looks ok but I don’t use scenes so may be wrong.
Also if this was generated by the Automation Editor, we may both be wrong :roll_eyes:

Indeed. Also, just to clarify a couple things:

  • script: should not be included above the script if the script is in a separate file with a script: !include scripts.yaml statement (or similar) in configuration.yaml
  • alias is optional

The scene service call is ok too.

1 Like

Though I use packages, so it is :smiley: (just to make things more confusing, sorry ! )

Edit: I was merely attempting (and failing, despite Tediore’s kind words) to show that in yaml hierarchy, it comes under the script: heading.
Make sure you only have ONE script: heading, UNLESS you have packages !
(that’s about as clear as I can make it, I think ! :roll_eyes: )

1 Like

Ah yes, that makes sense then. You didn’t make anything confusing, I just wanted to clarify to eliminate any potential confusion for OP :slightly_smiling_face:

Thanks for the support @Tediore and @Mutt . Found the reload scripts option /noob :wink:

The quotes are not the problem, my previous created scripts also have quotes, and do work. The error should be somewhere else in the script, but can’t figure it out.

My scripts.yaml:

'woonkamer_lights_off':
  alias: woonkamer_lights_off
  sequence:
  - data: {}
    entity_id: light.0xec1bbdfffea31ba3_light
    service: light.turn_off
  - entity_id: light.eethoek
    service: light.turn_off

'woonkamer_lights_on':
  alias: woonkamer_lights_on
  sequence:
  - data:
      brightness: '130'
    entity_id: light.0xec1bbdfffea31ba3_light
    service: light.turn_on
  - data:
      brightness: '130'
    entity_id: light.eethoek
    service: light.turn_on

'overloop_light_dim':
  alias: overloop_light_dim
  sequence:
  - data:
      brightness: '5'
    entity_id: light.0xccccccfffed80012_light
    service: light.turn_on

'keuken_timer':
  alias: keuken_timer
  sequence:
  - service: timer.start
    entity_id: timer.keuken

#'movie_scene_toggle': 
#  sequence:
#  - service: scene.turn_on
#    data_template:
#      entity_id: >
#        {% if states.light.0xec1bbdfffea31ba3_light.attributes.brightness == 20 %}
#          scene.livingroom_normal
#        {% else %}
#          scene.livingroom_dim
#        {% endif %}

Sorry for the confusion, I should have said you don’t need the quotes around each slug. Put this in the template tool at Developer Tools > Templates and see what it returns:

        {% if states.light.0xec1bbdfffea31ba3_light.attributes.brightness == 20 %}
          scene.livingroom_normal
        {% else %}
          scene.livingroom_dim
        {% endif %}

Also uncomment the script and run a config check as I mentioned earlier.