Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias: "Evening Routine: Lock Doors and Turn Off Lights"
- description: >-
- This automation locks only unlocked doors at 10:00 PM, turns off lights and
- switches that are on at 11:00 PM, and turns off specific lights at 12:00 AM if
- they are on. It also sends notifications when doors are locked.
- trigger:
- - platform: time
- at: "22:00:00"
- id: lock_doors
- - platform: time
- at: "23:00:00"
- id: lights_off
- - platform: time
- at: "00:00:00"
- id: midnight_lights_off
- condition: []
- action:
- - choose:
- - conditions:
- - condition: trigger
- id: lock_doors
- sequence:
- - variables:
- unlocked_doors: >-
- {{ expand([
- "lock.bedroom_closet_door_lock",
- "lock.front_door_lock",
- "lock.laundry_room_door_lock",
- "lock.rear_door_lock",
- "lock.sunroom_door_lock"
- ]) | selectattr('state', 'eq', 'unlocked') |
- map(attribute='entity_id') | list }}
- door_names: >-
- {{ unlocked_doors | map('device_id') | map('device_attr',
- 'name') | list | join(', ') }}
- - condition: template
- value_template: "{{ unlocked_doors | length > 0 }}"
- - service: lock.lock
- target:
- entity_id: "{{ unlocked_doors }}"
- - service: notify.mobile_app_pixel_9
- data:
- title: Door Lock Notification
- message: >-
- {% if unlocked_doors | length > 0 %}
- Locked doors: {{ door_names }}
- {% else %}
- All doors were already locked.
- {% endif %}
- - service: media_player.play_media
- enabled: false
- target:
- entity_id: media_player.ha_group
- data:
- media_content_id: >-
- media-source://tts/cloud?message=All+unlocked+doors+have+been+locked&language=en-US&voice=JennyNeural
- media_content_type: provider
- metadata:
- title: All unlocked doors have been locked
- thumbnail: https://brands.home-assistant.io/_/cloud/logo.png
- media_class: app
- navigateIds:
- - {}
- - media_content_type: app
- media_content_id: media-source://tts
- - media_content_type: provider
- media_content_id: >-
- media-source://tts/cloud?message=All+unlocked+doors+have+been+locked&language=en-US&voice=JennyNeural
- - conditions:
- - condition: trigger
- id: lights_off
- sequence:
- - variables:
- all_entities: >-
- {{ expand([
- "switch.hall_light",
- "switch.office_light",
- "switch.attic_hallway_light",
- "switch.hall_bath_exhaust_fan",
- "switch.foyer_light",
- "switch.sunroom_ceiling_light",
- "switch.sunroom_ceiling_fan",
- "switch.dining_room_light",
- "switch.kitchen_light",
- "switch.kitchen_sink_light",
- "switch.kitchen_pantry_light",
- "switch.laundry_room_light",
- "switch.garage_lights",
- "switch.bedroom_2_ceiling_fan",
- "switch.bedroom_2_lights",
- "switch.attic_garage_light",
- "switch.bathroom_mirror",
- "switch.hall_bath_light",
- "switch.landscape_lighting",
- "switch.office_ceiling_light",
- "switch.bills_desk",
- "switch.office_lamps",
- "light.hue_ambiance_lamp_1",
- "light.floor_lamps_group",
- "light.living_room",
- "light.office_lamp_1",
- "light.office_lamp_2",
- "light.bedroom_fado_lamp",
- "light.foyer_lamp",
- "light.bedroom_bedside_lamps_group",
- "light.bedroom_reading_lamp",
- "light.bedroom_dresser_lamp",
- "light.sunroom_lamp",
- "light.sofa_backlight",
- "light.govee_h612f",
- "light.office_lamps"
- ]) | selectattr('state', 'eq', 'on') |
- map(attribute='entity_id') | list }}
- - condition: template
- value_template: "{{ all_entities | length > 0 }}"
- - service: homeassistant.turn_off
- target:
- entity_id: "{{ all_entities }}"
- - delay:
- seconds: 5
- - service: scene.turn_on
- target:
- entity_id: scene.outside_lights_off
- - conditions:
- - condition: trigger
- id: midnight_lights_off
- sequence:
- - variables:
- midnight_lights: >-
- {{ expand([
- "light.light_bars_1",
- "light.bed_lights",
- "light.bedroom_dresser_under_light"
- ]) | selectattr('state', 'eq', 'on') |
- map(attribute='entity_id') | list }}
- - condition: template
- value_template: "{{ midnight_lights | length > 0 }}"
- - service: homeassistant.turn_off
- target:
- entity_id: "{{ midnight_lights }}"
- mode: single
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement