Skip to content

Instantly share code, notes, and snippets.

@jasontucker
Last active October 31, 2024 17:13
Show Gist options
  • Save jasontucker/fa9721e73e0ec832a9e17163536f99b7 to your computer and use it in GitHub Desktop.
Save jasontucker/fa9721e73e0ec832a9e17163536f99b7 to your computer and use it in GitHub Desktop.
# automations.yaml
# Update Unifi Doorbell with Day-Specific Message in Home Asssistant
# pulling data from build in calendar and "home calendar" that has custom events listed in it.
# This only works if you have alreadys set these messages in the doorbell as a custom message.
alias: "Update Doorbell with Day-Specific Message"
trigger:
- platform: time
at: "00:00:00" # Run daily at midnight
action:
- choose:
- conditions:
- condition: or
conditions:
- condition: state
entity_id: calendar.holidays # First holiday calendar entity
state: "on"
- condition: state
entity_id: calendar.home_calendar # Second calendar entity
state: "on"
sequence:
- service: text.set_value
target:
entity_id: text.capulet_doorbell_doorbell
data:
value: >
{% set event1 = state_attr('calendar.holidays', 'message') %}
{% set event2 = state_attr('calendar.home_calendar', 'message') %}
{% if event1 %}
Happy {{ event1 }}!
{% elif event2 %}
Happy {{ event2 }}!
{% else %}
WELCOME!
{% endif %}
- conditions:
- condition: state
entity_id: sensor.day_of_week
state: "Monday"
sequence:
- service: text.set_value
target:
entity_id: text.capulet_doorbell_doorbell
data:
value: "It's Monday! Welcome!"
- conditions:
- condition: state
entity_id: sensor.day_of_week
state: "Tuesday"
sequence:
- service: text.set_value
target:
entity_id: text.capulet_doorbell_doorbell
data:
value: "Happy Tuesday!"
- conditions:
- condition: state
entity_id: sensor.day_of_week
state: "Wednesday"
sequence:
- service: text.set_value
target:
entity_id: text.capulet_doorbell_doorbell
data:
value: "Wednesday Vibes!"
- conditions:
- condition: state
entity_id: sensor.day_of_week
state: "Thursday"
sequence:
- service: text.set_value
target:
entity_id: text.capulet_doorbell_doorbell
data:
value: "Almost Friday!"
- conditions:
- condition: state
entity_id: sensor.day_of_week
state: "Friday"
sequence:
- service: text.set_value
target:
entity_id: text.capulet_doorbell_doorbell
data:
value: "TGIF!"
- conditions:
- condition: state
entity_id: sensor.day_of_week
state: "Saturday"
sequence:
- service: text.set_value
target:
entity_id: text.capulet_doorbell_doorbell
data:
value: "Enjoy your Saturday!"
- conditions:
- condition: state
entity_id: sensor.day_of_week
state: "Sunday"
sequence:
- service: text.set_value
target:
entity_id: text.capulet_doorbell_doorbell
data:
value: "Relax, it's Sunday!"
default:
- service: text.set_value
target:
entity_id: text.capulet_doorbell_doorbell
data:
value: "WELCOME!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment