- alias: MSR 2 Testing id: d0be7b52-30f2-4947-a8de-a20a15df8849 mode: parallel trigger: - platform: state entity_id: &id001 - binary_sensor.apollo_msr_2_8935e0_radar_zone_1_occupancy - binary_sensor.apollo_msr_2_8935e0_radar_zone_2_occupancy - binary_sensor.apollo_msr_2_8935e0_radar_zone_3_occupancy variables: entities: *id001 colors: 'on': - 0 - 255 - 0 'off': - 255 - 0 - 0 unknown: - 255 - 255 - 255 unavailable: - 0 - 0 - 255 color: '{{ colors.get(trigger.to_state.state, colors.unavailable) }} ' index: '{{ entities.index(trigger.to_state.entity_id) }} ' target: light.test_segment_{{ index + 1 }} action: - if: '{{ is_state(''light.test_main'', ''off'') }}' then: - service: light.turn_on target: entity_id: light.test_main data: brightness: 255 - service: light.turn_on target: entity_id: '{{ target }}' data: rgb_color: '{{ color }}' - alias: Notify Aurora id: 1d19d3a4-4ce1-433e-b27a-bc5fa8364153 triggers: - trigger: state entity_id: binary_sensor.aurora_visibility_visibility_alert from: 'off' to: 'on' conditions: - condition: numeric_state entity_id: sensor.aurora_visibility_visibility above: 0 actions: - service: script.notify data: title: Snapshot Status message: There's a {{ states('sensor.aurora_visibility_visibility') }}% chance that Aurora Borealis may be visible. - alias: Update Group Members id: plants_update group members trigger: - platform: time at: 00:00:00 - platform: homeassistant event: start - platform: event event_type: event_template_reloaded action: - service: group.set data: name: Plants object_id: plants icon: mdi:sprout entities: '{{ states.plant | map(attribute=''entity_id'') | list }}' - alias: Notify id: plants_notify trigger: - platform: state entity_id: binary_sensor.plant_issue to: 'on' from: 'off' variables: state: '{{ trigger.to_state.state }}' - platform: time at: '10:00' variables: &id002 state: '{{ states(''binary_sensor.plant_issue'') }}' - platform: time at: '15:30' variables: *id002 - platform: time at: '19:00' variables: *id002 variables: problems: '{{ state_attr(''sensor.plant_events'', ''events'') }} ' count: '{{ problems | length }} ' title: 'Plant{{ ''s'' if count > 1 else '''' }} Need{{ '''' if count > 1 else ''s'' }} Attention! ' message: "{%- set ns = namespace(items=[]) %} {%- for issue, plants in problems\ \ | groupby(attribute='problems') %}\n {%- set phrases = plants | map(attribute='name')\ \ | list %}\n {%- set phrase = phrases[:-1] | join(', ') ~ ' and ' ~ phrases[-1]\ \ if phrases | length > 1 else phrases | first | default %}\n {%- set plural\ \ = '' if phrases | length > 1 else 's' %}\n {%- set ns.items = ns.items +\ \ [ (phrase ~ ' need%s ' % plural ~ issue ~ '.') | capitalize ] %}\n{%- endfor\ \ %} {{ ns.items | join('\\n') }}\n" condition: - condition: template value_template: '{{ count > 0 }}' action: - service: script.notify data: title: '{{ title }}' message: '{{ message }}' - alias: Zigbee Button Toggler id: button_toggle_lights mode: parallel trigger: - platform: state entity_id: - event.workshop_button_action - event.mikes_button_action - event.jims_button_action - event.lindsays_button_action variables: continue: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' event: '{{ trigger.to_state.attributes.event_type | default('''') if continue else '''' }} ' source: '{{ trigger.entity_id }} ' config: event.workshop_button_action: single: - light.workshop_desk double: - light.workshop_desk - light.workshop_bench_strip hold: - light.workshop_desk - light.workshop_dome - switch.floating_double_plug_left - light.workshop_bench_strip event.mikes_button_action: single: - light.mikes_lamp double: - light.living_room hold: - switch.movie_time event.jims_button_action: single: - light.jims_lamp double: - light.all_living_room hold: - light.all_living_room event.lindsays_button_action: single: - light.lindsays_lamp double: - light.living_room hold: - light.all_living_room which: '{%- set item = config.get(source, {}) %} {{ item.get(event, []) }} ' targets: '{{ which | count > 0 }} ' are_on: '{{ which | select(''is_state'', ''on'') | list | count > 0 }} ' condition: - condition: template value_template: '{{ continue and targets }}' action: - service: homeassistant.turn_o{{ 'ff' if are_on else 'n' }} target: entity_id: '{{ which }}' - alias: Living Room Scene Controller id: button_living_room_scene_controller mode: parallel trigger: - platform: event event_type: zwave_js_value_notification variables: device: '{{ trigger.event.data.device_id }} ' value: '{{ trigger.event.data.value }} ' label: "{{ trigger.event.data.label }} \n" config: 215253fb0f54a57d98bc940fac442073: Scene 001: KeyPressed: service: light.toggle data: entity_id: light.downstairs_ambiance Scene 002: KeyPressed: service: light.toggle data: entity_id: light.living_room_uplight Scene 003: KeyPressed: service: light.toggle data: entity_id: light.dining_room_uplight_1 Scene 004: KeyPressed: service: light.toggle data: entity_id: light.dining_room_uplight_2 Scene 005: KeyPressed: service: light.toggle data: entity_id: light.living_room KeyPressed2x: service: light.toggle data: entity_id: light.all_living_room f7a1fe2db74bf6a3b652301589f7cebc: Scene 001: KeyPressed: service: light.toggle data: entity_id: light.mikes_lamp Scene 002: KeyPressed: service: light.toggle data: entity_id: light.lindsays_lamp Scene 003: KeyPressed: service: light.toggle data: entity_id: light.jims_lamp Scene 004: KeyPressed: service: switch.toggle data: entity_id: switch.hyperion_usb_capture KeyPressed2x: service: switch.toggle data: entity_id: switch.hyperion_cinema KeyPressed3x: service: switch.toggle data: entity_id: switch.hyperion_rainbow_swirl_fast Scene 005: KeyPressed: service: light.toggle data: entity_id: light.living_room KeyPressed2x: service: light.toggle data: entity_id: light.all_living_room service: '{{ config.get(device, {}).get(label, {}).get(value, {}).get(''service'') }} ' data: '{{ config.get(device, {}).get(label, {}).get(value, {}).get(''data'') }} ' condition: - condition: template value_template: '{{ service is not none and data is not none }}' action: - service: '{{ service }}' data: '{{ data }}' - alias: Living Room Scene Controller LEDs id: button_living_room_scene_controller_leds mode: queued trigger: - platform: state entity_id: - light.mikes_lamp - light.lindsays_lamp - light.jims_lamp - switch.hyperion_usb_capture - switch.hyperion_cinema - switch.hyperion_rainbow_swirl_fast - light.all_living_room - light.downstairs_ambiance - light.dining_room_uplight_1 - light.dining_room_uplight_2 - light.living_room_uplight variables: values: 'on': 2 'off': 3 unavailable: 3 unknown: 3 colors: white: 0 blue: 1 green: 2 red: 3 config: light.mikes_lamp: devices: f7a1fe2db74bf6a3b652301589f7cebc parameter: 2 light.lindsays_lamp: devices: f7a1fe2db74bf6a3b652301589f7cebc parameter: 3 light.jims_lamp: devices: f7a1fe2db74bf6a3b652301589f7cebc parameter: 4 switch.hyperion_usb_capture: devices: f7a1fe2db74bf6a3b652301589f7cebc parameter: 5 switch.hyperion_cinema: devices: f7a1fe2db74bf6a3b652301589f7cebc parameter: 5 switch.hyperion_rainbow_swirl_fast: devices: f7a1fe2db74bf6a3b652301589f7cebc parameter: 5 light.all_living_room: devices: - f7a1fe2db74bf6a3b652301589f7cebc - 215253fb0f54a57d98bc940fac442073 parameter: 1 light.downstairs_ambiance: devices: 215253fb0f54a57d98bc940fac442073 parameter: 2 light.dining_room_uplight_1: devices: 215253fb0f54a57d98bc940fac442073 parameter: 4 light.dining_room_uplight_2: devices: 215253fb0f54a57d98bc940fac442073 parameter: 5 light.living_room_uplight: devices: 215253fb0f54a57d98bc940fac442073 parameter: 3 value: '{{ values.get(trigger.to_state.state) }} ' state_parameter: '{{ config.get(trigger.entity_id, {}).get(''parameter'') }} ' devices: '{% set devices = config.get(trigger.entity_id, {}).get(''devices'') %} {{ devices if devices is list else [devices] }} ' color_parameter: '{{ state_parameter + 5 if state_parameter is not none else none }} ' state_good: '{{ trigger.to_state.state in [''on'', ''off''] }} ' state_bad: '{{ trigger.to_state.state in [''unavailable'', ''unknown''] }} ' state_off: '{{ trigger.to_state.state == ''off'' }} ' color: "{% if state_good and state_off %}\n {{ colors.get('white') }}\n{% elif\ \ state_bad %}\n {{ colors.get('red') }}\n{% else %}\n None\n{% endif %}\n" condition: - condition: template value_template: '{{ value is not none and state_parameter is not none }}' action: - repeat: for_each: '{{ devices }}' sequence: - service: zwave_js.bulk_set_partial_config_parameters target: &id003 device_id: '{{ repeat.item }}' data: parameter: '{{ state_parameter }}' value: '{{ value }}' - condition: template value_template: '{{ color is not none and (state_bad or state_off) }}' - repeat: for_each: '{{ devices }}' sequence: - service: zwave_js.bulk_set_partial_config_parameters target: *id003 data: parameter: '{{ color_parameter }}' value: '{{ color }}' - alias: Calibration Helper id: 467417d9-fe47-4fb8-a0fd-2764c92e099a mode: parallel trigger: - platform: state entity_id: - sensor.basement_bme280_temperature - sensor.basement_bme280_humidity variables: config: sensor.basement_bme280_temperature: notify: notify.basement_temperature sensor: sensor.apollo_air_1_1ecac0_sen55_temperature sensor.basement_bme280_humidity: notify: notify.basement_humidity sensor: sensor.apollo_air_1_1ecac0_sen55_humidity which: '{{ config.get(trigger.to_state.entity_id) }}' condition: - condition: template value_template: '{{ which is not none }}' action: - service: notify.send_message target: entity_id: '{{ which.notify }}' data: message: '{{ now().isoformat() }},{{ trigger.to_state.state }},{{ states(which.sensor) }}' - alias: Turn off Outside Cameras based on temperature id: turn_off_outside_cameras_based_on_temperature trigger: - platform: state entity_id: binary_sensor.camera_shutoff from: 'off' to: 'on' action: - service: script.notify data: message: '[{{ now().strftime(''%-I:%M:%S %p'') }}] Temperature is moving below 16°F, turning off the driveway and backyard camera. ' - service: switch.turn_off data: entity_id: - switch.driveway_camera_port - switch.patio_camera_port - alias: Turn on Outside Cameras based on temperature id: turn_on_outside_cameras_based_on_temperature trigger: - platform: state entity_id: binary_sensor.camera_turn_on from: 'off' to: 'on' action: - service: script.notify data: message: '[{{ now().strftime(''%-I:%M:%S %p'') }}] Temperature is moving above 20°F, turning on the driveway and backyard camera. ' - service: switch.turn_on data: entity_id: - switch.driveway_camera_port - switch.patio_camera_port - id: f6524e79-6b0c-4aa2-b508-3d67f83901a8 alias: Cube Actions mode: parallel trigger: - platform: state entity_id: event.mikes_cube_action from: null variables: continue: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' event: '{{ trigger.to_state.attributes.event_type | default(None) if continue else None }}' player: media_player.yamaha_rx_v6a volume: '{{ state_attr(player, ''volume_level'') }}' condition: - condition: template value_template: '{{ event is not none }}' action: - alias: Which action choose: - alias: Shake conditions: '{{ event == ''shake'' }}' sequence: - service: switch.toggle target: entity_id: switch.movie_time - alias: Rotate conditions: '{{ ''rotate'' in event }}' sequence: - if: '{{ volume is not none }}' then: - service: media_player.volume_set target: entity_id: '{{ player }}' data: volume_level: '{% set c = 0.05 if event == ''rotate_right'' else -0.05 %} {{ ([ 0, volume + c, 1] | sort)[1] | round(2) }} ' - alias: MQTT Discovery id: mqtt_store_door_states_discovery mode: single trigger: - platform: homeassistant event: start variables: doors: - name: Main Door identifiers: - a8541 unique_id: main_door_last_opened - name: Sliding Door identifiers: - 59e40 unique_id: sliding_door_last_opened - name: Garage Door identifiers: - 922c2 unique_id: front_garage_door_last_opened - name: Garage Entry Door identifiers: - 5ef46 unique_id: garage_entry_door_last_opened - name: Rear Garage Door identifiers: - 0fff6 unique_id: rear_garage_door_last_opened - name: Passenger Door identifiers: - 069aa unique_id: passenger_door_last_opened action: - repeat: for_each: '{{ doors }}' sequence: - service: script.mqtt_automated_config data: domain: sensor name: Last Opened unique_id: '{{ repeat.item.unique_id }}' device_class: timestamp device: name: '{{ repeat.item.name }}' identifiers: '{{ repeat.item.identifiers }}' manufacturer: Petro model: Virtual Door sw_version: '1.0' - alias: Notify when Open id: notify_on_door_state_change mode: parallel trigger: &id004 - platform: state entity_id: - binary_sensor.main_door - binary_sensor.garage_entry_door - binary_sensor.sliding_door - binary_sensor.front_garage_door - binary_sensor.rear_garage_door - binary_sensor.passenger_door from: 'off' to: 'on' variables: valid: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' source: "{%- if valid %}\n {{ trigger.to_state.entity_id }}\n{%- endif %}\n" timestamp: '{{ (datetime | default(now())).isoformat() }} ' object_id: '{{ source.split(''.'')[-1] }} ' unique_id: '{{ object_id }}_last_opened ' count_script: 'script.notify_count_{{ object_id }} ' sensor: 'sensor.{{ unique_id }} ' last_opened: '{{ states(sensor) | default('''') }} ' quiet_window: "{%- set times = {\n 'binary_sensor.main_door': 120,\n 'binary_sensor.garage_entry_door':\ \ 120,\n 'binary_sensor.sliding_door': 120,\n 'input_boolean.test_door': 10,\n\ } %} {%- if valid and source in times %}\n {{ times[source] }}\n{%- else %}\n\ \ 0\n{%- endif %}\n" delta: "{%- set last = last_opened | as_datetime %} {%- set current = timestamp\ \ | as_datetime %} {%- if last and current %}\n {{ (current - last).seconds\ \ }}\n{%- else %}\n {{ quiet_window + 1 }}\n{%- endif %}\n" in_quiet_window: '{{ delta < quiet_window }} ' count: "{%- if in_quiet_window %}\n {%- set current = state_attr(sensor, 'count')\ \ %}\n {%- if current is none %}\n 1\n {%- else %}\n {{ current + 1\ \ }}\n {%- endif %}\n{%- else %}\n 0\n{%- endif %}\n" count_timestamp: "{%- if count == 0 %}\n {{ timestamp }}\n{%- else %}\n {{ state_attr(sensor,\ \ 'count_timestamp') }}\n{%- endif %}\n" who: '{{ state_attr(''sensor.people_at_home'', ''or'') }} ' what: '{{ state_attr(trigger.entity_id, ''friendly_name'') }} ' condition: &id005 - condition: template value_template: '{{ valid }}' action: - service: script.mqtt_automated_states data: domain: sensor unique_id: '{{ unique_id }}' state: '{{ timestamp }}' attributes: '{{ { ''who'': who, ''count'': count, ''source'': source, ''count_timestamp'': count_timestamp } | tojson }}' - choose: - conditions: - condition: template value_template: '{{ count > 0 }}' sequence: - service: '{{ count_script }}' data: door_name: '{{ what }}' duration: '{{ quiet_window }}' count: '{{ count + 1 }}' count_timestamp: '{{ count_timestamp }}' default: - service: script.notify data: title: '{{ what }} Opened!' message: '{{ who }} used the {{ what }}. ' - condition: template value_template: '{{ who in [''unknown''] }}' - wait_for_trigger: - platform: template value_template: '{{ states(''sensor.people_at_home'') | int(default=0) > 0 }}' timeout: seconds: 30 - choose: - conditions: - condition: template value_template: '{%- set current = timestamp | as_datetime %} {{ (now() - current).seconds >= 30 if current else False }} ' sequence: - service: script.notify data: title: '{{ what }} user is still unknown!' message: The person who used the {{ what | lower }} is still unknown! default: - service: script.notify data: title: Found {{ what }} user! message: The person who used the {{ what | lower }} is {{ state_attr('sensor.people_at_home', 'or') }}! - alias: Notify when Open too long. id: notify_on_door_ajar mode: parallel trigger: *id004 variables: valid: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' source: "{%- if valid %}\n {{ trigger.to_state.entity_id }}\n{%- endif %}\n" timestamp: '{{ (datetime | default(now())).isoformat() }} ' duration: "{%- set times = {\n 'binary_sensor.main_door': 90,\n 'binary_sensor.garage_entry_door':\ \ 90,\n 'binary_sensor.sliding_door': 240,\n 'binary_sensor.front_garage_door':\ \ 300,\n 'binary_sensor.rear_garage_door': 300,\n 'binary_sensor.passenger_door':\ \ 90,\n 'input_boolean.test_door': 5,\n} %} {%- if valid and trigger.to_state.entity_id\ \ in times %}\n {{ times[trigger.to_state.entity_id] }}\n{%- else %} {# default\ \ to 5 minutes for other doors #}\n 300\n{%- endif %}\n" door_name: '{{ state_attr(trigger.entity_id, ''friendly_name'') }} ' condition: *id005 action: - service: script.notify_if_ajar data: duration: '{{ duration }}' door: '{{ source }}' door_name: '{{ door_name }}' timestamp: '{{ timestamp }}' - alias: Illuminate Door id: illuminate_doors_when_open mode: parallel trigger: - platform: state entity_id: - binary_sensor.main_door - binary_sensor.garage_entry_door - binary_sensor.sliding_door - binary_sensor.server_room_door_contact from: 'off' to: 'on' variables: metadata: binary_sensor.main_door: entities: - switch.foyer duration: 120 binary_sensor.garage_entry_door: entities: - switch.garage_entry - switch.garage_cans duration: 120 binary_sensor.sliding_door: entities: - light.dining_room_chandelier duration: 30 input_boolean.test_door: entities: - input_boolean.test_switch - input_boolean.test_switch_2 duration: 10 valid: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' source: "{%- if valid %}\n {{ trigger.to_state.entity_id }}\n{%- endif %}\n" timestamp: '{{ (datetime | default(now())).isoformat() }} ' object_id: '{{ source.split(''.'')[-1] }} ' sensor: 'sensor.{{ object_id }}_last_opened ' script: 'script.resume_{{ object_id }} ' last_opened: '{{ states(sensor) | default('''') }} ' current: "{%- if valid and source in metadata %}\n {{ metadata[source] }}\n{%-\ \ endif %}\n" snapshot_entities: '{{ current.entities | default([]) }} ' action_data: "{%- macro kvp(k, v) %}{{ '\"{}\"'.format(k) }}: {{ '\"{}\"'.format(v)\ \ if v is string and not (v.startswith('{') or v.startswith('['))else v }}{%\ \ endmacro %} {%- macro coll(item, t='curly') %}{{ '{}{}{}'.format('{' if t\ \ == 'curly' else '[',item | join(', ') if item is iterable and item is not\ \ string else item, '}' if t == 'curly' else ']') }}{% endmacro %} {%- set ns\ \ = namespace(entities=[], scene_ids=[], scripts=[]) %} {%- set brightness =\ \ current.brightness | default(255) %} {%- for entity in snapshot_entities %}\n\ \ {%- set ns.scripts = ns.scripts + [ '\"script.resume_{}\"'.format(entity.replace('.','_'))]\ \ %}\n {%- set ns.scene_ids = ns.scene_ids + [ '\"{}\"'.format(entity.replace('.','_'))]\ \ %}\n {%- if entity.startswith('light.') %}\n {%- set ret = [kvp('state',\ \ 'on'), kvp('brightness', brightness)] %}\n {%- else %}\n {%- set ret =\ \ kvp('state', 'on') %}\n {%- endif %}\n {%- set ns.entities = ns.entities\ \ + [ kvp(entity, coll(ret)) ] %}\n{%- endfor %} {%- set ret = [ kvp('entities',\ \ coll(ns.entities | join(','))), kvp('scripts', coll(ns.scripts | join(','),\ \ 'list')), kvp('scene_ids', coll(ns.scene_ids | join(','), 'list'))] %} {{\ \ coll(ret) }}\n" duration: '{{ current.duration | default(0)}} ' delta: "{%- set last = last_opened | as_datetime %} {%- set current = timestamp\ \ | as_datetime %} {%- if last and current %}\n {{ (current - last).seconds\ \ }}\n{%- else %}\n {{ duration + 1 }}\n{%- endif %}\n" in_duration: '{{ delta < duration }} ' condition: &id006 - condition: template value_template: '{{ valid }}' - condition: or conditions: - condition: state entity_id: sun.sun state: below_horizon - condition: numeric_state entity_id: sensor.garage_luminance below: 11 action: - choose: - conditions: - condition: template value_template: '{{ not in_duration }}' sequence: - repeat: count: '{{ action_data.scene_ids | length }}' sequence: - service: scene.create data: scene_id: '{{ action_data.scene_ids[repeat.index - 1] }}' snapshot_entities: '{{ snapshot_entities[repeat.index - 1] }}' - service: scene.apply data: entities: '{{ action_data.entities }}' - wait_template: '{{ is_state(source, ''off'') }}' - repeat: count: '{{ action_data.scripts | length }}' sequence: - event: illuminate_door event_data: service: '{{ action_data.scripts[repeat.index - 1] }}' duration: '{{ duration }}' scene_id: '{{ action_data.scene_ids[repeat.index - 1] }}' - alias: Illuminate Event Handler id: illuminate_door_event_handler mode: parallel trigger: - platform: event event_type: illuminate_door variables: data: '{{ trigger.event.data | default({}) }} ' service: '{{ data.service | default }} ' duration: '{{ data.duration | default }} ' scene_id: '{{ data.scene_id | default }} ' valid: '{{ true if service and duration and scene_id else false }} ' condition: *id006 action: - service: '{{ service }}' data: duration: '{{ duration }}' scene_id: '{{ scene_id }}' - alias: Cancel Scheduled Resume State id: cancel_scheduled_resume_state mode: parallel trigger: - platform: state entity_id: - switch.foyer - switch.garage_entry - switch.garage_cans - light.dining_room_chandelier variables: valid: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' source: "{%- if valid %}\n {{ trigger.to_state.entity_id }}\n{%- endif %}\n" script: '{{ ''script.resume_{}''.format(source.replace(''.'',''_'')) }} ' condition: *id006 action: - service: script.turn_off target: entity_id: '{{ script }}' - alias: Illuminate Server Room id: illuminate_server_room mode: parallel trigger: - platform: state entity_id: binary_sensor.server_room_door_contact variables: continue: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' to_state: '{{ trigger.to_state.state | default('''') if continue else '''' }} ' condition: - condition: template value_template: '{{ continue and to_state in [''on'',''off''] }}' action: - service: switch.turn_{{ to_state }} target: entity_id: - switch.server_room_switch - alias: Notify id: announce_and_notify_on_doorbell_press mode: parallel trigger: - platform: state entity_id: - binary_sensor.doorbell_chime to: 'on' from: 'off' variables: valid: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' timeout: "{%- if valid %}\n {{ as_timestamp(trigger.to_state.last_changed, 0)\ \ - as_timestamp(trigger.from_state.last_changed, 0) }}\n{% endif %}\n" continue: '{{ timeout and timeout > 15 }} ' condition: - condition: template value_template: '{{ continue }}' action: - service: script.notify data: title: Door Bell! message: Door Bell! - alias: Suppress Chime id: suppress_doorbell_chime mode: single trigger: - platform: state entity_id: - binary_sensor.doorbell_chime to: 'on' from: 'off' action: - service: switch.turn_off target: entity_id: switch.doorbell_chime_active - delay: 00:00:15 - service: switch.turn_on target: entity_id: switch.doorbell_chime_active - alias: MQTT Discovery id: mqtt_store_drink_states_discovery mode: single trigger: - platform: homeassistant event: start variables: root: homeassistant milliliter: 0.20288414 teaspoon: 1 tablespoon: 3 ounce: 6 shot: 9 quarter: 12 third: 16 half: 24 two_thirds: 32 three_forths: 36 cup: 48 drinks: - name: Soco Manhattan id: soco_manhattan image: /local/images/manhattan.png parts: - name: Southern Comfort type: parts count: '{{ 3 * ounce }}' - name: Sweet Vermouth type: parts count: '{{ ounce }}' - name: Angostura Bitters type: dash - name: Cherry type: garnish - name: Smoke Rings id: smoke_rings image: /local/images/smoke_rings.png parts: - name: Rittenhouse Rye Whiskey type: parts count: '{{ 3 * ounce }}' - name: Sweet Vermouth type: parts count: '{{ ounce }}' - name: Angostura Bitters type: dash - name: Hickory Smoke type: garnish - name: Maple Syrup type: parts count: '{{ teaspoon }}' - name: Old Fashioned id: old_fashio image: /local/images/old_fashioned.png parts: - name: Rye Whiskey or Bourbon type: parts count: '{{ 3 * shot }}' - name: Cherry Juice type: parts count: '{{ 1/2 * shot }}' - name: Club Soda type: parts count: '{{ 1/2 * shot }}' - name: Angostura Bitters type: dash - name: Orance Slice type: garnish - name: 3 Cherries type: garnish - name: Mango Habanero Margarita id: mango_habanero image: /local/images/spicy_margarita.png parts: - name: Habanero Tequila type: parts count: '{{ quarter }}' - name: Naked Mango type: parts count: '{{ cup }}' - name: Cointreau Orange Liqueur type: parts count: '{{ 2 * tablespoon }}' - name: Lime Juice type: parts count: '{{ tablespoon }}' - name: Apple Cider Margarita id: apple_cider_margarita image: /local/images/apple_cider_margarita.png parts: - name: Cinnamon Tequila type: parts count: '{{ quarter }}' - name: Cider type: parts count: '{{ cup }}' - name: Cointreau Orange Liqueur type: parts count: '{{ ounce }}' - name: Simple Syrup type: parts count: '{{ ounce }}' - name: Cosmopolitan id: cosmopolitan image: /local/images/apple_cider_margarita.png parts: - name: Vodka type: parts count: '{{ 2 * shot }}' - name: Cranberry type: parts count: '{{ 2 * shot }}' - name: Triple Sec type: parts count: '{{ shot }}' - name: Lime Juice type: parts count: '{{ shot }}' action: - service: script.mqtt_automated_config data: domain: sensor unique_id: drinks_config - service: script.mqtt_automated_states data: domain: sensor unique_id: drinks_config state: '{{ drinks | count }}' attributes: "{{ {\n 'drinks': drinks\n} }}\n" - service: mqtt.publish data: "{% set command_template = \"{% set drinks = \" ~ drinks ~ \"%}{% set drink\ \ = drinks | selectattr('name', 'eq', value) | first | default(drinks[0]) %}{{\ \ drink | to_json }}\" %} {% set options = drinks | map(attribute='name') |\ \ list %} {{\n {\n 'topic': root ~ '/select/drinks/config',\n 'payload':\ \ {\n 'name': 'Drink',\n 'unique_id': 'drink_selector',\n\ \ 'object_id': 'drink',\n 'state_topic': root ~ '/select/drinks/state',\n\ \ 'value_template': '{{ value_json.name }}',\n 'command_topic':\ \ root ~ '/select/drinks/state',\n 'command_template': command_template,\n\ \ 'json_attributes_topic': root ~ '/select/drinks/state',\n \ \ 'json_attributes_template': '{{ {\"parts\": value_json.parts, \"image\"\ : value_json.image} | tojson }}',\n 'value_template': \"{{ value_json.name\ \ }}\",\n 'options': options,\n 'retain': True,\n }\ \ | to_json,\n 'retain': True,\n }\n}}\n" - alias: MQTT Discovery id: mqtt_store_echo_states_discovery mode: single trigger: - platform: homeassistant event: start action: - service: script.mqtt_automated_config data: domain: sensor unique_id: alexa_last_tts device_class: timestamp - alias: Events - Milestone Notifications id: event_milestone_notifications trigger: - platform: time at: '10:00:00' - platform: time at: '15:30:00' - platform: time at: '19:00:00' variables: target_date: '{{ today_at().date() | string }} ' events: '{{ state_attr(''binary_sensor.personal_events'', ''events'') | selectattr(''when'', ''eq'', target_date) | list }} ' condition: - condition: state entity_id: binary_sensor.personal_events state: 'on' action: - repeat: for_each: '{{ events }}' sequence: - service: script.notify data: message: 'Today is {{ repeat.item.who }}s {{ repeat.item.event }}! ' - alias: Events - Milestone Reminders id: event_milestone_reminders trigger: - platform: time at: '10:00:00' - platform: time at: '15:30:00' - platform: time at: '19:00:00' variables: target_dates: '{% set ns = namespace(dates=[]) %} {%- for offset in [30, 14, 7] %} {%- set ns.dates = ns.dates + [(today_at() + timedelta(days=offset)).date() | string] %} {%- endfor %} {{ ns.dates }} ' events: '{{ state_attr(''binary_sensor.personal_events'', ''events'') | selectattr(''when'', ''in'', target_dates) | selectattr(''who'', ''search'', ''Mike|Lindsay'') | list }} ' condition: - condition: template value_template: '{{ events | count > 0 }}' action: - repeat: for_each: '{{ events }}' sequence: - service: script.notify data: message: '{{ repeat.item.who }}s {{ repeat.item.event }} is in {{ repeat.item.days_away }} day{{ ''s'' if repeat.item.days_away > 1 else '''' }}! ' - alias: Events - Calendar Reminders id: event_calendar_reminders trigger: - platform: time at: '19:00:00' action: - service: script.events - alias: Events - Forward Reload Templates id: reload_templates trigger: - platform: event event_type: event_template_reloaded action: - delay: 00:00:01 - event: templates_reloaded event_data: {} - alias: Turn On Livingroom lights with Activities id: turn_on_livingroom_lights_with_harmony_activities trigger: - platform: state entity_id: - switch.xbox_one - switch.playstation - switch.roku - switch.switch - switch.tv to: 'on' from: 'off' condition: - condition: state entity_id: sun.sun state: below_horizon action: - service: homeassistant.turn_on target: entity_id: - light.living_room - switch.hyperion_usb_capture - alias: Turn Off Hyperion with Activities id: turn_off_hyperion_lights_with_harmony_activities trigger: - platform: template value_template: '{{ is_state_attr(''remote.living_room'', ''current_activity'', ''PowerOff'') }}' condition: - condition: state entity_id: sun.sun state: below_horizon action: - service: switch.turn_off target: entity_id: switch.hyperion_usb_capture - alias: Give ChromeCast control to remote using emulated roku id: harmony_give_chromecast_control_to_remote_using_emulated_roku mode: restart trigger: - platform: event event_type: roku_command event_data: source_name: Home Assistant variables: target: media_player.chromecast jump_in_seconds: 10 key: '{{ trigger.event.data.key | default("NoPress") }} ' keys: - Play - Rev - Fwd play_pause: '{{ key == ''Play'' }}' rev: '{{ key == ''Rev'' }}' fwd: '{{ key == ''Fwd'' }}' rev_fwd: '{{ fwd or rev }}' condition: - condition: template value_template: '{{ states(target) in [''playing'', ''paused''] and key != ''NoPress'' }} ' action: - choose: - conditions: - condition: template value_template: '{{ play_pause }}' sequence: - service: media_player.media_play_pause target: entity_id: '{{ target }}' - conditions: - condition: template value_template: '{{ rev_fwd }}' sequence: - service: media_player.media_seek target: entity_id: '{{ target }}' data: seek_position: "{%- set current = state_attr(target, 'media_position') |\ \ default(0) %} {%- set total = state_attr(target, 'media_duration') |\ \ default(0) %} {%- set dir = 1 if fwd else -1 %} {%- set next = current\ \ + jump_in_seconds * dir %} {%- if fwd %}\n {{ total if next >= total\ \ else next }}\n{%- else %}\n {{ 0 if next <= 0 else next }}\n{%- endif\ \ %}\n " - alias: Timed Event - Holiday Lights id: indoor_holiday_lights mode: parallel trigger: - id: indoor platform: state entity_id: binary_sensor.indoor_holiday not_from: - unknown - unavailable - id: outdoor_on platform: sun event: sunset - id: outdoor_off platform: sun event: sunrise variables: continue: "{% if trigger.platform == 'state' %}\n {{ trigger | default(none)\ \ is not none and trigger.to_state is defined and trigger.from_state is defined\ \ }}\n{% else %}\n True\n{% endif %}\n" to_state: "{% if trigger.platform == 'state' %}\n {{ trigger.to_state.state |\ \ default if continue else None }}\n{% else %}\n {{ trigger.id.split('_')[-1]\ \ }}\n{% endif %}\n" indoor: - switch.indoor_holiday outdoor: [] target: '{{ indoor if trigger.id == ''indoor'' else outdoor }} ' condition: - condition: template value_template: '{{ target | count > 0 and continue and to_state in [''on'',''off''] }}' action: - service: switch.turn_{{ to_state }} target: entity_id: '{{ target }}' - alias: Turn on fan when bathroom humidity is high. id: bathroom_turn_on_fan_when_humidity_is_high mode: restart trigger: - platform: state entity_id: binary_sensor.master_bathroom_humidity_status variables: check: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' continue: '{%- set valid = [''on'', ''off''] %} {{ check and trigger.to_state.state in valid and trigger.from_state.state in valid }} ' service: 'switch.turn_{{ trigger.to_state.state if continue else none }} ' add_delay: '{{ trigger.to_state.state == ''off'' if continue else False }} ' condition: - condition: template value_template: '{{ continue }}' action: - choose: - conditions: '{{ add_delay }}' sequence: - delay: 00:20:00 - service: '{{ service }}' target: entity_id: switch.master_bathroom_fan - delay: seconds: 1 - alias: Notify when basement humidity is high id: basement_notify_when_humidity_is_high mode: parallel trigger: - id: 2 hours platform: state entity_id: binary_sensor.basement_humidity_high to: 'on' for: hours: 2 - id: 10 hours platform: state entity_id: binary_sensor.basement_humidity_high to: 'on' for: hours: 10 action: - service: script.notify data: title: Basement humidity has been high for {{ trigger.id }}. message: Basement humidity has been high for {{ trigger.id }}. - alias: Execute Effects id: hyperion_execute_effects mode: restart trigger: - platform: state entity_id: - input_number.hyperion_brightness - input_select.hyperion_effects variables: valid: "{{ trigger.from_state is defined and trigger.from_state is not none \n\ \ and trigger.to_state is defined and trigger.to_state is not none \n and\ \ trigger.from_state.state != trigger.to_state.state }}\n" source: '{{ trigger.to_state.entity_id }} ' target: light.gpio_18_tv brightness: "{%- if source == 'input_number.hyperion_brightness' %}\n {{ trigger.to_state.state\ \ }}\n{%- else %}\n {{ states('input_number.hyperion_brightness') }}\n{%- endif\ \ %}\n" effect: "{%- if source == 'input_select.hyperion_effects' %}\n {{ trigger.to_state.state\ \ }}\n{%- else %}\n {{ states('input_select.hyperion_effects') }}\n{%- endif\ \ %}\n" condition: - condition: template value_template: '{{ valid }}' action: - service: light.turn_on target: entity_id: '{{ target }}' data: brightness: '{{ brightness }}' effect: '{{ effect }}' - alias: MQTT Discovery id: aafa91b8-a2e2-4df2-9412-536288327566 mode: single trigger: - platform: homeassistant event: start action: - service: script.turn_on target: entity_id: script.irrigation_mqtt_discovery - alias: Set Next Irrigation id: 54f20352-b2ba-44d7-80f5-44ada2469dbc mode: restart trigger: - platform: homeassistant event: start - platform: time at: 00:00:00 - platform: state entity_id: - input_datetime.irrigation_program_start - switch.back_yard_status - switch.front_yard_status - number.back_yard_day_cycle - number.front_yard_day_cycle - switch.rain_bird_sprinkler_1_status - switch.rain_bird_sprinkler_2_status - switch.rain_bird_sprinkler_3_status - switch.rain_bird_sprinkler_5_status - switch.rain_bird_sprinkler_6_status - switch.rain_bird_sprinkler_7_status - switch.rain_bird_sprinkler_8_status - number.rain_bird_sprinkler_1_program_duration - number.rain_bird_sprinkler_2_program_duration - number.rain_bird_sprinkler_3_program_duration - number.rain_bird_sprinkler_5_program_duration - number.rain_bird_sprinkler_6_program_duration - number.rain_bird_sprinkler_7_program_duration - number.rain_bird_sprinkler_8_program_duration action: - service: script.get_next_irrigations response_variable: irrigations - condition: template value_template: '{{ irrigations.zones | count > 0 }}' - repeat: for_each: '{{ irrigations.zones }}' sequence: - service: script.mqtt_automated_states data: domain: sensor unique_id: '{{ repeat.item.zone_next_run_id }}' state: '{{ repeat.item.zone_next_run }}' - alias: Start Irrigation Cycle id: 1c67152d-d153-41a9-b5a7-78ce036fecbf mode: single trigger: - platform: time at: &id007 - sensor.rain_bird_sprinkler_1_start - sensor.rain_bird_sprinkler_2_start - sensor.rain_bird_sprinkler_3_start - sensor.rain_bird_sprinkler_5_start - sensor.rain_bird_sprinkler_6_start - sensor.rain_bird_sprinkler_7_start - sensor.rain_bird_sprinkler_8_start variables: entities: *id007 trigger_time: '{{ trigger.now.astimezone(utcnow().tzinfo).replace(second=0, microsecond=0).isoformat() }} ' start: '{{ entities | select(''is_state'', trigger_time) | first | default }} ' object_id: '{{ start | regex_findall(''sensor.(.*)_start'') | first }} ' switch: switch.{{ object_id }} number: number.{{ object_id }}_program_duration last_run_unique_id: '{% set identifier = device_attr(''sensor.{0}_last_run''.format(object_id), ''identifiers'') | list | first | last %} {{ identifier | slugify | replace(''_'', '''') ~ ''lr'' }} ' last_run_attributes: '{{ dict(by=''irrigation'' if is_state(''binary_sensor.rain_bird_controller_rainsensor'', ''off'') else ''rain'') }} ' duration: '{{ states(number) | int(0) }} ' condition: - condition: template value_template: '{{ duration > 0 }}' action: - service: script.mqtt_automated_states data: domain: sensor unique_id: '{{ last_run_unique_id }}' state: '{{ trigger_time }}' attributes: '{{ last_run_attributes }}' - if: '{{ is_state(''binary_sensor.rain_bird_controller_rainsensor'', ''off'') }}' then: - service: rainbird.start_irrigation data: entity_id: '{{ switch }}' duration: '{{ duration }}' - alias: Check Rain Today id: a9040111-cd2f-4dd4-9a6b-518bfa2e90e9 mode: restart triggers: - trigger: time at: - entity_id: input_datetime.irrigation_program_start offset: -00:01:00 variables: trigger_time: '{{ trigger.now.astimezone(utcnow().tzinfo).replace(second=0, microsecond=0).isoformat() }} ' conditions: - condition: state entity_id: binary_sensor.rain_bird_controller_rainsensor state: 'on' - condition: state entity_id: binary_sensor.irrigation_season state: 'on' actions: - action: script.set_last_irrigation data: time: '{{ (trigger_time | as_datetime).time() }}' date: '{{ (trigger_time | as_datetime).date() }}' switches: '{{ integration_entities(''rainbird'') | select(''match'', ''^switch.'') | list }}' reason: rain - alias: Valve Reminders id: 33596fc1-7dbf-4837-a589-953f2d5d072a trigger: - platform: time at: '10:00:00' - platform: time at: '15:30:00' - platform: time at: '19:00:00' variables: target_dates: '{% set ns = namespace(dates=[]) %} {%- for offset in [7, 1] %} {%- set ns.dates = ns.dates + [(today_at() + timedelta(days=offset)).date() | string] %} {%- endfor %} {{ ns.dates }} ' entities: - sensor.irrigation_season_start - sensor.irrigation_season_end events: "{%- from 'easy_time.jinja' import speak_the_days %} {%- set phrase =\ \ 'Turn o{} the water irrigation shutoff value{}{}' %} {%- set ns = namespace(items=[])\ \ %} {%- for e in entities %}\n {%- set dt = states(e) | as_datetime %}\n \ \ {%- set date = dt.date() | string %}\n {%- set name = state_attr(e, 'friendly_name')\ \ %}\n {%- set p = 'n' if 'Start' in name else 'ff' %}\n {%- set f = speak_the_days(dt)\ \ %}\n {%- set m = ' ' if 'in' in f else ' before ' %}\n {%- set ns.items\ \ = ns.items + [\n dict(\n title=name,\n when=date,\n message=phrase.format(p,\ \ m, f)\n )\n ] -%}\n{%- endfor %} {{ ns.items }}\n" event: '{{ events | selectattr(''when'', ''in'', target_dates) | list | first | default(None) }} ' condition: - condition: template value_template: '{{ event is not none }}' action: - service: script.notify data: title: '{{ event.title }}' message: '{{ event.message }}' - alias: Garage position indicator id: laser_position_indicator_automation mode: parallel trigger: - platform: state entity_id: - binary_sensor.front_garage_door variables: laser: switch.garage_ceiling_outlet valid: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' is_on: '{{ trigger.to_state.state == ''on'' and trigger.from_state.state == ''off'' }} ' is_off: '{{ trigger.to_state.state == ''off'' and trigger.from_state.state == ''on'' }} ' continue: '{{ valid and (is_on or is_off) }} ' is_laser_on: '{{ is_state(laser, ''on'') }} ' condition: - condition: template value_template: '{{ continue }}' action: - choose: - conditions: - condition: template value_template: '{{ is_on }}' sequence: - service: script.turn_off target: entity_id: script.laser_position_timer - choose: - conditions: - condition: template value_template: '{{ not is_laser_on }}' sequence: - service: switch.turn_on target: entity_id: '{{ laser }}' - service: script.laser_position_timer - conditions: - condition: template value_template: '{{ is_off }}' sequence: - choose: - conditions: - condition: template value_template: '{{ is_laser_on }}' sequence: - service: script.turn_off target: entity_id: script.laser_position_timer - service: switch.turn_off target: entity_id: '{{ laser }}' - alias: Notify id: announce_dryer_when_complete mode: parallel trigger: - platform: state entity_id: - binary_sensor.dryer_status - binary_sensor.washer to: 'off' from: 'on' variables: valid: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' timeout: "{%- if valid %}\n {{ as_timestamp(trigger.to_state.last_changed, 0)\ \ - as_timestamp(trigger.from_state.last_changed, 0) }}\n{% endif %}\n" continue: '{{ timeout and timeout > 15 }} ' name: '{{ trigger.to_state.name.split('' '')[0] if valid else ''Unknown'' }} ' announce: '{{ name.lower() if name != ''Unkonwn'' else none }} ' condition: - condition: template value_template: '{{ continue and announce is not none }}' action: - event: announce_energy event_data: machine: '{{ announce }}' - service: script.notify data: title: '{{ name }} is finished!' message: '{{ name }} is finished!' - alias: Booleans id: washer_and_dryer_booleans mode: parallel trigger: - platform: state entity_id: - sensor.dryer_power - sensor.washer_power variables: config: sensor.washer_power: input_boolean: input_boolean.washer threshold: 80 sensor.dryer_power: input_boolean: input_boolean.dryer threshold: 150 valid: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' current: '{{ config.get(trigger.entity_id) }} ' have_current: '{{ current is not none }} ' number: '{{ trigger.to_state.state if valid and is_number(trigger.to_state.state) else none }} ' have_number: '{{ number is not none }} ' disposition: '{{ number > current.threshold if have_current and have_number else none }} ' service_target: '{{ current.input_boolean if have_current else none }} ' service_call: 'homeassistant.turn_o{{ ''n'' if disposition else ''ff'' }} ' continue: '{{ valid and disposition is not none }} ' condition: - condition: template value_template: '{{ continue }}' action: - service: '{{ service_call }}' target: entity_id: '{{ service_target }}' - alias: Cycle Counter id: washer_and_dryer_cycle_counter mode: parallel trigger: - platform: state entity_id: - input_boolean.test_washer - binary_sensor.washer_status variables: prefix: washer_dryer_ valid: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' continue: '{{ trigger.to_state.state != trigger.from_state.state if valid else False }} ' source: '{{ trigger.entity_id }} ' next_phase: '{{ trigger.to_state.state if valid else none }} ' condition: - condition: template value_template: '{{ continue }}' action: - service: script.calculate_washer_cycle data: prefix: '{{ prefix }}' source: '{{ source }}' next_phase: '{{ next_phase }}' - alias: MQTT Discovery id: 3e5e2ffb-d811-4818-a6bd-1f1386c6dbae trigger: - platform: homeassistant event: start action: - variables: prefix: washer_dryer_ binary_sensors: - test_washer - washer - repeat: count: '{{ binary_sensors | length }}' sequence: - service: script.mqtt_automated_config data: domain: binary_sensor unique_id: '{{ prefix }}{{ binary_sensors[repeat.index - 1] }}' object_id: '{{ binary_sensors[repeat.index - 1] }}' device_class: running - alias: Leak Warning id: 0705a3d3-e7e4-475f-9063-70e7c6107c83 description: Notify if there's a leak triggers: - trigger: state entity_id: - binary_sensor.leak to: 'on' actions: - action: script.notify data: title: Leak Detected! message: '{{ state_attr(''binary_sensor.leak'', ''message'') }}' - action: input_datetime.set_datetime target: &id008 entity_id: input_datetime.leak_annoy data: &id009 datetime: '{{ now() + timedelta(minutes=15) }} ' - alias: Leak Persistence id: 391d15c8-d9de-4937-94e9-c6367690ea4a description: Keep notifying if there's a leak. triggers: - trigger: time at: input_datetime.leak_annoy conditions: - condition: state entity_id: binary_sensor.leak state: 'on' actions: - action: script.notify data: title: Leak Detected! message: '{{ message }}' - action: input_datetime.set_datetime target: *id008 data: *id009 - alias: Execute Quick Effects on UI updates id: execute_quick_effects_on_ui_updates mode: restart trigger: - platform: state entity_id: - input_number.quick_strip_brightness - input_number.quick_strip_color_temp - input_number.quick_strip_hue - input_select.quick_strip_effect variables: valid_trigger: "{{ trigger.from_state is defined and trigger.from_state is not\ \ none \n and trigger.to_state is defined and trigger.to_state is not none\ \ \n and trigger.from_state.state != trigger.to_state.state }}\n" choose_service: "{# Should we run a choose service? Returns 0 if we shouldn't\ \ #} {%- if valid_trigger %}\n {%- set color_temp = 'color_temp' in trigger.to_state.object_id\ \ %}\n {%- set hue = 'hue' in trigger.to_state.object_id %}\n {%- set effect\ \ = 'effect' in trigger.to_state.object_id %}\n {%- if hue or color_temp %}\n\ \ input_boolean.turn_{{ 'on' if color_temp else 'off' }}\n {%- elif effect\ \ %}\n {# This is because you can't turn it off in hue mode for some reason\ \ #}\n {{ 'input_boolean.turn_on' if trigger.to_state.state == 'off' else\ \ 0 }}\n {%- else %}\n 0\n {%- endif %}\n{%- else %}\n 0\n{%- endif %}\n" continue_actions: "{%- if valid_trigger %}\n {%- if 'effect' in trigger.to_state.object_id\ \ %}\n true\n {%- else %}\n {{ states('input_select.quick_strip_effect')\ \ != 'off' }}\n {%- endif %}\n{%- else %}\n false\n{%- endif %}\n" condition: - condition: template value_template: '{{ continue_actions }}' action: - choose: - conditions: - condition: template value_template: '{{ choose_service != 0 }}' sequence: - service: '{{ choose_service }}' data: entity_id: input_boolean.hue_color_temp - service: script.lzw45_ui_quick_effect - alias: Manage LZW Pixel Effects & Quick Strip Effects id: manage_lzw_pixel_effects_and_quick_strip_effects trigger: - platform: state entity_id: - input_select.quick_strip_effect - script.lzw45_ui_pixel_effect - script.lzw45_ui_custom_effect variables: from_state_trigger_valid: '{{ trigger.from_state is defined and trigger.from_state is not none and trigger.from_state.state not in [''unavailable'', ''unknown''] }} ' to_state_trigger_valid: '{{ trigger.to_state is defined and trigger.to_state is not none and trigger.to_state.state not in [''unavailable'', ''unknown''] }} ' valid_trigger: '{{ from_state_trigger_valid and to_state_trigger_valid and trigger.from_state.state != trigger.to_state.state }} ' last_effect: "{%- if valid_trigger %}\n {%- if trigger.to_state.object_id in\ \ ('lzw45_ui_pixel_effect', 'lzw45_party_effect') %}\n {{ states('input_select.pixel_effect')\ \ }}\n {%- elif trigger.to_state.object_id == 'lzw45_ui_custom_effect' %}\n\ \ custom\n {%- else %}\n {{ trigger.to_state.state }}\n {%- endif %}\n\ {%- endif %}\n" condition: - condition: template value_template: '{{ valid_trigger }}' action: - service: input_text.set_value data: entity_id: input_text.lzw45_last_effect value: '{{ last_effect }}' - alias: Keep Sunset Switches On. id: reaction_keep_sunset_switches_on mode: parallel trigger: - platform: state entity_id: - switch.passenger_sconce - switch.sconces_garage - switch.sconces_main_entrance to: 'off' variables: continue: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' condition: - condition: template value_template: '{{ continue }}' action: - service: switch.turn_on target: entity_id: '{{ trigger.entity_id }}' - service: script.notify data: title: Sunset Switch Turned Off message: '{{ state_attr(trigger.entity_id, ''friendly_name'') }} door sconce switch was turned off, turning back on. ' - service: script.notify_area data: message: Jim counter action initiative in affect. Turning on {{ state_attr(trigger.entity_id, 'friendly_name') }} door sconces. announce: false area: living_room - condition: sun after: sunrise before: sunset - delay: seconds: 5 - service: light.turn_off target: entity_id: light.outdoor_bulbs - alias: Living Room Lamp Availability. id: reaction_keep_living_room_lamps_available mode: parallel trigger: - platform: state entity_id: &id010 - light.jims_lamp - light.mikes_lamp - light.lindsays_lamp to: unavailable variables: triggering: '{{ trigger.entity_id }} ' entities: *id010 continue: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' only_triggering_light: '{{ expand(entities) | rejectattr(''entity_id'', ''eq'', triggering) | map(attribute=''state'') | select(''eq'', ''unavailable'') | list | length == 0 }} ' name: '{{ state_attr(triggering, ''friendly_name'') or ''unknown'' }} ' condition: - condition: template value_template: '{{ continue and only_triggering_light }}' action: - service: script.notify data: message: '{{ name.capitalize() }} went unavailable! Notifying living room. ' - service: script.notify_area data: message: "Please do not turn off living room lamps, turn the lamp back on. \ \ If you want to turn on this lamp in the future, say: Turn on {{ name }}.\ \ \n" announce: false area: living_room - alias: Fix Zwave Multicast Errors id: 6c4bb70c-e8a7-40c8-9c78-bb077023e3b9 description: Refreshes a zwave multicast light and attempts to fix it. mode: single triggers: - not_from: &id011 - unknown - unavailable not_to: &id012 - unknown - unavailable trigger: state entity_id: sensor.multicast_error variables: action: '{{ trigger.to_state.attributes.action | default(None) }}' entity_id: '{{ trigger.to_state.attributes.entity_id | default(None) }}' new: '{# Stops reload template from triggering. #} {%- set t = now() %} {%- set yesterday = t - timedelta(hours=24) %} {{ t - trigger.to_state.state | as_datetime(yesterday) | as_local < timedelta(seconds=10) }} ' continue: '{{ action is not none and entity_id is not none and new }}' conditions: - condition: template value_template: '{{ continue }}' action: - action: script.notify data: notify: notify.mobile_app_petro title: Multicast Error message: Refreshing {{ state_attr(entity_id, 'friendly_name') }} - action: script.get_zwave_entities_from_light_group data: light: '{{ entity_id }}' response_variable: response - delay: 1 - action: zwave_js.refresh_value target: entity_id: '{{ response.entity_id }}' - action: '{{ action }}' target: entity_id: '{{ entity_id }}' - alias: Fix Wled Errors id: 06cfa18a-fa57-406d-94dc-5037e6096b87 description: Refreshes a zwave multicast light and attempts to fix it. mode: single triggers: - not_from: *id011 not_to: *id012 trigger: state entity_id: sensor.wled_api_error variables: config: wled_hutch: - light.hutch_uplight kitchen_uplight: - light.cabinet_master - light.cabinet_slave kitchen_cabinet_2: - light.cabinet_surface source: '{{ trigger.to_state.attributes.source | default(None) }} ' action: '{{ trigger.to_state.attributes.action | default(None) }} ' entities: '{{ config.get(trigger.to_state.attributes.source, []) }} ' to_state: '{{ action.split(''_'') | last if action else None }} ' filtered: '{{ entities | reject(''is_state'', to_state) | list }} ' new: '{# Stops reload template from triggering. #} {%- set t = now() %} {%- set yesterday = t - timedelta(hours=24) %} {{ t - trigger.to_state.state | as_datetime(yesterday) | as_local < timedelta(seconds=10) }} ' continue: '{{ filtered | length > 0 and new }} ' conditions: - condition: template value_template: '{{ continue }}' action: - action: script.notify data: notify: notify.mobile_app_petro title: WLED Error message: Refreshing {{ filtered | map('state_attr', 'friendly_name') | list | join(', ') }} - delay: 1 - action: homeassistant.turn_{{ to_state }} target: entity_id: '{{ filtered }}' - alias: Fix Doorbell Chime Status id: 3f1c8cab-0151-4961-854e-80fdb956fcae description: Checks to see if the doorbell chime is on periodically. triggers: - id: turn_on trigger: state entity_id: switch.doorbell_chime_active to: 'off' for: minutes: 5 - id: turn_on trigger: template value_template: '{{ states(''sensor.doorbell_chime_off'') | float(0) == 5 }}' - id: check trigger: time at: '8:00:00' variables: message: "{% if trigger.id == 'turn_on' %}\n Doorbell chime has been off for\ \ at least 5 minutes. Turning Back on.\n{% elif is_state('sensor.doorbell_chime_off',\ \ 'off') %}\n Doorbell chime was found to be off at 8am, turning back on.\n\ {% else%}\n None\n{% endif %}\n" continue: '{{ message is not none }}' conditions: - condition: template value_template: '{{ continue }}' action: - action: script.notify data: notify: notify.mobile_app_petro title: Fixing Doorbell Chime message: '{{ message }}' - action: switch.turn_on target: entity_id: switch.doorbell_chime_active - alias: Play/Pause lighting in living room id: 0c371ea2-c700-476b-9c3d-b36bd3c9a662 description: Turn on lighting when paused, turn off lighting when playing. triggers: - trigger: state entity_id: media_player.roku_living_room to: - playing - paused not_from: - unavailable - unknown variables: light: light.living_room media_state: '{{ trigger.to_state.state }}' light_state: '{{ ''on'' if media_state == ''paused'' else ''off'' }}' movie_time: '{{ is_state(''switch.movie_time'', ''on'') }}' turned_on_by_this: "{% if this.context.parent_id is not none %}\n {{ light |\ \ expand | selectattr('state', 'eq', 'on') | selectattr('context.parent_id',\ \ 'eq', this.context.parent_id) | map(attribute='entity_id') | list }}\n{% else\ \ %}\n []\n{% endif %}\n" living_room_lights: "{% if movie_time and media_state == 'paused' and is_state(light,\ \ 'off') %}\n {{ state_attr(light, 'entity_id') }}\n{% elif movie_time and\ \ media_state == 'playing' and is_state(light, 'on') %}\n {{ turned_on_by_this\ \ }}\n{% else %}\n []\n{% endif %}\n" conditions: - condition: template value_template: '{{ living_room_lights | length > 0 }}' actions: - action: light.turn_{{ light_state }} target: entity_id: '{{ living_room_lights }}' - alias: Ignore Spook Repair id: repair_ignore_spook_repair trigger: - platform: state entity_id: event.repair variables: continue: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' attrs: '{{ trigger.to_state.attributes | default({}) if continue else {} }} ' issue_id: '{{ attrs.get(''issue_id'') }} ' target: '{{ issue_id if ''timed_event_snapshot_status'' in issue_id else None }} ' condition: - condition: template value_template: '{{ target is not none }}' action: - service: repairs.remove data: issue_id: '{{ target }}' - alias: Notify Snapshot status id: snapshot_status trigger: - platform: state entity_id: sensor.samba_backup variables: valid: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }}" ' status: '{{ trigger.to_state.state | default | lower }} ' not_idle: '{{ status != ''idle'' }} ' condition: - condition: template value_template: '{{ valid and not_idle }}' action: - service: script.notify data: title: Snapshot Status message: Samba backup {{ status }}. - alias: Notify Garbage Day Message id: garbage_day_message trigger: - platform: time at: '10:00:00' - platform: time at: '15:30:00' - platform: time at: '19:00:00' variables: recycling: '{% set recycling_origin = strptime(states(''input_datetime.recycling''), ''%Y-%m-%d'') | as_local %} {% set tomorrow = (today_at() + timedelta(days=1)) %} {% set days = (tomorrow - recycling_origin).days %} {{ (days // 7) % 2 == 0 }} ' what: 'Trash {{ ''and Recycling '' if recycling else '''' }}day tomorrow! ' condition: - condition: time weekday: - mon action: - service: script.notify data: message: '{{ what }}' - alias: Notify Change Filters Message id: change_filters_message trigger: - platform: time at: '10:00:00' - platform: time at: '19:00:00' condition: - condition: template value_template: '{{ now().day == 1 and now().month in [ 1, 4, 7, 10 ] }}' action: - service: script.notify data: message: Change HVAC filter. - alias: Notify Mosby Heartworm and Flee Medication. id: mosby_heartworm trigger: - platform: time at: '10:00:00' - platform: time at: '19:00:00' condition: - condition: template value_template: '{{ now().day == 1 }}' action: - service: script.notify data: message: Give mosby heartworm and flee medication. - alias: Notify DST Change id: dst_warning trigger: - platform: time at: '10:00:00' - platform: time at: '19:00:00' condition: - condition: template value_template: '{{ states(''sensor.daylight_savings_days_until'') | int(0) in [7,1] }} ' action: - service: script.notify data: message: '{%- set days = states(''sensor.daylight_savings_days_until'') | int(0) %} {%- set plural = ''s'' if days | int(0) > 1 else '''' %} Daylight savings in {{ days }} day{{plural}}, you will {{ states(''sensor.daylight_savings_phrase'') }}! ' - alias: Outdoor Lights On at Sunset, Off at Sunrise id: outdoor_lights_on_off trigger: - platform: sun event: sunset - platform: sun event: sunrise variables: event: '{{ trigger.event | default(''invalid'') }} ' scene: '{{ states(''sensor.seasonal_lights'') }} ' action: - service: script.sunrise_sunset data: event: '{{ event }}' scene: '{{ scene }}' - alias: Clear persistent_notifications at bedtime id: clear_persistent_notifications_around_bedtime trigger: - platform: time at: '22:00:00' action: - service: persistent_notification.dismiss_all - alias: Simple Thermostat id: simple_thermostat trigger: - platform: calendar event: start entity_id: calendar.thermostat variables: config: heat: 70 cool: 66 event: '{{ trigger.calendar_event.summary.lower() }} ' temperature: '{{ config.get(event) }} ' condition: - condition: template value_template: '{{ temperature is not none }}' action: - service: climate.set_temperature target: entity_id: climate.living_room_thermostat data: temperature: '{{ temperature }}' - alias: Setup Mike's Todo Lists id: d11bb907-e656-4a0b-8f03-ecbbf3e40a3a mode: single triggers: - trigger: time at: 00:00:00 - trigger: event event_type: run_manual_schedule_update variables: day: '{% from ''easy_time.jinja'' import count_the_days %} {# Assumes monday is always selected #} {{ count_the_days(''input_datetime.mike_run_program'') }} ' week: '{{ (day | abs / 7 + 1) | int }} ' action: - if: '{{ 1 <= week <= 10 }}' then: - action: script.set_run_schedule data: program: 718485f4-3031-46a3-bce5-990189a6e06c week: '{{ week }}' weekly_todo: todo.mike_this_week daily_todo: todo.mike_today max_heart_rate: 200 - action: script.set_mikes_daily_list - event: roll_up_todo - alias: Game Room Lights id: toggle_game_room_lights trigger: - platform: state entity_id: switch.game_room_switch variables: continue: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' to_state: '{{ trigger.to_state.state | default('''') if continue else '''' }} ' condition: - condition: template value_template: '{{ continue and to_state in [''on'',''off''] }}' action: - service: switch.turn_{{ to_state }} target: entity_id: - switch.game_room_bookcase_outlet - switch.game_room_buffet_outlet - alias: Basement Lights id: toggle_basement_lights trigger: - platform: state entity_id: switch.basement_stairs variables: continue: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' to_state: '{{ trigger.to_state.state | default('''') if continue else '''' }} ' condition: - condition: template value_template: '{{ continue and to_state in [''on'',''off''] }}' action: - service: switch.turn_{{ to_state }} target: entity_id: - switch.basement_cans - alias: Deck String Lights id: toggle_deck_string_lights trigger: - platform: state entity_id: &id013 - switch.deck_mood_lighting - switch.patio_string_light variables: entities: *id013 state_list: - 'on' - 'off' continue: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' to_state: '{{ trigger.to_state.state | default(none) if continue else none }} ' targets: '{{ expand(entities) | rejectattr(''entity_id'', ''eq'', trigger.entity_id) | rejectattr(''state'', ''eq'', to_state) | map(attribute=''entity_id'') | list if continue else [] }} ' condition: - condition: template value_template: '{{ continue and to_state in state_list and targets | count > 0 }}' action: - service: switch.turn_{{ to_state }} target: entity_id: '{{ targets }}' - alias: Uplight & Downlight Cabinet from Switch id: toggle_cabinet_string_lights mode: single trigger: - platform: state entity_id: switch.kitchen_cabinet variables: entities: - switch.kitchen_cabinet_2 - switch.kitchen_uplight in_season: '{% set remove = [''switch.kitchen_uplight''] if is_state(''binary_sensor.indoor_holiday'', ''on'') else [] %} {{ entities | reject(''in'', remove) | list }} ' state_list: - 'on' - 'off' continue: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined and trigger.to_state.state in state_list }} ' targets: '{{ in_season | reject(''is_state'', trigger.to_state.state) | list if continue else [] }} ' condition: - condition: template value_template: '{{ targets | count > 0 }}' action: - service: switch.turn_{{ trigger.to_state.state }} target: entity_id: '{{ targets }}' - alias: Notify Power Outage id: ups_notify_power_outage trigger: - id: notify platform: state entity_id: binary_sensor.house_power_status to: 'on' - id: power off platform: state entity_id: binary_sensor.house_power_status to: 'on' for: 00:01:00 - id: cancel platform: state entity_id: binary_sensor.house_power_status from: 'on' to: 'off' variables: valid: '{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }} ' message: "{% if trigger.id == 'notify' %}\n Detected power outage, starting power\ \ down sequence in 1 minute if power is not restored.\n{% elif trigger.id ==\ \ 'power off' %}\n Power was not restored, starting power down sequence.\n\ {% else %}\n Power has restored, canceling power down sequence.\n{% endif %}\n" condition: - condition: template value_template: '{{ valid }}' action: - service: script.notify data: message: '{{ message }}' - condition: template value_template: '{{ trigger.id == ''power off'' }}' - service: script.power_down_sequence - alias: MQTT Discovery and Automation id: mqtt_store_and_automate_weights mode: parallel trigger: - id: start platform: homeassistant event: start - id: new platform: state entity_id: sensor.master_scale_weight variables: root: homeassistant range: 20 config: - person: person.petro initial: 200 - person: person.lambo initial: 145 people: "{%- set ns = namespace(items=[]) %} {%- for item in config %}\n {%-\ \ set object_id = item.person.split('.')[-1] ~ '_weight' %}\n {%- set ns.items\ \ = ns.items + [{\n 'unique_id': object_id,\n 'object_id': object_id,\n\ \ 'initial': item.initial,\n 'current': states('sensor.' ~ object_id)\ \ | float(None),\n }] %}\n{%- endfor %} {{ ns.items }}\n" weight: "{%- if trigger.id == 'new' and trigger.to_state.state | is_number %}\n\ \ {%- set next_weight = trigger.to_state.state | float %}\n {%- set ns = namespace(items=[])\ \ %}\n {%- for person in people %}\n {%- set current = person.current or\ \ person.initial %}\n {%- if current - range <= next_weight <= current +\ \ range %}\n {%- set ns.items = ns.items + [{'next':next_weight, 'unique_id':person.unique_id}]\ \ %}\n {%- endif %}\n {%- endfor %}\n {{ ns.items | first | default }}\n\ {%- else -%}\n None\n{%- endif %}\n" action: - choose: - conditions: '{{ trigger.id == ''start'' }}' sequence: - repeat: for_each: '{{ people }}' sequence: - service: script.mqtt_automated_config data: domain: sensor unique_id: '{{ repeat.item.unique_id }}' object_id: '{{ repeat.item.object_id }}' state_class: measurement device_class: weight unit_of_measurement: lb - conditions: '{{ weight is not none }}' sequence: - service: script.mqtt_automated_states data: domain: sensor unique_id: '{{ weight.unique_id }}' state: '{{ weight.next }}'