Holiday Automation & Hue Scenes

Hi!
I’m trying to conceptualize an approach to do the following:

Maintain a calendar of dates with lighting information (in my case, a Philips Hue Scene name to call)
Have a series of automations that reference this calendar and call the scene or turn off the scene.

My approach so far is to use a Google Calendar, add holidays I want set lighting for, and then write a set of automations to call the scene at sunset.

I’m not sure yet what kind of template I’ll need, but I suspect it’s an if/then to weed out days with no info, followed by calling a service and inserting the calendar body which references the scene.

Any better approaches out there?

I do this with an if statement for the holidays and scenes I added in HA (imported Hue scenes were a pain because you can’t edit them). Hope this helps.


alias: Outdoor - Lights at Sunset with Holidays
description: >-
  Outdoor lights on at sunset, holiday scenes activate automatically with
  calendar. 
trigger:
  - platform: sun
    event: sunset
    offset: "-00:15:00"
condition: []
action:
  - service: scene.turn_on
    target:
      entity_id: >
        {% if now().month == 10 and now().day >= 1 and now().day <= 31 %}
        scene.outdoor_lights_halloween   {% elif now().month == 12 and now().day
        >= 1 and now().day <= 30 %} scene.outdoor_lights_christmas  {% elif
        now().month == 12 and now().day == 31 %} scene.new_years  {% elif
        now().month == 7 and now().day == 4 %} scene.outdoor_lights_usa  {% else
        %} scene.outdoor_lights_normal   {% endif %}
mode: single

This is helpful.

I was thinking similar except checking a calendar and name matching those. Somewhat fragile but should work.

I’m using Hue Scenes because the editing editing experience in Hue App is way more usable for other folks in the household. :slight_smile:

Suggestion

Instead of using a chain of if-elif statements, consider using a dictionary to store the holiday dates. It works as long as there are no overlapping dates.

alias: Outdoor - Lights at Sunset with Holidays
description: >-
  Outdoor lights on at sunset, holiday scenes activate automatically with
  calendar. 
trigger:
  - platform: sun
    event: sunset
    offset: "-00:15:00"
condition: []
action:
  - service: scene.turn_on
    target:
      entity_id: >
        {% set (m, d) = (now().month, now().day) %}
        {% set holidays = {
          m == 10: 'outdoor_lights_halloween',
          m == 12 and d <= 30: 'outdoor_lights_christmas',
          (m, d) == (12, 31): 'new_years',
          (m, d) == (7, 31): 'outdoor_lights_usa' } %}
        scene.{{ holidays.get(true, 'outdoor_lights_normal') }}
mode: single
1 Like

Thanks, Taras. I think I saw this suggestion (by you?) in another thread I was researching.

I’m hoping to use a Google Calendar to make it easier to edit in the future, but this is definitely my fall back approach.

FWIW, I haven’t worked with Calendar entities in the past, so a ton of learning here!

Good strategy. Other option, to use Local Calendar, is just a minor variation of the same theme.

The fully templated approach, suggested by OvalZyre, is also a good strategy provided there’s no need to display/manage the holidays in the UI.

There’s also the new Holiday integration, introduced in 2024.1.0, but I have no experience with it.

In my case, I use a python script that reads a YAML configuration of dates and reports them in a sensor’s attributes containing details like remaining days until the event and computed phrases like “Jane and John’s 13th wedding anniversary” or “Reminder, in 3 days, Bob’s 42nd birthday”.

However I have been considering the idea of converting it all to a Local Calendar and storing each holiday/birthday/anniversary event’s metadata in JSON format within the calendar event’s description field. Real Soon Now™ :slightly_smiling_face:

HOW DID I NOT LOOK AT LOCAL CALENDARS.

This is even better. Thank you Taras! :raised_hands:

I’m going to use three automations: One, is an automation that fires at the calendar event, which pastes the holiday name to a text attribute. Then, I have my standing “Lights on” automation that has logic to set lights to specific scenes if called for, else will use default scene. Then my end of lights automation turns off the lights and sets the text entity back to none.

Rube Goldberg machine

I almost said thanks for not being condescending like you were in other holiday lighting posts I saw, but I am glad I waited.

The additional complexity is worth it to me as it lets other family members enjoy the platform without editing templates. They can easily create a scene in Hue, add a calendar event with the scene name, and away it goes.

If it fails I’ve got logic to bail to normal lighting, and we’re all still happy.

Take care.

I don’t recall purposely being condescending but I admit I don’t know everyone’s threshold for condescension.

If you found that light-hearted comparison to be condescending, and several other posts I have made, then I suggest you avoid my posts altogether because I can’t guarantee my future posts won’t also be misinterpreted as condescending.

  • If you feel strongly about it, you can flag my post which will bring it to the attention of a moderator.

  • If my posts serve to upset you, you can go to the Preferences section of your forum account and Ignore my account. This will hide the display of my posts.

Seeing that this may be the last time we speak, I wish you all the best with your home automation projects. Good luck and goodbye.

Thanks for this - I’ll definitely give it a look as it’s something I’ve not had experience with thus far. The IF automation I use was something I implemented when I first starting using HA and just left it since it was working for what I needed. This looks much easier to manage however, once I get my head around the syntax.

Hey, trying to follow along with your idea but having a problem executing it.

Would you mind providing your YAML for this?