- alias: 'Adaptive lighting: turn on and off switches' triggers: - trigger: state entity_id: input_select.sleep_mode - trigger: homeassistant event: start variables: sleep_mode: '{{ states(''input_select.sleep_mode'') }}' actions: choose: - conditions: '{{ sleep_mode == ''off'' }}' sequence: - action: switch.turn_off entity_id: - switch.adaptive_lighting_sleep_mode_bedroom - switch.adaptive_lighting_sleep_mode_bedroom_led - switch.adaptive_lighting_sleep_mode_living_room - switch.adaptive_lighting_sleep_mode_baby_room - conditions: '{{ sleep_mode == ''half'' }}' sequence: - action: switch.turn_off entity_id: - switch.adaptive_lighting_sleep_mode_living_room - action: switch.turn_on entity_id: - switch.adaptive_lighting_sleep_mode_bedroom - switch.adaptive_lighting_sleep_mode_bedroom_led - switch.adaptive_lighting_sleep_mode_baby_room - conditions: '{{ sleep_mode == ''total'' }}' sequence: - action: switch.turn_on entity_id: - switch.adaptive_lighting_sleep_mode_bedroom - switch.adaptive_lighting_sleep_mode_bedroom_led - switch.adaptive_lighting_sleep_mode_baby_room - alias: 'Adaptive lighting: reset manual_control after 1 hour' mode: parallel max: 200 triggers: - trigger: event event_type: adaptive_lighting.manual_control variables: light: '{{ trigger.event.data.entity_id }}' switch: '{{ trigger.event.data.switch }}' conditions: '{{ ''hall'' not in light and ''stairs'' not in light }}' actions: - delay: 01:00:00 - condition: template value_template: '{{ light in state_attr(''switch'', ''manual_control'') }}' - action: adaptive_lighting.set_manual_control data: entity_id: '{{ switch }}' lights: '{{ light }}' manual_control: false - action: notify.iphone_bas data: title: 'Adaptive Ligthing: manual_control reset' message: '{{ light }} is reset to not ''manually controlled''' - alias: 'Adaptive lighting: notify manual_control' mode: parallel max: 20 triggers: - trigger: event event_type: adaptive_lighting.manual_control variables: light: '{{ trigger.event.data.entity_id }}' conditions: '{{ ''hall'' not in light and ''stairs'' not in light }}' actions: - action: system_log.write data: message: '{{ light }} is manually controlled' level: error logger: yolo.yolo - action: notify.iphone_bas data: title: 'Adaptive Ligthing: manual_control' message: '{{ light }} is now ''manually controlled'', context={{ trigger.event.context }}' - alias: 'Alarm clock: wake up with Spotify and light' triggers: trigger: template value_template: '{{ states("sensor.time")[0:5] == states("sensor.ten_minutes_before_alarm") }} ' conditions: condition: state entity_id: input_boolean.alarm_clock state: 'on' actions: - action: input_boolean.turn_off entity_id: input_boolean.alarm_clock - action: input_boolean.turn_on entity_id: input_boolean.wake_up_with_spotify - action: input_boolean.turn_on entity_id: input_boolean.wake_up_light - action: input_select.select_option entity_id: input_select.sleep_mode data: option: 'off' - alias: 'Apple Watch: Play or Pause the TV' triggers: trigger: event event_type: ios.action_fired event_data: actionName: Play TV conditions: condition: state entity_id: media_player.tv state: 'on' actions: action: media_player.media_play_pause target: entity_id: 'media_player.{{ ''xbox'' if is_state_attr(''media_player.tv'', ''source'', ''XBOX'') else ''tv''}} ' - alias: 'Apple Watch: minimal lights bedroom' triggers: trigger: event event_type: ios.action_fired event_data: actionName: Minimal lights bedroom actions: action: light.turn_on data: entity_id: - light.philips_go - light.bed_led brightness: 1 color_name: red - alias: 'Apple Watch: fix TV sound' triggers: trigger: event event_type: ios.action_fired event_data: actionName: Fix TV sound actions: action: script.fix_sound - alias: 'Apple Watch: Go to sleep' triggers: trigger: event event_type: ios.action_fired event_data: actionName: Go to sleep actions: action: script.going_to_sleep - alias: 'Apple Watch: set sleep mode' mode: parallel triggers: trigger: event event_type: ios.action_fired event_data: actionName: Set sleep mode actions: - variables: iphone: notify.mobile_app_{{ trigger.event.data.sourceDeviceName.replace('-', '_') }} - action: '{{ iphone }}' data: message: 'Apple Watch: set sleep mode.' data: actions: - action: SLEEP_OFF title: 'Off' - action: SLEEP_HALF title: Half - action: SLEEP_TOTAL title: Total - wait_for_trigger: - trigger: event event_type: mobile_app_notification_action event_data: action: SLEEP_OFF - trigger: event event_type: mobile_app_notification_action event_data: action: SLEEP_HALF - trigger: event event_type: mobile_app_notification_action event_data: action: SLEEP_TOTAL timeout: 00:00:20 continue_on_timeout: false - variables: event: '{{ wait.trigger.event.data.action.lower().split(''_'')[1] }}' - action: input_select.select_option data: entity_id: input_select.sleep_mode option: '{{ event }}' - alias: 'Apple Watch: set lights' mode: parallel triggers: trigger: event event_type: ios.action_fired event_data: actionName: Set lights actions: - variables: iphone: notify.mobile_app_{{ trigger.event.data.sourceDeviceName.replace('-', '_') }} - action: '{{ iphone }}' data: message: 'Apple Watch: set lights' data: actions: - action: SET_LIGHTS_ALL title: All - action: SET_LIGHTS_BEDROOM title: Bedroom - action: SET_LIGHTS_LIVING_ROOM title: Living room - action: SET_LIGHTS_BATHROOM title: Bathroom - action: SET_LIGHTS_HALL title: Hall - action: SET_LIGHTS_TOILET title: Toilet - action: SET_LIGHTS_KITCHEN title: Kitchen - wait_for_trigger: - trigger: event event_type: mobile_app_notification_action event_data: action: SET_LIGHTS_ALL - trigger: event event_type: mobile_app_notification_action event_data: action: SET_LIGHTS_BEDROOM - trigger: event event_type: mobile_app_notification_action event_data: action: SET_LIGHTS_LIVING_ROOM - trigger: event event_type: mobile_app_notification_action event_data: action: SET_LIGHTS_BATHROOM - trigger: event event_type: mobile_app_notification_action event_data: action: SET_LIGHTS_HALL - trigger: event event_type: mobile_app_notification_action event_data: action: SET_LIGHTS_TOILET - trigger: event event_type: mobile_app_notification_action event_data: action: SET_LIGHTS_KITCHEN timeout: 00:00:20 continue_on_timeout: false - variables: light: "{{\n {'SET_LIGHTS_ALL': 'all',\n 'SET_LIGHTS_BEDROOM': 'light.bedroom_lights',\n\ \ 'SET_LIGHTS_LIVING_ROOM': 'light.living_room_lights',\n 'SET_LIGHTS_BATHROOM':\ \ 'light.bathroom_ceiling',\n 'SET_LIGHTS_HALL': 'light.hall_lights,light.stairs_lights',\n\ \ 'SET_LIGHTS_TOILET': 'light.toilet',\n 'SET_LIGHTS_KITCHEN': 'light.kitchen_lights',\n\ \ }[wait.trigger.event.data.action] }}\n" - action: '{{ iphone }}' data: message: 'Apple Watch: choose option' data: actions: - action: LIGHTS_OFF title: 'Off' - action: LIGHTS_ON title: 'On' - action: LIGHTS_FIFTY title: 50% - action: LIGHTS_HUNDRED title: 100% - action: LIGHTS_ONE title: 1% - action: LIGHTS_WHITE title: White lights - action: LIGHTS_COZY title: Cozy lights - wait_for_trigger: - trigger: event event_type: mobile_app_notification_action event_data: action: LIGHTS_OFF - trigger: event event_type: mobile_app_notification_action event_data: action: LIGHTS_ON - trigger: event event_type: mobile_app_notification_action event_data: action: LIGHTS_FIFTY - trigger: event event_type: mobile_app_notification_action event_data: action: LIGHTS_HUNDRED - trigger: event event_type: mobile_app_notification_action event_data: action: LIGHTS_ONE - trigger: event event_type: mobile_app_notification_action event_data: action: LIGHTS_WHITE - trigger: event event_type: mobile_app_notification_action event_data: action: LIGHTS_COZY timeout: 00:00:20 continue_on_timeout: false - variables: option: '{{ wait.trigger.event.data.action }}' - choose: - conditions: '{{ option == ''LIGHTS_OFF'' }}' sequence: action: light.turn_off data: entity_id: '{{ light }}' - conditions: '{{ option == ''LIGHTS_ON'' }}' sequence: action: script.turn_on_lights data: entity_id: '{{ light }}' - conditions: '{{ option == ''LIGHTS_FIFTY'' }}' sequence: action: light.turn_on data: entity_id: '{{ light }}' brightness_pct: 50 - conditions: '{{ option == ''LIGHTS_HUNDRED'' }}' sequence: action: light.turn_on data: entity_id: '{{ light }}' brightness_pct: 100 - conditions: '{{ option == ''LIGHTS_ONE'' }}' sequence: action: light.turn_on data: entity_id: '{{ light }}' brightness_pct: 1 - conditions: '{{ option == ''LIGHTS_WHITE'' and light == ''light.living_room_lights''}}' sequence: action: script.white_lights_living_room - conditions: '{{ option == ''LIGHTS_WHITE'' and light == ''light.bedroom_lights''}}' sequence: action: script.white_lights_living_room - conditions: '{{ option == ''LIGHTS_COZY'' and light == ''light.living_room_lights''}}' sequence: action: script.cozy_lights_living_room - conditions: '{{ option == ''LIGHTS_COZY'' and light == ''light.bedroom_lights''}}' sequence: action: script.cozy_lights_bedroom - alias: 'Apple Watch: temperature report' mode: parallel triggers: trigger: event event_type: ios.action_fired event_data: actionName: Temperature report actions: - variables: iphone: notify.mobile_app_{{ trigger.event.data.sourceDeviceName.replace('-', '_') }} - action: '{{ iphone }}' data: title: Temperature message: 'Bedroom: {{ states(''sensor.temperature_bedroom'') }}°C Living room: {{ states(''sensor.temperature_living_room'') }}°C Hall: {{ states(''sensor.temperature_hall'') }}°C Thermostat: {{ state_attr(''climate.thermostat'', ''temperature'') }}°C Outside: {{ state_attr(''weather.huis'', ''temperature'') }}°C and it''s {{ states(''weather.huis'') }} ' - alias: 'Apple Watch: portfolio value' mode: parallel triggers: trigger: event event_type: ios.action_fired event_data: actionName: Portfolio value actions: - variables: iphone: notify.iphone_bas - action: '{{ iphone }}' data: title: Portfolio value message: '€{{ states(''sensor.portfolio_value'') }} ' - alias: 'Apple Watch: send vacuum cleaner' mode: parallel triggers: trigger: event event_type: ios.action_fired event_data: actionName: Vacuum actions: - variables: iphone: notify.mobile_app_{{ trigger.event.data.sourceDeviceName.replace('-', '_') }} - action: '{{ iphone }}' data: message: 'Apple Watch: vacuum' data: actions: - action: VACUUM_LIVING_ROOM title: Living room - action: VACUUM_BEDROOM title: Bedroom - action: VACUUM_OFFICE title: Office - action: VACUUM_HALL title: Hall - action: VACUUM_KITCHEN title: Kitchen - action: VACUUM_ALL title: All - action: VACUUM_STOP title: Stop and return - wait_for_trigger: - trigger: event event_type: mobile_app_notification_action event_data: action: VACUUM_LIVING_ROOM - trigger: event event_type: mobile_app_notification_action event_data: action: VACUUM_BEDROOM - trigger: event event_type: mobile_app_notification_action event_data: action: VACUUM_OFFICE - trigger: event event_type: mobile_app_notification_action event_data: action: VACUUM_HALL - trigger: event event_type: mobile_app_notification_action event_data: action: VACUUM_KITCHEN - trigger: event event_type: mobile_app_notification_action event_data: action: VACUUM_ALL - trigger: event event_type: mobile_app_notification_action event_data: action: VACUUM_STOP timeout: 00:00:20 continue_on_timeout: false - variables: location: '{{ wait.trigger.event.data.action.lower().split(''vacuum_'')[1] }}' - action: script.vacuum_command data: option: '{{ location }}' - alias: 'Apple Watch: movie time' triggers: trigger: event event_type: ios.action_fired event_data: actionName: Movie time actions: - action: light.turn_on data: entity_id: - light.living_room_lights brightness: 5 color_name: red - action: light.turn_off data: entity_id: - light.marble - action: light.turn_on data: entity_id: - light.tv_led brightness: 20 - alias: 'Apple Watch: reset adaptive lighting' triggers: trigger: event event_type: ios.action_fired event_data: actionName: Reset adaptive lighting actions: action: script.reset_adaptive_lighting - alias: 'Apple Watch: set temperature' mode: parallel triggers: trigger: event event_type: ios.action_fired event_data: actionName: Set temperature actions: - variables: iphone: notify.mobile_app_{{ trigger.event.data.sourceDeviceName.replace('-', '_') }} - action: '{{ iphone }}' data: message: 'Apple Watch: set temperature' data: actions: - action: T15 title: '15' - action: T16 title: '16' - action: T17 title: '17' - action: T18 title: '18' - action: T19 title: '19' - action: T20 title: '20' - action: T21 title: '21' - wait_for_trigger: - trigger: event event_type: mobile_app_notification_action event_data: action: T15 - trigger: event event_type: mobile_app_notification_action event_data: action: T16 - trigger: event event_type: mobile_app_notification_action event_data: action: T17 - trigger: event event_type: mobile_app_notification_action event_data: action: T18 - trigger: event event_type: mobile_app_notification_action event_data: action: T19 - trigger: event event_type: mobile_app_notification_action event_data: action: T20 - trigger: event event_type: mobile_app_notification_action event_data: action: T21 timeout: 00:00:20 continue_on_timeout: false - variables: temperature: '{{ wait.trigger.event.data.action.split(''T'')[1] | int }}' - action: climate.set_temperature data: entity_id: climate.thermostat temperature: '{{ temperature }}' - alias: 'Apple Watch: where is other person?' mode: parallel triggers: trigger: event event_type: ios.action_fired event_data: actionName: Where is variables: phone: "{% if trigger.event.data.sourceDeviceName == 'basnijholt-iphone' %}\n\ \ basnijholt\n{% else %}\n marcella\n{% endif %}\n" other_person: '{% if phone == ''basnijholt'' %}Marcella{% else %}Bas{% endif %}' device_tracker: device_tracker.{{ other_person }}_iphone actions: action: notify.mobile_app_{{ phone }}_iphone data: message: '{{ other_person }} is {{ distance(''device_tracker.basnijholt_iphone'', ''device_tracker.marcella_iphone'') | round(2) }} km away' data: push: category: MAP action_data: latitude: '{{ state_attr(device_tracker, ''latitude'') }}' longitude: '{{ state_attr(device_tracker, ''longitude'') }}' - alias: 'Arriving: switch music from iPhone to speakers if no one is home' triggers: trigger: state entity_id: binary_sensor.openclose_front_door from: 'off' to: 'on' conditions: - condition: state entity_id: person.marcella state: not_home - condition: state entity_id: input_boolean.guest_mode state: 'off' - '{{ is_state_attr(''media_player.spotify'', ''source'', ''basnijholt-iphone'') }}' - '{{ is_state(''media_player.spotify'', ''playing'') }}' actions: - action: notify.iphone_bas data: title: Arriving message: Switched music from phone to speakers - action: media_player.turn_on entity_id: media_player.kef_ls50 - action: media_player.select_source entity_id: media_player.kef_ls50 data: source: Spotify - action: media_player.select_source entity_id: media_player.spotify data: source: KEF LS50 - alias: 'Bike: started charging' triggers: trigger: state entity_id: switch.bike_charger to: 'on' from: 'off' actions: - action: input_datetime.set_datetime data: entity_id: input_datetime.bike_charger_on timestamp: '{{ now().timestamp() }}' - action: input_datetime.set_datetime data: entity_id: input_datetime.bike_charger_off timestamp: '{{ now().timestamp() + 3600 * 6 }}' - alias: 'Bike: stop charging' triggers: trigger: time_pattern minutes: /1 conditions: condition: template value_template: '{{ states(''sensor.time'') == states(''input_datetime.bike_charger_off'')[0:5] }}' actions: action: switch.turn_off data: entity_id: switch.bike_charger - alias: 'Climate: turn on the heating 30 min before waking up' triggers: trigger: template value_template: '{{ states("sensor.time")[0:5] == states("sensor.half_hour_before_alarm") }} ' conditions: condition: state entity_id: - input_boolean.alarm_clock - input_boolean.automatic_temperature state: 'on' actions: action: script.set_high_temperature - alias: 'Climate: turn on the heating when going home' triggers: trigger: numeric_state entity_id: sensor.home_nearest_distance below: 6 above: 1 conditions: - condition: state entity_id: input_boolean.automatic_temperature state: 'on' - condition: time after: '16:00:00' before: '22:00:00' - '{{ is_state(''sensor.home_nearest_direction_of_travel'', ''towards'') }}' - '{{ not is_state_attr(''climate.thermostat'', ''temperature'', states(''input_number.temperature_high'')) }}' - condition: state entity_id: binary_sensor.no_one_home state: 'on' actions: - action: script.set_high_temperature - action: notify.all_iphones data: title: Climate message: Automatically turned on the heating 🥵℃ - alias: 'Climate: turn off the heating at 22:00' triggers: trigger: time at: '22:00' conditions: - condition: state entity_id: input_boolean.automatic_temperature state: 'on' - condition: state entity_id: binary_sensor.no_one_home state: 'off' - '{{ not is_state_attr(''climate.thermostat'', ''temperature'', states(''input_number.temperature_low'')|float(0)) }}' actions: - action: script.set_low_temperature - action: notify.all_iphones data: message: Turned off the heating 🥶, click to turn it on again? data: actions: - action: TURN_ON_HEATING title: Turn on heating activationMode: background authenticationRequired: true destructive: true - wait_for_trigger: trigger: event event_type: mobile_app_notification_action event_data: action: TURN_ON_HEATING timeout: 00:00:20 continue_on_timeout: false - action: script.set_high_temperature - alias: 'Climate: set outside temperature every hour' triggers: trigger: time_pattern hours: /1 actions: action: mqtt.publish data: topic: actions/otmonitor/outside payload: '{{ state_attr("weather.huis", "temperature") }} ' - alias: 'Climate: warning when heating on and living room door open' triggers: trigger: state entity_id: binary_sensor.openclose_bedroom to: 'on' for: 00:05:00 conditions: '{{ state_attr(''climate.thermostat'', ''temperature'') >= 18 }}' actions: - repeat: while: - condition: state entity_id: binary_sensor.openclose_bedroom state: 'on' - condition: template value_template: '{{ repeat.index <= 6 }}' sequence: - action: notify.all data: title: Climate message: 'The living room door is open and the heating is on! ⚠️ Warning #{{ repeat.index }}!' - delay: 00:05:00 - condition: state entity_id: binary_sensor.openclose_bedroom state: 'on' - action: notify.all data: title: Climate message: Turning off the heating! - action: climate.set_temperature entity_id: climate.thermostat data: temperature: '{{ states("input_number.temperature_low") }} ' - alias: 'Climate: set temperature setpoint to 50 °C' triggers: trigger: time_pattern hours: /2 actions: action: mqtt.publish data: topic: actions/otmonitor/maxdhwsetpt payload: '50' - alias: 'Climate: automatically turn off spaceheater when no-one is in the guest room' triggers: - trigger: time_pattern minutes: /10 - trigger: state entity_id: binary_sensor.activity_in_guest_room to: 'off' conditions: condition: state entity_id: binary_sensor.activity_in_guest_room state: 'off' actions: action: switch.turn_off entity_id: switch.space_heater - alias: 'Control switches: living room Philips Hue dimmer switch' mode: parallel triggers: trigger: mqtt topic: zigbee2mqtt/Dimmer Switch (Living room) variables: action: '{{ trigger.payload_json.action }}' actions: choose: - conditions: '{{ action == ''off_press'' }}' sequence: action: script.next_colors data: input_select: input_select.last_script_living_room - conditions: - '{{ action == ''up_press'' }}' - condition: state entity_id: light.living_room_lights state: 'on' sequence: - action: script.white_lights_living_room - action: light.turn_on entity_id: light.living_room_lights data: brightness: '255' - conditions: '{{ action == ''on_press'' }}' sequence: action: script.increase_brightness data: group: light.living_room_lights - conditions: - '{{ action == ''up_press'' }}' - condition: state entity_id: light.living_room_lights state: 'off' sequence: - action: light.turn_on entity_id: light.living_room_lights - conditions: - '{{ action == ''down_press'' }}' - condition: state entity_id: light.living_room_lights state: 'on' sequence: - action: light.turn_off entity_id: light.living_room_lights - conditions: - '{{ action == ''up_hold'' }}' - '{{ trigger.payload_json.action_duration > 2 }}' sequence: - action: script.reset_adaptive_lighting - alias: 'Control switches: bedroom Philips Hue dimmer switch' mode: parallel triggers: trigger: mqtt topic: zigbee2mqtt/Dimmer Switch (Bedroom) variables: action: '{{ trigger.payload_json.action }}' actions: choose: - conditions: '{{ action == ''off_press'' }}' sequence: action: script.next_colors data: input_select: input_select.last_script_bedroom - conditions: - '{{ action == ''up_press'' }}' - condition: state entity_id: light.bedroom_lights state: 'on' sequence: - action: script.white_lights_bedroom - action: light.turn_on entity_id: light.bedroom_lights data: brightness: '255' - conditions: '{{ action == ''on_press'' }}' sequence: action: script.increase_brightness data: group: light.bedroom_lights - conditions: - '{{ action == ''up_press'' }}' - condition: state entity_id: light.bedroom_lights state: 'off' sequence: - action: light.turn_on entity_id: light.bedroom_lights - conditions: - '{{ action == ''down_press'' }}' - condition: state entity_id: light.bedroom_lights state: 'on' sequence: - action: light.turn_off entity_id: light.bedroom_lights - conditions: - '{{ action == ''up_hold'' }}' - '{{ trigger.payload_json.action_duration > 2 }}' sequence: - action: script.reset_adaptive_lighting - alias: 'Control switches: bedroom IKEA dimmer switch' mode: parallel triggers: - trigger: mqtt topic: zigbee2mqtt/IKEA Remote (Bedroom) - trigger: mqtt topic: zigbee2mqtt/IKEA Remote (Bedroom Marcella) variables: action: '{{ trigger.payload_json.action }}' personal_light: "{% if trigger.topic == 'zigbee2mqtt/IKEA Remote (Bedroom)' %}\n\ \ light.bed_led\n{% elif trigger.topic == 'zigbee2mqtt/IKEA Remote (Bedroom\ \ Marcella)' %}\n light.philips_go\n{% endif %}" actions: choose: - conditions: - '{{ action == ''brightness_move_up'' }}' - condition: state entity_id: light.bedroom_lights state: 'on' sequence: - action: script.white_lights_bedroom - action: light.turn_on entity_id: light.bedroom_lights data: brightness: '255' kelvin: 5500 - conditions: - '{{ action == ''on'' }}' - condition: state entity_id: light.bedroom_lights state: 'on' sequence: action: script.increase_brightness data: group: light.bedroom_lights - conditions: - '{{ action == ''on'' }}' - condition: state entity_id: light.bedroom_lights state: 'off' sequence: - action: light.turn_on entity_id: light.bedroom_lights - conditions: - '{{ action == ''off'' }}' - condition: state entity_id: light.bedroom_lights state: 'on' sequence: - action: light.turn_off entity_id: light.bedroom_lights - conditions: '{{ action == ''arrow_left_click'' }}' sequence: action: script.next_colors data: input_select: input_select.last_script_bedroom - conditions: - '{{ action == ''arrow_right_click'' }}' - '{{ is_state(personal_light, ''off'') }}' sequence: action: light.toggle data: entity_id: '{{ personal_light }}' - conditions: - '{{ action == ''arrow_right_click'' }}' - '{{ is_state(personal_light, ''on'') }}' sequence: action: script.increase_brightness data: group: '{{ personal_light }}' - conditions: - '{{ action == ''brightness_move_down'' }}' - '{{ is_state(''input_boolean.guest_mode'', ''off'') }}' sequence: - action: input_select.select_option data: entity_id: input_select.sleep_mode option: total - action: script.turn_off_everything - conditions: - '{{ action == ''brightness_move_down'' }}' - '{{ is_state(''input_boolean.guest_mode'', ''on'') }}' sequence: - action: input_select.select_option data: entity_id: input_select.sleep_mode option: total - action: light.turn_off data: entity_id: - light.bedroom_lights - light.baby_room_lights - alias: 'Control switches: living room Aqara Wireless Mini Switch' mode: parallel triggers: trigger: event event_type: deconz_event event_data: id: smart_switch_living_room actions: choose: - conditions: '{{ trigger.event.data.event == 1004 }}' sequence: action: script.next_colors data: input_select: input_select.last_script_living_room - conditions: '{{ trigger.event.data.event == 1002 }}' sequence: action: script.increase_brightness data: group: light.living_room_lights - conditions: - '{{ trigger.event.data.event == 1007 }}' - condition: state entity_id: light.living_room_lights state: 'on' sequence: - action: light.turn_on data: flash: short entity_id: light.cabinet_led - action: media_player.turn_off entity_id: media_player.tv - wait_template: '{{ is_state(''media_player.tv'', ''off'') }}' timeout: 00:00:30 - action: media_player.turn_off entity_id: media_player.kef_ls50 - action: light.turn_off entity_id: light.living_room_lights data: transition: 30 - conditions: '{{ trigger.event.data.event == 1001 }}' sequence: action: script.fix_sound - alias: 'Control switches: bedroom Aqara Wireless Mini Switch' mode: parallel triggers: - trigger: event event_type: deconz_event event_data: id: smart_switch_bedroom_bas - trigger: event event_type: deconz_event event_data: id: smart_switch_bedroom_marcella actions: choose: - conditions: '{{ trigger.event.data.event == 1004 }}' sequence: action: script.next_colors data: input_select: input_select.last_script_bedroom - conditions: '{{ trigger.event.data.event == 1002 }}' sequence: action: script.increase_brightness data: group: light.bedroom_lights - conditions: '{{ trigger.event.data.event == 1001 }}' sequence: action: light.turn_off entity_id: - light.hall_lights - light.bedroom_lights - light.bathroom_ceiling - light.stairs_lights - conditions: '{{ trigger.event.data.event == 1007 }}' sequence: choose: - conditions: '{% set h, m = states("sensor.ten_minutes_before_alarm").split(":") %} {% set t_diff = as_timestamp(now()) - as_timestamp(now().replace(hour=h|int(0), minute=m|int(0))) %} {% set is_near_alarm = (t_diff|abs) < 1800 %} {% set is_morning = now().replace(hour=6, minute=0) < now() < now().replace(hour=12, minute=0) %} {{ is_near_alarm or is_morning }} ' sequence: action: light.turn_off entity_id: all - conditions: condition: state entity_id: input_select.sleep_mode state: 'off' sequence: - action: light.turn_off entity_id: - light.hall_lights - light.bedroom_lights - light.bathroom_ceiling - light.stairs_lights - action: input_select.select_option entity_id: input_select.sleep_mode data: option: half - conditions: condition: state entity_id: input_select.sleep_mode state: half sequence: - action: script.turn_off_everything - action: input_select.select_option entity_id: input_select.sleep_mode data: option: total - conditions: condition: state entity_id: input_select.sleep_mode state: total sequence: action: light.turn_off entity_id: all - alias: 'Control switches: bathroom Aqara Wireless Mini Switch' mode: parallel triggers: trigger: event event_type: deconz_event event_data: id: smart_switch_bathroom actions: choose: - conditions: '{{ trigger.event.data.event == 1002 }}' sequence: action: light.toggle entity_id: light.bathroom_lights - conditions: '{{ trigger.event.data.event == 1004 }}' sequence: - action: light.turn_on data: entity_id: light.living_room_lights flash: short - alias: 'Control switches: door Aqara Wireless Mini Switch' mode: parallel triggers: trigger: event event_type: deconz_event event_data: id: smart_switch_door actions: choose: - conditions: '{{ trigger.event.data.event == 1002 }}' sequence: - action: light.turn_on data: entity_id: light.living_room_lights flash: short - action: script.turn_off_everything_non_automatic - action: script.set_low_temperature - if: '{{ is_state_attr(''media_player.spotify'', ''source'', ''KEF LS50'') and is_state(''media_player.spotify'', ''playing'') }}' then: - action: media_player.media_pause entity_id: media_player.spotify - conditions: '{{ trigger.event.data.event == 1004 }}' sequence: - action: light.turn_on data: flash: short entity_id: light.ceiling_kitchen - action: script.turn_on data: entity_id: light.living_room_lights - action: script.arriving - action: script.start_spotify data: source: KEF LS50 id: playlist:{{ states("sensor.favorite_playlist_of_nearest_person") }} volume: 0.25 - alias: 'Control switches: guest room IKEA Switch' mode: parallel triggers: trigger: mqtt topic: zigbee2mqtt/IKEA Switch (Guest room) variables: action: '{{ trigger.payload_json.action }}' actions: choose: - conditions: '{{ action == ''on'' }}' sequence: action: light.turn_on entity_id: light.guest_room_lights - conditions: '{{ action == ''off'' }}' sequence: action: light.turn_off entity_id: light.guest_room_lights - alias: 'Control switches: Guest Room Light' mode: parallel triggers: trigger: mqtt topic: zigbee2mqtt/Smart Switch (Guest Room) variables: action: '{{ trigger.payload_json.action }}' actions: choose: - conditions: '{{ action == ''single'' }}' sequence: action: light.toggle data: entity_id: light.guest_room_lights - conditions: '{{ action == ''double'' }}' sequence: action: switch.toggle entity_id: switch.adaptive_lighting_sleep_mode_guest_room - alias: 'Control switches: Guest Room Space heater' mode: parallel triggers: trigger: mqtt topic: zigbee2mqtt/Smart Switch (Desk) variables: action: '{{ trigger.payload_json.action }}' actions: choose: - conditions: '{{ action == ''single'' }}' sequence: action: switch.toggle data: entity_id: switch.space_heater - alias: 'Control switches: Baby Room Light' mode: parallel triggers: trigger: mqtt topic: zigbee2mqtt/Smart Switch (Baby Room) variables: action: '{{ trigger.payload_json.action }}' actions: choose: - conditions: '{{ action == ''single'' }}' sequence: action: light.toggle data: entity_id: - light.baby_room_lights - conditions: '{{ action == ''double'' }}' sequence: action: switch.toggle entity_id: switch.adaptive_lighting_sleep_mode_baby_room - alias: 'Control switches: Mid Room Changing Table Light' mode: parallel triggers: trigger: mqtt topic: zigbee2mqtt/Smart Switch (Mid Room) variables: action: '{{ trigger.payload_json.action }}' actions: choose: - conditions: '{{ action == ''single'' }}' sequence: action: light.toggle data: entity_id: light.mid_room brightness_pct: 100 color_temp_kelvin: 2200 - conditions: '{{ action == ''double'' }}' sequence: action: script.increase_brightness data: group: light.mid_room - conditions: '{{ action == ''hold'' }}' sequence: action: script.next_colors data: input_select: input_select.last_script_living_room - alias: 'Cube: perform operation' mode: parallel triggers: trigger: event event_type: deconz_event event_data: id: mi_magic_cube variables: event: '{{ trigger.event.data.event }}' conditions: '{{ (event | string)[1:-1] == ''00'' }}' actions: choose: - conditions: '{% set event = event | string %} {% set correct_start = event[:3] in ("100", "200", "300") %} {% set first_last_different = event[0] != event[-1] %} {% set last_is_zero = event[-1] == 0 %} {{ correct_start and (first_last_different or last_is_zero) }} ' sequence: - action: input_select.select_option entity_id: input_select.cube_mode data: option: '{% set event = event | string %} {{ {"100": "Volume", "200": "Hue", "300": "Brightness"}[event[:3]] }} ' - condition: state entity_id: media_player.tv state: 'on' - action: notify.tv data: message: 'Cube set to {{ states("input_select.cube_mode") }} ' - conditions: - '{{ event == 7007 }}' - '{{ is_state_attr(''media_player.spotify'', ''source'', ''KEF LS50'') }}' sequence: - action: media_player.shuffle_set entity_id: media_player.spotify data: shuffle: true - action: media_player.media_next_track entity_id: media_player.spotify - conditions: - '{{ event in (1001, 2002, 3003, 4004, 5005, 6006) }}' - '{{ is_state_attr(''media_player.spotify'', ''source'', ''KEF LS50'') }}' sequence: action: media_player.media_play_pause entity_id: media_player.spotify - conditions: '{{ event == 7008 }}' sequence: action: script.start_spotify_playlist_of_nearest_person data: source: KEF LS50 entity_id: media_player.kef_ls50 - alias: 'Cube: rotate the cube' triggers: trigger: event event_type: deconz_event event_data: id: mi_magic_cube variables: event: '{{ trigger.event.data.event }}' conditions: '{{ (event | string)[1:-1] != ''00'' or event < 0 }}' actions: choose: - conditions: condition: state entity_id: input_select.cube_mode state: Hue sequence: - variables: hue_sat: '{{ state_attr(''light.sphere'', ''hs_color'') or [30, 56] }}' - action: light.turn_on entity_id: light.living_room_lights data: hs_color: - '{% set delta = event / 200 %} {% set new_hue = [([0, (hue_sat[0] + delta)]|max), 360]|min %} {{ new_hue|round(3) }} ' - '{{ hue_sat[1] }}' - conditions: condition: state entity_id: input_select.cube_mode state: Brightness sequence: action: light.turn_on entity_id: light.living_room_lights data: brightness: '{% set brightness = state_attr(''light.sphere'', ''brightness'') %} {% set delta = event / 450 %} {% set new_brightness = [([0, (brightness + delta)]|max), 255]|min %} {{ new_brightness|int(0) }} ' - conditions: condition: state entity_id: input_select.cube_mode state: Volume sequence: - action: media_player.volume_set entity_id: media_player.kef_ls50 data: volume_level: '{% set max_change = 0.15 %} {% set dV = [event / 100 / 900, max_change] | min %} {{ (states.media_player.kef_ls50.attributes.volume_level + dV)|round(2) }} ' - condition: state entity_id: media_player.tv state: 'on' - action: notify.tv data: message: 'Volume set to {{ state_attr("media_player.kef_ls50", "volume_level") }} ' - alias: 'Doorbell: click the button' initial_state: true triggers: trigger: event event_type: deconz_event event_data: id: smart_switch_doorbell event: 1002 actions: - action: light.turn_on data: flash: short entity_id: all - action: notify.all_iphones data: title: Doorbell message: Someone in front of the door! - condition: state entity_id: media_player.tv state: 'on' - action: notify.tv data: message: Someone in front of the door! - alias: 'Frontend: turn on dark mode' triggers: - trigger: time at: '20:00' - trigger: sun event: sunset conditions: '{{ is_state(''input_boolean.dark_mode'', ''off'') }}' actions: entity_id: input_boolean.dark_mode action: input_boolean.turn_on - alias: 'Frontend: turn on light mode' triggers: - trigger: time at: 06:00 - trigger: sun event: sunrise conditions: '{{ is_state(''input_boolean.dark_mode'', ''on'') }}' actions: entity_id: input_boolean.dark_mode action: input_boolean.turn_off - alias: 'Frontend: change theme' triggers: - trigger: state entity_id: input_select.theme - trigger: state entity_id: input_boolean.dark_mode - trigger: state entity_id: input_boolean.theme_alternative - trigger: homeassistant event: start actions: action: frontend.set_theme data: name: '{% set which = "dark" if is_state("input_boolean.dark_mode", "on") else "light" -%} {% set name = states("input_select.theme") -%} {% set suffix = "-alternative" if is_state("input_boolean.theme_alternative", "on") else "" -%} ios-{{ which }}-mode-{{ name }}{{ suffix }} ' - alias: 'Leaving: automatically turn off everything' initial_state: 'on' triggers: - trigger: state entity_id: binary_sensor.someone_in_the_house_in_last_hour from: 'on' to: 'off' for: 00:01:00 - trigger: time_pattern hours: /1 conditions: - condition: state entity_id: - binary_sensor.no_one_home - binary_sensor.anything_on state: 'on' - condition: state entity_id: - binary_sensor.someone_in_the_house_in_last_hour - input_boolean.guest_mode state: 'off' actions: - action: script.leaving - action: notify.all_iphones data: title: Leaving message: Everything automatically turned off! - alias: 'Leaving: ask to turn off everything' initial_state: 'on' triggers: - trigger: state entity_id: person.bas from: home - trigger: state entity_id: person.marcella from: home conditions: - condition: state entity_id: - binary_sensor.no_one_home - binary_sensor.anything_on state: 'on' - condition: state entity_id: input_boolean.guest_mode state: 'off' actions: - delay: 00:05:00 - condition: state entity_id: binary_sensor.no_one_home state: 'on' - action: notify.all_iphones data: message: No one is home, turn off everything? data: actions: - action: TURN_OFF_EVERYTHING title: Turn off everything activationMode: background authenticationRequired: false destructive: true - alias: 'Leaving: turn off everything after notification' triggers: trigger: event event_type: mobile_app_notification_action event_data: action: TURN_OFF_EVERYTHING actions: action: script.leaving - alias: 'Leaving: downstairs Aqara Wireless Mini Switch' triggers: trigger: event event_type: deconz_event event_data: id: smart_switch_door event: 1002 actions: - wait_for_trigger: trigger: state entity_id: binary_sensor.openclose_front_door from: 'on' to: 'off' timeout: 00:01:00 continue_on_timeout: false - action: script.turn_off_everything - action: notify.all_iphones data: title: Bye 👋 message: See you soon! - alias: 'Light: turn on living room' triggers: trigger: state entity_id: binary_sensor.activity_in_living_room to: 'on' conditions: condition: state entity_id: input_boolean.guest_mode state: 'off' actions: action: light.turn_on entity_id: light.living_room_lights - alias: 'Light: turn off living room' triggers: - trigger: state entity_id: binary_sensor.activity_in_living_room to: 'off' - trigger: state entity_id: input_select.sleep_mode from: total conditions: condition: state entity_id: input_boolean.guest_mode state: 'off' actions: action: light.turn_off entity_id: light.living_room_lights - alias: 'Light: turn on Chrismas tree' triggers: - trigger: state entity_id: input_select.sleep_mode to: - 'off' - half - trigger: state entity_id: binary_sensor.someone_in_the_house_in_last_hour to: 'on' conditions: condition: state entity_id: binary_sensor.someone_in_the_house_in_last_hour state: 'on' actions: action: switch.turn_on entity_id: switch.christmas_tree - alias: 'Light: turn off Chrismas tree' triggers: - trigger: state entity_id: input_select.sleep_mode to: total - trigger: state entity_id: binary_sensor.someone_in_the_house_in_last_hour to: 'off' actions: action: switch.turn_off entity_id: switch.christmas_tree - alias: 'Light: toggle dinner area lights' triggers: trigger: state entity_id: binary_sensor.activity_in_dinner_area conditions: - condition: state entity_id: input_boolean.automatic_dinner_area_light state: 'on' - condition: state entity_id: input_select.sleep_mode state: 'off' - condition: state entity_id: input_boolean.guest_mode state: 'off' actions: action: light.turn_{{ trigger.to_state.state }} data: entity_id: light.dinner_area - alias: 'Light: turn off automatic dinner area lights when turning off lights after 18:00' conditions: - condition: state entity_id: input_boolean.automatic_dinner_area_light state: 'on' - condition: time after: '18:00:00' triggers: trigger: state entity_id: light.dinner_area to: 'off' actions: action: input_boolean.turn_off entity_id: input_boolean.automatic_dinner_area_light - alias: 'Light: reset automatic dinner area lights at 06:00' triggers: trigger: time at: 06:00:00 actions: action: input_boolean.turn_on entity_id: input_boolean.automatic_dinner_area_light - alias: 'Light: turn on kitchen counter if sleep mode is off' triggers: trigger: state entity_id: binary_sensor.activity_in_kitchen to: 'on' conditions: condition: state entity_id: input_select.sleep_mode state: - 'off' - half actions: action: light.turn_on entity_id: light.kitchen_counter - alias: 'Light: turn off kitchen counter' triggers: trigger: state entity_id: binary_sensor.activity_in_kitchen to: 'off' actions: action: light.turn_off entity_id: light.kitchen_counter - alias: 'Light: reboot kitchen ceiling Shelly' triggers: trigger: time at: 05:00:00 actions: action: shell_command.reboot_kitchen_ceiling - alias: 'Light: turn on bathroom' triggers: trigger: state entity_id: binary_sensor.activity_in_bathroom to: 'on' conditions: '{{ states(''input_select.sleep_mode'') != ''total'' }}' actions: action: light.turn_on data: entity_id: light.bathroom_lights transition: 1 - alias: 'Light: turn off bathroom' triggers: trigger: state entity_id: binary_sensor.activity_in_bathroom to: 'off' actions: action: light.turn_off data: entity_id: light.bathroom_lights transition: 1 - alias: 'Light: turn on hall' mode: parallel triggers: - trigger: state entity_id: binary_sensor.activity_in_hall from: 'off' to: 'on' - trigger: state entity_id: binary_sensor.openclose_front_door from: 'off' to: 'on' variables: off_lights: "{% set hall_lights = [\"light.hall_2\"]\n if is_state('input_select.sleep_mode',\ \ 'total')\n else [\"light.hall_1\", \"light.hall_2\", \"light.hall_3\"] %}\n\ {{ expand(state_attr(\"light.stairs_lights\", \"entity_id\") + hall_lights)\n\ \ | selectattr(\"state\", \"eq\", \"off\")\n | map(attribute=\"entity_id\"\ )\n | list }}\n" conditions: '{{ (off_lights | length) > 0 }}' actions: alias: Turn on lights that are off repeat: count: '{{ off_lights | length }}' sequence: action: script.turn_on_lights data: entity_id: '{{ off_lights[repeat.index - 1] }}' - alias: 'Light: turn off hall' triggers: trigger: state entity_id: binary_sensor.activity_in_hall from: 'on' to: 'off' actions: action: light.turn_off data: entity_id: - light.stairs_lights - light.hall_lights transition: 1 - alias: 'Light: automatically turn on the bedroom' triggers: trigger: state entity_id: binary_sensor.activity_in_master_bedroom to: 'on' variables: off_lights: "{{ expand(state_attr(\"light.bedroom_lights\", \"entity_id\"))\n\ \ | selectattr(\"state\", \"eq\", \"off\")\n | map(attribute=\"entity_id\"\ )\n | list }}\n" conditions: - '{{ (off_lights | length) > 0 }}' - condition: state entity_id: input_select.sleep_mode state: 'off' - condition: state entity_id: input_boolean.automatic_bedroom_lights state: 'on' actions: - alias: Turn on lights that are off repeat: count: '{{ off_lights | length }}' sequence: action: script.turn_on_lights data: entity_id: '{{ off_lights[repeat.index - 1] }}' - action: input_boolean.turn_on entity_id: input_boolean.bedroom_lights_automatically_turned_on - alias: 'Light: automatically turn off the bedroom' initial_state: 'on' triggers: trigger: state entity_id: binary_sensor.activity_in_master_bedroom to: 'off' for: 00:08:00 conditions: - condition: state entity_id: input_boolean.bedroom_lights_automatically_turned_on state: 'on' - condition: state entity_id: light.bedroom_lights state: 'on' - condition: state entity_id: input_boolean.automatic_bedroom_lights state: 'on' actions: action: light.turn_off entity_id: light.bedroom_lights data: transition: 10 - alias: 'Light: turn off bedroom lights auto switch' mode: parallel triggers: - trigger: state entity_id: light.bedroom_lights to: 'off' - trigger: event event_type: deconz_event event_data: id: dimmer_switch_bedroom - trigger: event event_type: deconz_event event_data: id: smart_switch_bedroom_bas - trigger: event event_type: deconz_event event_data: id: smart_switch_bedroom_marcella conditions: condition: state entity_id: input_boolean.bedroom_lights_automatically_turned_on state: 'on' actions: action: input_boolean.turn_off entity_id: input_boolean.bedroom_lights_automatically_turned_on - alias: 'Light: turn on automatic_bedroom_lights switch' triggers: trigger: time at: '12:00' actions: entity_id: input_boolean.automatic_bedroom_lights action: input_boolean.turn_on - alias: 'Light: turn off bedroom after 2 hours of inactivity' triggers: trigger: state entity_id: binary_sensor.activity_in_master_bedroom from: 'on' to: 'off' for: 02:00:00 conditions: '{{ is_state(''light.bedroom_lights'', ''on'') }}' actions: action: light.turn_off data: entity_id: light.bedroom_lights - alias: 'Light: reboot bedroom ceiling Shelly' triggers: trigger: time at: '13:00:00' actions: action: shell_command.reboot_bedroom_ceiling - alias: 'Light: Update input_select when bedroom lights turned off' description: Set the input_select.last_script_bedroom such that colored lights will be chosen triggers: trigger: state entity_id: light.bedroom_lights to: 'off' actions: action: input_select.select_option data: entity_id: input_select.last_script_bedroom option: script.white_lights_bedroom - alias: 'Light: turn on utility room / garage outside' triggers: - trigger: state to: 'on' entity_id: binary_sensor.activity_in_utility_room - trigger: state to: 'on' entity_id: binary_sensor.activity_outside_front_door - trigger: state to: 'on' entity_id: binary_sensor.activity_outside_garage actions: - action: light.turn_on data: entity_id: - light.utility_room transition: 1 - if: '{{ state_attr(''sun.sun'', ''elevation'') < 6 }}' then: - action: light.turn_on data: entity_id: - light.outside_front_door - light.garage_outside - action: switch.turn_on data: entity_id: switch.string_lights_outside - alias: 'Light: turn off utility room / garage outside' triggers: - trigger: state to: 'off' entity_id: binary_sensor.activity_in_utility_room - trigger: state to: 'off' entity_id: binary_sensor.activity_outside_front_door - trigger: state to: 'off' entity_id: binary_sensor.activity_outside_garage actions: - if: '{{ is_state(''binary_sensor.activity_in_utility_room'', ''off'') }}' then: - action: light.turn_off entity_id: light.utility_room - if: '{{ is_state(''binary_sensor.activity_outside_house'', ''off'') }}' then: - action: light.turn_off data: entity_id: - light.outside_front_door - light.garage_outside - action: switch.turn_off data: entity_id: switch.string_lights_outside - alias: 'Light: turn on the outside front light' triggers: - trigger: sun event: sunset offset: -01:00:00 - trigger: sun event: sunrise offset: -02:00:00 actions: action: light.turn_on entity_id: light.front_house - alias: 'Light: turn off the outside front light' triggers: - trigger: time at: 01:00:00 - trigger: sun event: sunrise offset: +01:00:00 actions: action: light.turn_off entity_id: light.front_house - alias: 'Light: toggle guest room' triggers: trigger: state entity_id: binary_sensor.activity_in_guest_room conditions: - condition: state entity_id: input_boolean.guest_mode state: 'off' actions: action: light.turn_{{ trigger.to_state.state }} data: entity_id: light.guest_room_lights transition: 1 - alias: 'Light: toggle baby room' triggers: trigger: state entity_id: binary_sensor.activity_in_baby_room actions: - action: light.turn_{{ trigger.to_state.state }} data: entity_id: light.baby_sphere - action: light.turn_{{ trigger.to_state.state }} data: entity_id: light.baby_room_lights transition: 1 - alias: 'Light: turn off living room (extra check)' description: In case the other automation failed triggers: trigger: time_pattern minutes: /59 conditions: - condition: state entity_id: binary_sensor.activity_in_living_room state: 'off' - condition: state entity_id: light.living_room_lights state: 'on' actions: action: light.turn_off entity_id: light.living_room_lights - alias: 'Light: turn off guest room (extra check)' description: In case the other automation failed triggers: trigger: time_pattern minutes: /10 conditions: - condition: state entity_id: binary_sensor.activity_in_guest_room state: 'off' - condition: state entity_id: light.guest_room_lights state: 'on' actions: action: light.turn_off entity_id: light.guest_room_lights - alias: 'Light: turn off baby room (extra check)' description: In case the other automation failed triggers: trigger: time_pattern minutes: /10 conditions: - condition: state entity_id: binary_sensor.activity_in_baby_room state: 'off' - condition: or conditions: - condition: state entity_id: light.baby_sphere state: 'on' - condition: state entity_id: light.baby_room_lights state: 'on' actions: action: light.turn_off entity_id: - light.baby_room_lights - alias: 'Light: turn off bedroom (extra check)' description: In case the other automation failed triggers: trigger: time_pattern minutes: /30 conditions: - condition: state entity_id: binary_sensor.activity_in_master_bedroom state: 'off' - condition: state entity_id: input_boolean.automatic_bedroom_lights state: 'on' - condition: state entity_id: input_boolean.bedroom_lights_automatically_turned_on state: 'on' actions: - action: light.turn_off entity_id: light.bedroom_lights - action: light.turn_off entity_id: input_boolean.bedroom_lights_automatically_turned_on - alias: 'Light: turn off utility room / garage (extra check)' description: In case the other automation failed triggers: trigger: time_pattern minutes: /10 conditions: - condition: state entity_id: binary_sensor.activity_in_utility_room state: 'off' - condition: state entity_id: binary_sensor.activity_outside_front_door state: 'off' - condition: state entity_id: binary_sensor.activity_outside_garage state: 'off' - condition: or conditions: - condition: state entity_id: light.utility_room state: 'on' - condition: state entity_id: light.garage_outside state: 'on' - condition: state entity_id: light.outside_front_door state: 'on' actions: action: light.turn_off entity_id: - light.utility_room - light.garage_outside - light.outside_front_door - alias: 'Light: Update Zigbee2MQTT lights input_select options' triggers: trigger: mqtt topic: zigbee2mqtt/bridge/devices actions: - variables: devices: '{{ trigger.payload_json }}' - variables: z2m_lights: "{% set ns = namespace(lights=[]) %} {% for device in devices %}\n\ \ {% if device.definition is not none %}\n {% for expose in device.definition.exposes\ \ %}\n {% if expose.type == 'light' %}\n {% set light_name = device.friendly_name\ \ %}\n {% set ns.lights = ns.lights + [light_name] %}\n {% endif\ \ %}\n {% endfor %}\n {% endif %}\n{% endfor %} {{ ns.lights }}" - action: input_select.set_options target: entity_id: input_select.z2m_lights data: options: '{{ z2m_lights }}' - alias: 'Light: Update Zigbee2MQTT Lights State' description: Refresh the state of all Zigbee2MQTT lights triggers: trigger: time_pattern minutes: /5 actions: action: script.sync_z2m_to_ha_lights mode: single - alias: 'Lovelace: convert lovelace.json to lovelace-ui.yaml' initial_state: 'on' triggers: trigger: state entity_id: sensor.lovelace actions: - action: shell_command.convert_lovelace - action: shell_command.chores - alias: 'Mailbox: the mailbox was opened' description: 'In the UI show the `input_boolean.mailbox_full`. It needs to be manually switched off after getting the mail." ' triggers: - trigger: state entity_id: binary_sensor.mailbox_vibration to: 'on' conditions: - condition: state entity_id: input_boolean.mailbox_full state: 'off' actions: - action: notify.all_iphones data: title: Mailbox message: Received mail in the mailbox! - action: input_boolean.turn_on data: entity_id: input_boolean.mailbox_full - alias: 'Media player: turn on Opt when TV is on and Spotify is not playing and not Usb' description: 'The speaker is connected via an optical cable to the TV. Whenever the speakers aren''t playing Spotify (via WiFi) directly, switch the source of the speakers to "Opt". ' triggers: - trigger: state entity_id: media_player.tv - trigger: state entity_id: media_player.spotify to: paused conditions: - condition: state entity_id: media_player.tv state: 'on' - '{{ not is_state_attr(''media_player.kef_ls50'', ''source'', ''Optical Input 1'') }}' - '{{ not is_state_attr(''media_player.kef_ls50'', ''source'', ''HDMI ARC'') }}' - '{{ not is_state_attr(''media_player.tv'', ''source'', ''GALLERY'') }}' - "{{ not (is_state_attr('media_player.kef_ls50', 'source', 'Usb')\n and\ \ is_state_attr('media_player.tv', 'source', 'HDMI 3')) }}\n" - "{{ not (is_state_attr('media_player.spotify', 'source', 'KEF LS50')\n \ \ and is_state('media_player.spotify', 'playing')) }}\n" actions: action: media_player.select_source entity_id: media_player.kef_ls50 data: source: Optical Input 1 - alias: 'Media player: turn off speakers when turning off TV' triggers: trigger: state entity_id: media_player.tv to: 'off' conditions: condition: state entity_id: media_player.kef_ls50 state: 'on' actions: - action: homeassistant.update_entity entity_id: media_player.kef_ls50 - condition: template value_template: "{{ is_state_attr(\"media_player.kef_ls50\", \"source\", \"HDMI\ \ ARC\")\n or is_state_attr(\"media_player.kef_ls50\", \"source\", \"Optical\ \ Input 1\") }}\n" - action: media_player.turn_off entity_id: media_player.kef_ls50 - alias: 'Media player: if speakers off and TV on, turn on the speaker on TV state change' triggers: trigger: state entity_id: media_player.tv conditions: - condition: state entity_id: media_player.kef_ls50 state: 'off' - condition: state entity_id: media_player.tv state: 'on' - "{{ trigger.from_state.state != trigger.to_state.state\n or trigger.from_state.attributes[\"\ volume_level\"] != trigger.to_state.attributes[\"volume_level\"]\n or trigger.from_state.attributes[\"\ source\"] != trigger.to_state.attributes[\"source\"] }}\n" actions: - action: media_player.turn_on entity_id: media_player.kef_ls50 - action: media_player.select_source entity_id: media_player.kef_ls50 data: source: Optical Input 1 - alias: 'Media player: update Spotify entity when TV is on every 5 seconds' triggers: trigger: time_pattern seconds: /5 conditions: - condition: state entity_id: media_player.spotify state: playing - condition: state entity_id: media_player.tv state: 'on' actions: action: homeassistant.update_entity entity_id: media_player.spotify - alias: 'Media player: sync KEF LS50 and TV volume' mode: single max_exceeded: silent triggers: - trigger: state entity_id: media_player.kef_ls50 attribute: volume_level - trigger: state entity_id: media_player.tv attribute: volume_level conditions: - '{{ trigger.to_state.state != ''off'' }}' - '{{ state_attr(''media_player.kef_ls50'', ''source'') in (''Optical Input 1'', ''HDMI ARC'', ''Usb'') }}' actions: repeat: sequence: - action: media_player.volume_set data: entity_id: 'media_player.{{ "tv" if (trigger.entity_id == "media_player.kef_ls50") else "kef_ls50" }} ' volume_level: '{{ state_attr(trigger.entity_id, "volume_level") }} ' - delay: milliseconds: 200 until: - "{{ state_attr(\"media_player.tv\", \"volume_level\") == state_attr(\"media_player.kef_ls50\"\ , \"volume_level\")\n or not (is_state(\"media_player.tv\", \"on\") and\ \ is_state(\"media_player.kef_ls50\", \"on\")) }}\n" - alias: 'Media player: automatically turn off TV and Xbox after two hours of inactivity' triggers: trigger: state entity_id: binary_sensor.motion_sensor_living_room_klok to: 'off' for: 02:00:00 actions: - action: media_player.turn_off entity_id: media_player.living_room_xbox - action: media_player.turn_off entity_id: media_player.tv - alias: 'Media player: Turn On Living Room TV with WakeOnLan' triggers: trigger: webostv.turn_on entity_id: media_player.tv actions: - action: wake_on_lan.send_magic_packet data: mac: '!secret tv_mac_address' - alias: 'Music: start playlist' initial_state: 'on' triggers: trigger: state entity_id: input_boolean.start_the_music from: 'off' to: 'on' actions: - action: input_boolean.turn_off entity_id: input_boolean.start_the_music - action: script.start_spotify_playlist_of_nearest_person data: source: KEF LS50 entity_id: media_player.kef_ls50 - alias: 'Music: switch music from iPhone to speakers if coming home' triggers: trigger: state entity_id: binary_sensor.openclose_front_door from: 'off' to: 'on' conditions: - condition: state entity_id: person.marcella state: not_home - condition: state entity_id: input_boolean.guest_mode state: 'off' - '{{ is_state_attr(''media_player.spotify'', ''source'', ''basnijholt-iphone'') }}' - '{{ is_state(''media_player.spotify'', ''playing'') }}' - '{{ as_timestamp(now()) - as_timestamp(states.person.bas.last_changed) < 5 * 60 }}' - condition: numeric_state entity_id: sensor.home_nearest_distance below: 2 actions: - action: media_player.turn_on entity_id: media_player.kef_ls50 - action: media_player.select_source entity_id: media_player.kef_ls50 data: source: Wifi - action: media_player.select_source entity_id: media_player.spotify data: source: KEF LS50 - alias: 'Notifications: Marcella leaving work' triggers: trigger: state entity_id: device_tracker.marcella_iphone_se2 to: Work Marcella Kirkland actions: action: notify.iphone_bas data: title: Leaving message: Marcella left work - alias: 'Notifications: front door has opened' triggers: trigger: state entity_id: binary_sensor.openclose_front_door to: 'on' conditions: condition: state entity_id: input_boolean.front_door_open_warning state: 'on' actions: - action: notify.mobile_app_basnijholt_iphone_13 data: title: Security message: Front door opened! - action: notify.iphone_bas data: title: Security message: Front door opened! - action: input_boolean.turn_off entity_id: input_boolean.front_door_open_warning - alias: 'Notifications: Daily New Word Notification' triggers: - trigger: time at: 07:30:00 actions: - action: notify.mobile_app_marcella_iphone_14_pro data: title: Daily new word message: "{% set words = [\n \"Mama\",\n \"Baby\",\n \"Dog\",\n \"Cat\"\ ,\n \"Ball\",\n \"Car\",\n \"Book\",\n \"Milk\",\n \"Juice\",\n \"Water\"\ ,\n \"Apple\",\n \"Banana\",\n \"Eat\",\n \"More\",\n \"No\",\n \"Yes\"\ ,\n \"Please\",\n \"Thank you\",\n \"Hi\",\n \"Bye\",\n \"Night-night\"\ ,\n \"Bath\",\n \"Diaper\",\n \"Shoe\",\n \"Hat\",\n \"Ear\",\n \"Nose\"\ ,\n \"Eye\",\n \"Hand\",\n] %} {% set word = words | random %} {{ word }}\n" data: actions: - action: AGREE_WORD title: Great word! activationMode: background authenticationRequired: true destructive: true - wait_for_trigger: trigger: event event_type: mobile_app_notification_action event_data: action: AGREE_WORD timeout: 01:00:00 continue_on_timeout: false - action: notify.mobile_app_marcella_iphone_14_pro data: message: We all love you! ❤️😘🥰💖💕🌷🌼🌈✨🎉🍀 - alias: 'Plant: problem with Calathea' triggers: - trigger: state entity_id: plant.calathea to: problem - trigger: time at: '20:00' conditions: condition: state entity_id: plant.calathea state: problem actions: action: notify.all_iphones data: title: Plant in trouble! ⚠️☢️☠️ message: 'You need to give the Calathea 🌳 attention and love: {{ state_attr("plant.calathea", "problem") }}! ' - alias: 'Plant: problem with Monstera' triggers: - trigger: state entity_id: plant.monstera to: problem - trigger: time at: '20:00' conditions: condition: state entity_id: plant.monstera state: problem actions: action: notify.all_iphones data: title: Plant in trouble! ⚠️☢️☠️ message: 'You need to give the Monstera 🌴 attention and love: {{ state_attr("plant.monstera", "problem") }}! ' - alias: 'Plant: problem with Peace lily' triggers: - trigger: state entity_id: plant.peace_lily to: problem - trigger: time at: '20:00' conditions: condition: state entity_id: plant.peace_lily state: problem actions: action: notify.all_iphones data: title: Plant in trouble! ⚠️☢️☠️ message: 'You need to give the Peace lily 🌿 attention and love: {{ state_attr("plant.peace_lily", "problem") }}! ' - alias: 'Security: motion detected but we are not home' triggers: trigger: state entity_id: binary_sensor.motion_detected from: 'off' to: 'on' conditions: - condition: state entity_id: group.persons state: not_home - condition: state entity_id: vacuum.valetudo_vacuum state: docked actions: - action: notify.all_iphones data: message: 'Security: motion is detected, but we are not home.' data: actions: - action: SOUND_ALARM title: Sound alarm activationMode: background authenticationRequired: true destructive: true - wait_for_trigger: trigger: event event_type: mobile_app_notification_action event_data: action: SOUND_ALARM timeout: 01:00:00 continue_on_timeout: false - action: light.turn_on entity_id: all data: flash: long color_name: red - alias: 'Security: front door has been open for more than 5 minutes' triggers: trigger: state entity_id: binary_sensor.openclose_front_door from: 'off' to: 'on' for: 00:05:00 actions: action: notify.all_iphones data: title: Security message: The front door has been open for more than 5 minutes. - alias: 'Security: utility room door has been open for more than 5 minutes' triggers: trigger: state entity_id: binary_sensor.openclose_front_door from: 'off' to: 'on' for: 00:05:00 actions: action: notify.all_iphones data: title: Security message: The utility room door has been open for more than 5 minutes. - alias: 'Security: no one is home but high power usage' triggers: - trigger: state entity_id: binary_sensor.no_one_home to: 'on' - trigger: time_pattern minutes: /10 conditions: - condition: state entity_id: binary_sensor.no_one_home state: 'on' - condition: numeric_state entity_id: sensor.power_consumption above: 0.7 actions: action: notify.all_iphones data: title: Security message: 'No one is home and we are using a lot of energy ({{ states(''sensor.power_consumption'') }} kW now)! ⚡️ ' - alias: 'Security: bathroom door has opened' triggers: trigger: state entity_id: binary_sensor.openclose_bathroom to: 'on' conditions: condition: state entity_id: input_boolean.bathroom_door_open_warning state: 'on' actions: - action: notify.bas data: title: Security message: Office door opened! - action: notify.iphone_bas data: title: Security message: Office door opened! - action: light.turn_on data: entity_id: - light.philips_go - light.desk_led flash: short - action: input_boolean.turn_off entity_id: input_boolean.bathroom_door_open_warning - alias: 'Security: activity in master bedroom' triggers: trigger: state entity_id: binary_sensor.activity_in_master_bedroom to: 'on' conditions: condition: state entity_id: input_boolean.bedroom_activity_warning state: 'on' actions: - action: notify.bas data: title: Security message: Activity bedroom! - action: notify.iphone_bas data: title: Security message: Activity bedroom! - action: light.turn_on data: entity_id: light.desk_led flash: short - action: input_boolean.turn_off entity_id: input_boolean.bedroom_activity_warning - alias: 'Security: Door to outside open' description: '' triggers: - trigger: state entity_id: binary_sensor.door_to_outside_open to: 'on' for: seconds: 15 actions: - repeat: while: - condition: state entity_id: binary_sensor.door_to_outside_open state: 'on' sequence: - action: light.turn_off data: entity_id: - light.garage_outside - light.outside_front_door - light.bedroom_outside - light.utility_room - delay: seconds: 1 - action: light.turn_on data: entity_id: - light.garage_outside - light.outside_front_door - light.bedroom_outside - light.utility_room brightness_pct: 100 - delay: seconds: 1 mode: single - alias: 'Night mode: automatically turn off when alarm turns off or at 7AM' triggers: - trigger: time at: 07:00 - trigger: state entity_id: input_boolean.alarm_clock from: 'on' to: 'off' conditions: condition: state entity_id: input_boolean.alarm_clock state: 'off' actions: entity_id: input_select.sleep_mode action: input_select.select_option data: option: half - alias: 'Night mode: automatically turn off sleeping mode at 11AM' triggers: trigger: time at: '11:00' actions: entity_id: input_select.sleep_mode action: input_select.select_option data: option: 'off' - alias: 'Night mode: turn off automatic bedroom lights' triggers: trigger: state entity_id: input_select.sleep_mode from: 'off' actions: action: input_boolean.turn_off entity_id: input_boolean.automatic_bedroom_lights - alias: 'Night mode: set low temperature when sleep mode turns on' triggers: trigger: state entity_id: input_select.sleep_mode from: 'off' actions: action: script.set_low_temperature - alias: 'Night mode: go from half to total sleeping mode' description: 'When it is half sleeping mode and there is no activity in the house for more than an hour go to total sleeping mode. ' triggers: trigger: state entity_id: binary_sensor.activity_outside_bedroom to: 'off' for: 01:00:00 conditions: condition: state entity_id: input_select.sleep_mode state: half actions: - action: input_select.select_option entity_id: input_select.sleep_mode data: option: total - action: notify.iphone_bas data: title: Night mode message: Automatically switched from 'half' to 'total' sleeping mode! 💤🛌 - alias: 'Night mode: set sleeping mode in the living room' description: 'Set the living room lights to sleep mode only when no-one is there anymore. ' triggers: trigger: state entity_id: input_select.sleep_mode to: total actions: choose: - conditions: '{{ is_state(''binary_sensor.activity_in_living_room'', ''on'') }}' sequence: - wait_for_trigger: trigger: state entity_id: binary_sensor.activity_in_living_room from: 'on' to: 'off' timeout: 06:00:00 continue_on_timeout: false - condition: state entity_id: input_select.sleep_mode state: total - action: switch.turn_on entity_id: switch.adaptive_lighting_sleep_mode_living_room - conditions: '{{ is_state(''binary_sensor.activity_in_living_room'', ''off'') }}' sequence: action: switch.turn_on entity_id: switch.adaptive_lighting_sleep_mode_living_room - alias: 'System: warning about high CPU usage' triggers: trigger: numeric_state entity_id: sensor.processor_use above: 70 for: hours: 4 actions: action: notify.iphone_bas data: title: System message: CPU usage has been above 70% for 4 hours! ⚠️🖥 - alias: 'System: warning about high CPU temperature' triggers: trigger: numeric_state entity_id: sensor.cpu_temperature above: 70 for: hours: 4 actions: action: notify.iphone_bas data: title: System message: CPU temperature has been above 70 °C for 4 hours! ⚠️ - alias: 'System: warning about high Xbox temperature' triggers: trigger: numeric_state entity_id: sensor.temperature_xbox above: 50 actions: - action: notify.iphone_bas data: title: System message: 'Temperature in the Xbox cabinet is {{ states("sensor.temperature_xbox") }} °C! ⚠️ ' - condition: state entity_id: media_player.tv state: 'on' - action: notify.tv data: message: 'Temperature in the Xbox cabinet is {{ states("sensor.temperature_xbox") }} °C! ⚠️ ' - alias: 'System: update DNS' description: Update the DNS at Gandi to point my domain to my Home Assistant instance. triggers: trigger: time_pattern minutes: /15 actions: action: script.update_dns - alias: 'System: run chores' description: Run shell and Python scripts in utils folder. triggers: trigger: time_pattern minutes: /15 actions: action: shell_command.chores - alias: 'System: MQTT sensors are not updating' description: Check whether we are receiving messages over MQTT from my other HA instance. triggers: trigger: time_pattern minutes: /5 conditions: '{{ (as_timestamp(now()) - as_timestamp(states.sensor.power_consumption.last_changed)) > 20 * 60 }}' actions: - action: notify.iphone_bas data: title: System message: Not receiving MQTT updates, maybe reboot the other HA instance! ⚠️ - delay: 03:00:00 - alias: 'System: battery level low' triggers: trigger: time at: '14:30:00' variables: min_battery_level: 50 notify_service: notify.iphone_bas battery_ids: '' current: '' actions: - variables: battery_ids: "{% set ns = namespace(battery=[]) %} {% for s in states.sensor\ \ if 'battery_level' in s.entity_id %}\n {% set ns.battery = ns.battery +\ \ [s] %}\n{% endfor %} {{ ns.battery | map(attribute='entity_id') | list }}\n" - alias: Repeat repeat: count: '{{ battery_ids | length }}' sequence: - variables: current: '{{ battery_ids[repeat.index - 1] }}' - condition: template value_template: '{{ ''iphone'' not in current and ''ipad'' not in current }}' - condition: template value_template: '{{ 0 < (states(current) | float) < (min_battery_level | float ) }}' - action: '{{ notify_service }}' data: title: System message: 'Battery level low of {{ current }}: {{ states(current) }}%! ⚠️' - alias: 'Test: listen to Adaptive Lighting events' mode: parallel max: 100 triggers: - trigger: event event_type: call_service event_data: action: turn_on domain: light - trigger: event event_type: state_changed conditions: '{{ trigger.event.context.id.startswith(''adapt_lgt'') }}' actions: action: system_log.write data: message: '{{ trigger.event.data.entity_id }} is changed by AL: {{ trigger.event.data }}' level: debug logger: yolo.yolo - alias: 'Test: time' triggers: trigger: state entity_id: sensor.time actions: - variables: t_start: '{{ as_timestamp(now()) }}' - action: system_log.write data: message: took {{ as_timestamp(now()) - t_start | int }} level: debug logger: yolo.yolo - alias: 'Test: flash lights' triggers: trigger: state entity_id: sensor.time variables: lights: light.bed_led,light.philips_go,light.bed_reading_up,light.hall_3,light.toilet,light.ceiling_kitchen,light.bamboo,light.lampan,light.sphere_2,light.sphere_1,light.hall_2,light.bed_reading_down,light.corner_living_room,light.tv_led,light.stairs_up,light.stairs_down,light.ceiling_bedroom,light.ceiling_living_room,light.hall_1,light.bed_reading actions: - alias: Turn on lights that are off repeat: count: '{{ lights | length }}' sequence: - variables: light: '{{ lights.split('','')[repeat.index - 1] }}' - action: light.turn_on data: entity_id: '{{ light }}' - delay: 00:00:01 - action: light.turn_off data: entity_id: '{{ light }}' - alias: 'Test: call update_entity after light.turn_on/turn_off' mode: parallel max: 100 triggers: - trigger: event event_type: call_service event_data: action: turn_on domain: light - trigger: event event_type: call_service event_data: action: turn_off domain: light actions: - delay: 00:00:01 - action: homeassistant.update_entity data: entity_id: '{{ trigger.event.entity_id }}' - alias: 'Test: Light Baby Room Loop' mode: parallel triggers: trigger: homeassistant event: start actions: - condition: '{{ is_state(''automation.test_light_baby_room_loop'', ''on'') }}' - action: light.turn_on target: entity_id: light.baby_room - delay: 00:00:10 - action: light.turn_off target: entity_id: light.baby_room - delay: 00:00:10 - action: automation.trigger target: entity_id: automation.test_light_baby_room_loop - alias: 'Utilities: washing machine or dishwasher started or finished' triggers: - trigger: state entity_id: binary_sensor.dishwasher - trigger: state entity_id: binary_sensor.washing_machine variables: from_state: '{{ trigger.from_state.state }}' to_state: '{{ trigger.to_state.state }}' name: '{{ trigger.entity_id.split(''.'', 1)[1] }}' conditions: '{{ (to_state == ''on'' and from_state == ''off'') or (to_state == ''off'' and from_state == ''on'') }}' actions: action: input_datetime.set_datetime data: entity_id: input_datetime.{{ name }}_{{ to_state }} timestamp: '{{ now().timestamp() }}' - alias: 'Utilities: washing machine notification' triggers: trigger: state entity_id: binary_sensor.washing_machine from: 'off' to: 'on' actions: action: script.utility_notification data: name: washing_machine emojis: 👚👕 - alias: 'Utilities: dishwasher notification' triggers: trigger: state entity_id: binary_sensor.dishwasher from: 'off' to: 'on' actions: action: script.utility_notification data: name: dishwasher emojis: 🍽🍳 - alias: 'Vacation mode: auto turn on' initial_state: 'on' triggers: trigger: state entity_id: group.persons from: home to: not_home for: '24:00:00' conditions: - condition: state entity_id: input_boolean.guest_mode state: 'off' actions: - action: input_boolean.turn_on entity_id: input_boolean.vacation_mode - action: notify.all_iphones data: title: Vacation mode message: No one at home for 24 hours, switching on vacation mode. - alias: 'Vacation mode: auto turn off' initial_state: 'on' triggers: trigger: state entity_id: group.persons from: not_home to: home conditions: - condition: state entity_id: input_boolean.vacation_mode state: 'on' - condition: state entity_id: input_boolean.guest_mode state: 'off' actions: - action: input_boolean.turn_off entity_id: input_boolean.vacation_mode - action: notify.all_iphones data: title: Vacation mode message: Welcome back! Switching off the vacation mode. - alias: 'Vacuum: started cleaning' triggers: trigger: state entity_id: vacuum.valetudo_vacuum from: docked to: cleaning actions: - action: notify.all_iphones data: title: Robot message: Robot started to clean! - action: input_datetime.set_datetime data: entity_id: input_datetime.vacuum_on datetime: '{{ now().isoformat() }}' - alias: 'Vacuum: stopped cleaning' triggers: trigger: state entity_id: vacuum.valetudo_vacuum from: returning to: docked actions: - action: input_boolean.turn_on entity_id: input_boolean.cleaned_today - action: input_datetime.set_datetime data: entity_id: input_datetime.vacuum_off datetime: '{{ now().isoformat() }}' - action: notify.all_iphones data: title: Robot message: Cleanup successful after {{ (states('sensor.robot_vacuum_last_clean_duration') | int / 60) | round }} minutes - alias: 'Vacuum: reminder notification' triggers: trigger: time at: 08:00 conditions: condition: state entity_id: binary_sensor.vacuum_day state: 'on' actions: action: notify.all_iphones data: title: Robot message: Vacuum will go today, make sure to leave the doors open and leave nothing on the floor! - alias: 'Vacuum: cleanup if nobody is home' triggers: - trigger: time at: '13:00' - trigger: state entity_id: group.persons from: home to: not_home conditions: - condition: time after: '13:00:00' before: '22:00:00' - condition: state entity_id: binary_sensor.vacuum_day state: 'on' - condition: state entity_id: group.persons state: not_home - condition: state entity_id: input_boolean.cleaned_today state: 'off' - condition: state entity_id: input_boolean.guest_mode state: 'off' - condition: state entity_id: input_boolean.vacation_mode state: 'off' actions: action: vacuum.start entity_id: vacuum.valetudo_vacuum - alias: 'Vacuum: reset cleaned today' initial_state: 'on' triggers: trigger: time at: 00:00:00 actions: action: input_boolean.turn_off entity_id: input_boolean.cleaned_today - alias: 'Vacuum: reset to standard mode' triggers: trigger: state entity_id: vacuum.living_room to: docked actions: action: vacuum.set_fan_speed entity_id: vacuum.valetudo_vacuum data: fan_speed: Standard - alias: 'Work: go home notification' triggers: trigger: state entity_id: binary_sensor.worked_enough_today from: 'off' to: 'on' conditions: - condition: state entity_id: binary_sensor.workday_sensor state: 'on' - condition: state entity_id: input_boolean.work_hour_notification_sent state: 'off' actions: - action: notify.iphone_bas data: title: Work message: You have worked 8 hours today, very good! Go home 🎉 - action: input_boolean.turn_on entity_id: input_boolean.work_hour_notification_sent - alias: 'Work: reset input_boolean at midnight' triggers: trigger: time at: 00:00 conditions: condition: state entity_id: input_boolean.work_hour_notification_sent state: 'on' actions: action: input_boolean.turn_off entity_id: input_boolean.work_hour_notification_sent - alias: 'Work: Bas left work notification for Marcella' triggers: trigger: state entity_id: person.bas from: Work conditions: condition: time after: '15:00:00' before: '22:00:00' actions: action: notify.all_iphones data: title: Work message: Bas has left work! ♥️🎉