Scene on if weekdays and not holiday

Hello. is this syntax ok?

alias: Turn on light at 05:15 on weekdays (excluding holidays)
description: Turns on the specified light every weekday at 5:15 AM unless it is a holiday
triggers:

  • at: “05:15:00”
    trigger: time
    conditions:
  • condition: time
    weekday:
    • mon
    • tue
    • wed
    • thu
    • fri
  • condition: state
    entity_id: calendar.helgdagar_i_sverige
    state: “off”
    attribute: all_day
    actions:
  • target:
    entity_id: scene.godmorgon
    action: scene.turn_on
    data: {}
    mode: single

Other than your formatting, it looks correct to me!

alias: Turn on light at 05:15 on weekdays (excluding holidays)
description: Turns on the specified light every weekday at 5:15 AM unless it is a holiday
trigger:
  - platform: time
    at: "05:15:00"
condition:
  - condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  - condition: state
    entity_id: calendar.helgdagar_i_sverige
    state: "off"
    attribute: all_day
action:
  - service: scene.turn_on
    target:
      entity_id: scene.godmorgon
mode: single

Thanks for your reply. I am unsure if the “state: “off”
attribute: all_day” is the condition i want. I would like the binary to go to “on” if its a holiday. I am new to HA and learning every day.

But you start your code saying you want the light turned ON at 5:15am every day except holidays.

This part code of the code is saying, 'except when your calendar shows it’s a holiday, then the light remains OFF, all day:

entity_id: calendar.helgdagar_i_sverige
state: “off”
attribute: all_day

Also, a side note, when does the light get turned off every day? Is it manually being turned off every day? Or else, once it turns on, it will remain on all the time unless it’s a holiday.

Ok, then i change to “on” then. It is the lights in our bedroom and if it is holiday we dont want the lights to go on when we probaly are sleeping.

Yes I manually turn off lights when im leaving home workdays. I am going to add my Iphone tracing later for that purpose.

I use door sensors on the bedroom doors to turn on the lights in the house in the morning. That way the lights turn on right when you need them, regardless of when you wake up.

Thats one way to do it. I am going to get lightbulbs instead of switches so that the lights slowly dimming up to full.

By the way. Is it possible to test the automation the whole way? I dont know how i can simulate a holiday.

How did you set up your calendar?

And the code I provided is correct. If you don’t wan the lights to turn on when it’s a holiday, the code I gave you is the correct way to do that.

By changing “off” to “on”, it means on a holiday, it would turn them ON… which would be redundant since you have them turn on every day of the week anyway.

Yea i misunderstood you, sorry. Then it is ok with “off”

Regarding how to test your automation. Create a calendar and label today as a holiday. Then use this newly created calendar for your calendar sensor.

Ok, well i use Google calendar with all the swedish holidays.

Just add this calendar (Montenegro) as today is a public holiday there:

en.me.official#[email protected]

go to calendar.google.com and then click on the ‘+’ next to other Calendars in the bottom left of the page. Then click on Subscribe and paste the address above into the box.

When you’re done testing, simply unsubscribe to that new calendar.

I have done this. The calendar dont show up in HA. Can i refresh it?

Reload Google Calendar by going to Settings, Integrations, Click on the > next to google calendar… then “reload”

You should see the new calendar now as a device and the entity ID:

1 Like

I found how to refresh the inegratration, but the automation dont work.

I get this when i test the condition.

I should not use “Yes/No” instead on/off according to attributes?

Oh, right… yeah, you need to edit the automation to say YES instead of ON

In capitals or as the attribut says?

In Developer Tools under states it says to use “on” in lower case.

I still get “condition not pass” when testing automation. hmmm strange.