Automation using HA calendar if no event as criteria

I am using the local HA calendar integration to trigger multiple automations but I am trying to include this criteria along with other criteria to run an automation if no event is currently scheduled. I don’t want to use the end of the event as there may be an event that follows. I looked at the schedule but this will not work as the HA calendar is dynamic and getting updated frequently throughout the day as appointments are scheduled.

Am I missing a simple solution?

trigger on the end of events then immeidately call calendar.get_events with the current time to see if there’s anything scheduled.

Makes sense. I am new to HA, and not sure exactly how to I do that in the automation visual editor? Still learning the YAML, here is my current config without the get_event:

alias: Bay 1 - Lights On
description: Turn on lights upon entry - no sim
trigger:
  - platform: calendar
    event: end
    offset: "0:0:0"
    entity_id: calendar.bay_1_schedule
  - type: occupied
    platform: device
    device_id: 6b8430f55d942e45f18b80fe
    entity_id: 79e3e526af6d7e5b5e0ab2dd
    domain: binary_sensor
condition: []
action:

avoid device id’s:

this has an example on how to use get_events… you can do it via the ui. you don’t need to write yaml to call the get_event.

then to see how many events are returned you’d have someting like
`{{ agenda[‘name_of_your_calendar’.events | count() }}

but build your automation as far as you can then post it here and we’ll help.

Thanks for the info, I will work on converting to Entity IDs and repost.

whoops. i’m sorry i forgot to add the link to the page thath as the calendar.get_events sample:

I am finally heading down the path to switch over to entity_id (name) and remove the device_id from the automatioin such as below:

entity_id changed:

type: turn_on
device_id: 655d805cd95878802e46ae309da8779a
entity_id: switch.lobby_main_lights
domain: switch

however, when I attempt to delete the device_id I get a error:
Message malformed: extra keys not allowed @ data[‘actions’][1][‘parallel’][3][‘type’]

What am I doing wrong here?

You still aren’t using a non-device action…

type: switch.turn_on
target:
  entity_id: switch.lobby_main_lights

From the error message, you may have also inadvertently deleted the leading hyphen - for the action… but we can’t tell if that’s the case (or if it’s necessary) by what you have posted.

Ah, thank you. I have only been using the UI to this point so thank you for assisting in my HA continuing education.

All the non-device actions are available in the UI, you are not required to use YAML configuration to use them. The action shown in my previous post, switch.turn_on, can be found under “Switch” in the Action selector:

image

That explains quite a bit. I was using “Device” for everything when I started. Now I see the difference. Thank you.