Blinking Holiday Lights? Best Approach

I’m brand new to HA after spending my time in the smart home world in SmartThings and doing the best I could with it.

Now we’re migrating over and getting there piece by piece. So far, so good.

One question: I own four Novostella RGB landscape lights that are working just fine in HA, with an automation to turn each of them on and off around sunrise and sunset. Now I’d like to go a step up and tie specific (perhaps scenes?) to calendar periods. For example, around Halloween I’d like all the lights to go mainly orange, but then during the Christmas period (say all December) have the lights switch between green and red and potentially do it in some staggered fashion so that when lights 1 and 3 are red, lights 2 and 4 are green… switch and repeat.

What might be the best way to go about this?

Thanks.

1 Like

Guess this one is a bit off the beaten path?

I used node red, with big timer to get my outside lights to change colours on certain dates :+1:

As a noobie I was trying to avoid Node Red for now, but if it’s the best way to do this then that will have to happen sooner than later. Thanks!

I actually found it very straight forward using node red - happy to export my flow if it helps

This should help you get started.

Create a Trigger-based Template Sensor, called sensor.festive_season, that reports either halloween or christmas during whatever stretch of days you choose for these holiday events. In this example, Halloween is two days (30/31) and Christmas season is December 1 to January 10. This Template Sensor is updated at the start of every day or whenever Home Assistant is restarted or when you execute Reload Template Entities.

template:
  - trigger:
    - platform: time
      at: '00:00:00'
    - platform: event
      event_type: event_template_reloaded
    - platform: homeassistant
      event: start
    sensor:
    - name: 'Festive Season'
      state: >
        {% set m = now().month %}
        {% set md = (m, now().day) %}
        {{ 'halloween' if (md == (10,30) or md == (10,31)) else 'christmas' if (m == 12 or (1,1) <= md <= (1,10)) else 'none' }}
      icon: "{{ 'mdi:party-popper' if states('sensor.festive_season') != 'none' else 'mdi:sleep' }}"

Create an automation with a State Trigger that monitors sensor.festive_season and triggers whenever the sensor’s value changes to either halloween or christmas. Depending on which holiday it changed to, you can do different things (turn on various lights, switches, etc).

I’m unfamiliar with the lighting you described so I simply made an assumption that there are 4 lights and you can control each one individually. Change it to whatever it is you are using.

alias: festive lighting
trigger:
- platform: state
  entity_id: sensor.festive_season
  to:
  - 'halloween'
  - 'christmas'
action:
- choose:
  - conditions: "{{ trigger.to_state.state == 'halloween' }}"
    sequence:
    - service: light.turn_on
      target:
        entity_id:
        - light.novostella1
        - light.novostella2
        - light.novostella3
        - light.novostella4
      data:
        color_name: 'orange'
  - conditions: "{{ trigger.to_state.state == 'christmas' }}"
    sequence:
    - service: light.turn_on
      target:
        entity_id:
        - light.novostella1
        - light.novostella3
      data:
        color_name: 'red'
    - service: light.turn_on
      target:
        entity_id:
        - light.novostella2
        - light.novostella4
      data:
        color_name: 'green'
  default: []
mode: single
1 Like

Did you try what I had suggested? Now that it’s December, it should be controlling your holidays lighting. Let me know how it’s working out for you.

I’m having issues with this code giving me an error:

template:
  - trigger:
    - platform: time_pattern
      minutes: '/15'
    sensor:
    - name: 'Holidays'
      state: >
        {% set m = now().month %}
        {% set md = (m, now().day) %}
        {{ 'halloween' if (m == 10 >= md >= (10,26)) else 'christmas' if (m == 12 or (1,1) <= md <= (1,7)) else 'July4th' if (md = (7,4)) else 'stpaddys' if (md = (3,17)) else 'test' if (md = (3,25)) else 'none' }}
      icon: "{{ 'mdi:party-popper' if states('sensor.Holidays') != 'none' else 'mdi:sleep' }}"
Invalid config
The following integrations and platforms could not be set up:
template Show logs
Please check your config and logs.
Invalid config for [template]: invalid template (TemplateSyntaxError: expected token ')', got '=') for dictionary value @ data['sensor'][0]['state']. Got "{% set m = now().month %} {% set md = (m, now().day) %} {{ 'halloween' if (m == 10 >= md >= (10,26)) else 'christmas' if (m == 12 or (1,1) <= md <= (1,7)) else 'July4th' if (md = (7,4)) else 'stpaddys' if (md = (3,17)) else 'test' if (md = (3,25)) else 'none' }}\n". (See /config/configuration.yaml, line 24). 

This is invalid:

m == 10 >= md >= (10,26)

What date range are you trying to establish there? Halloween is a single day but it seems like you’re trying to define a range of days albeit using an incorrect comparison.

Ok,

My ideal ranges are:
Halloween: 10-26 - 10-31
Christmas: December 1 - January 7

I tried simplifying it but still get the error.

template:
  - trigger:
    - platform: time_pattern
      minutes: '/15'
    sensor:
    - name: 'Holidays'
      state: >
        {% set m = now().month %}
        {% set md = (m, now().day) %}
        {{ 'halloween' if (md = (10,31)) else 'christmas' if (m == 12 or (1,1) <= md <= (1,7)) else 'July4th' if (md = (7,4)) else 'stpaddys' if (md = (3,17)) else 'test' if (md = (3,25)) else 'none' }}
      icon: "{{ 'mdi:party-popper' if states('sensor.Holidays') != 'none' else 'mdi:sleep' }}"

Try this version (it’s a bit easier to read).

template:
  - trigger:
      - platform: time_pattern
        minutes: '/15'
    sensor:
      - name: 'Holidays'
        state: >
          {% set m = now().month %}
          {% set md = (m, now().day) %}
          {% if md == (10,31) %} halloween
          {% elif (m == 12) or ((1,1) <= md <= (1,7)) %} christmas
          {% elif md == (7,4) %} July4th
          {% elif md == (3,17) %} stpaddys
          {% elif md == (3,25) %} test
          {% else %} none
          {% endif %}
        icon: "{{ 'mdi:party-popper' if states('sensor.holidays') != 'none' else 'mdi:sleep' }}"
1 Like

So far so good, thank you!

Welp. I thought it was working. Stuck on sensor “pride”

template:
  - trigger:
      - platform: time_pattern
        minutes: "/15"
    sensor:
      - name: "Holidays"
        state: >
          {% set m = now().month %}
          {% set md = (m, now().day) %}
          {% if md >= (10,26) and md <= (10,31) %} halloween
          {% elif (m == 12) or ((1,1) <= md <= (1,7)) %} christmas
          {% elif md == (7,4) %} July4th
          {% elif md == (3,17) %} stpaddys
          {% elif md == (6,19) %} juneteenth
          {% elif md == (11,11) %} veterans
          {% elif md == (6,1) or (6,28) %} pride
          {% elif md == (10,9) %} Indigenous
          {% elif md == (11,7) %} Election
          {% elif md == (3,31) %} trans
          {% elif md == (5,29) %} memorial
          {% elif md == (9,4) %} labor
          {% elif md == (11,23) %} thanksgiving
          {% elif md == (6,18) %} father
          {% elif md == (5,14) %} mother
          {% elif md == (1,16) %} mlkj
          {% elif md == (2,14) %} valentines
          {% elif md == (5,5) %} cinco
          {% elif md == (4,22) %} earth
          {% elif md == (9,11) %} sept11
          {% elif md == (4,2) %} palm
          {% elif md == (1,6) %} epiphany
          {% elif md == (2,1) %} black_history
          {% elif md == (5,6) %} nurse
          {% elif md == (4,6) or (4,7) %} maundy
          {% elif md == (4,8) or (4,9) %} Easter
          {% elif md == (3,28) %} test
          {% else %} none
          {% endif %}
        icon: "{{ 'mdi:party-popper' if states('sensor.holidays') != 'none' else 'mdi:sleep' }}"

Tell me what you tried in order to fix it. What didn’t work?

BTW, I assume you have a 15-minute Time Pattern Trigger purely for testing purposes because the production version only needs to trigger at the beginning of each new day.

It was working before I added the lengthy list of dates. I have no idea why it triggered to ‘pride’ in the first place as those dates aren’t until June.

I am doing every 15 minutes because I only want it to turn on once the lights come on automatically at sunset (-60). Is there a better idea?

As explained above; trigger at midnight.

Forgive me if I missed something, but won’t that cause the lights to turn on at Midnight?

I’d be interested in seeing your flow if you have it available.

Not unless you have designed your automation to use this Trigger-based Template Sensor in that way.

It’s a Trigger-based Template Sensor designed to report if the current day is a holiday. It only needs to check if the current day is a holiday at the start of each new day (midnight). It doesn’t need to repeatedly check every 15 minutes if today is a holiday.


EDIT

This line is invalid:

          {% elif md == (6,1) or (6,28) %} pride

Change it to this:

          {% elif md == (6,1) or md == (6,28) %} pride

or this:

          {% elif md in [(6,1), (6,28)] %} pride

Fix the same mistake for maundy and Easter.

1 Like

I was just curious where you got your holiday light patterns? I’ve been looking for the same thing and was wondering if you could share.

1 Like