Scene Templating

I have recently looked into getting lights for the front of my home to be more festive throughout the year. But I am running into some difficulty. I am not sure if this would be me doing something wrong, or if this should become a sort of feature request.

I have several scenes set up for different US holidays (i.e july 4th, thanksgiving, halloween, etc) calling on them individually works fine but when trying to automate the date to the scene it becomes more difficult. What I have a script that reset light conditions based off of outside movement around my house (to allow me to better see where I am going when walking around my house at night). But upon no movement detected I call a script to put my house back to scene colors. This is why I am using a script to call scenes. My script…

script.yaml
'front_lights':
  alias: Front Lights
  sequence:
  - service: scene.turn_on
    entity_id: >
      {% if (now().month==2 and now().day<=14)%} scene.frontlights_valentines
      {% elif (now().month==10)%} scene.frontlights_halloween
      {% elif (now().month==11)%} scene.frontlights_thanksgiving
      {% elif (now().month==12 and now().day<=25)%} scene.frontlights_christmas
      {% else%}scene.frontlights_normal
      {% endif%}

As Valentine’s Day is tomorrow I get from the template developer:

'front_lights':
  alias: Front Lights
  sequence:
  - service: scene.turn_on
    entity_id: >
        scene.frontlights_valentines

I can reformat it to get entity_id: scene.frontlights_valentines to present too, but that hasn’t worked either.

Any assistance would be appreciated.

it looks correct, is there an error in the logs?

nevermind, its wrong. Add this:

 'front_lights':
  alias: Front Lights
  sequence:
  - service: scene.turn_on
    data_template:
      entity_id: >
        {% if (now().month==2 and now().day<=14)%} scene.frontlights_valentines
        {% elif (now().month==10)%} scene.frontlights_halloween
        {% elif (now().month==11)%} scene.frontlights_thanksgiving
        {% elif (now().month==12 and now().day<=25)%} scene.frontlights_christmas
        {% else%}scene.frontlights_normal
        {% endif%}

or

'front_lights':
  alias: Front Lights
  sequence:
  - service: scene.turn_on
    data:
      entity_id: >
          scene.frontlights_valentines

Thank you, I will give that a try when I get home.

I use @geekoftheweek concept. https://github.com/geekofweek/homeassistant/blob/master/automation/holiday.yaml

1 Like

Thanks @petro, it works.

@Tyler_Terzigni, that’s impressive! I will save that one for when I get more into this.

1 Like

Love hearing that people find my configs useful :exploding_head:

1 Like