- alias: event_android_alarm id: event_android_alarm triggers: - trigger: event event_type: android_alarm actions: - action: timer.start entity_id: timer.post_android_alarm data: duration: '{{states.input_number.post_android_alarm.state|int}}' - action: logbook.log data: name: ha_alarm message: timer arm {{states.input_number.post_android_alarm.state}} seconds - alias: post_android_alarm id: post_android_alarm triggers: - trigger: event event_type: timer.finished event_data: entity_id: timer.post_android_alarm conditions: - condition: and conditions: - condition: template value_template: "{{\n not is_state('media_player.bedroom_speaker', 'playing')\n\ \ }}" actions: - action: script.android_post_alarm - id: bed_light alias: bed_light initial_state: false triggers: - trigger: state entity_id: binary_sensor.bed_motion to: 'on' id: light_on - trigger: state entity_id: binary_sensor.bed_occupancy to: 'off' for: seconds: 60 id: light_off - trigger: state entity_id: binary_sensor.living_motion to: 'on' id: light_off - trigger: state entity_id: binary_sensor.office_motion to: 'on' id: light_off - trigger: event event_type: lights_check event_data: light: turn_off id: light_off mode: restart actions: - variables: cfg: '{% from ''tools.jinja'' import light_cfg %} {{ light_cfg(is_state(''binary_sensor.night_mode'', ''off'')) | from_json }}' - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: light.bed state: 'off' - condition: state entity_id: binary_sensor.day state: 'off' sequence: - action: script.lights_on data: ctrl_light: light.bed ctrl_all: '{{ is_state(''binary_sensor.night_mode'', ''off'') }}' brightness_pct: '{{ cfg.brightness }}' transition: '{{ cfg.transition }}' color_temp: '{{ cfg.temp }}' - conditions: - condition: trigger id: - light_off - condition: state entity_id: light.bed state: 'on' - condition: state entity_id: binary_sensor.bed_occupancy state: 'off' sequence: - action: script.lights_off data: ctrl_light: light.bed transition: '{{ cfg.transition }}' - id: other_bed_light alias: other_bed_light triggers: - trigger: state entity_id: - binary_sensor.bed_motion - binary_sensor.night_mode_ctrl to: 'on' id: light_on - trigger: state entity_id: binary_sensor.bed_occupancy to: 'off' for: seconds: 120 id: light_off - trigger: state entity_id: binary_sensor.night_mode_ctrl to: 'off' id: light_ctrl_off - trigger: event event_type: lights_check event_data: light: turn_off id: light_ctrl_off mode: restart actions: - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: binary_sensor.bed_occupancy state: 'on' - condition: state entity_id: binary_sensor.night_mode_ctrl state: 'on' - condition: state entity_id: light.shutter_bed state: 'off' sequence: - action: light.turn_on target: entity_id: - light.shutter_bed - conditions: - condition: trigger id: - light_off - condition: state entity_id: binary_sensor.bed_occupancy state: 'off' - condition: state entity_id: light.shutter_bed state: 'on' sequence: - action: light.turn_off target: entity_id: - light.shutter_bed - conditions: - condition: trigger id: - light_ctrl_off - condition: state entity_id: light.shutter_bed state: 'on' sequence: - action: light.turn_off target: entity_id: - light.shutter_bed - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: binary_sensor.bed_occupancy state: 'on' - condition: state entity_id: input_boolean.in_bed_dummy_switch state: 'off' - condition: state entity_id: light.bed_wardrobe state: 'off' sequence: - action: light.turn_on target: entity_id: - light.bed_wardrobe - conditions: - condition: trigger id: - light_off - condition: state entity_id: binary_sensor.bed_occupancy state: 'off' - condition: state entity_id: light.bed_wardrobe state: 'on' sequence: - action: light.turn_off target: entity_id: - light.bed_wardrobe - conditions: - condition: trigger id: - light_ctrl_off - condition: state entity_id: light.bed_wardrobe state: 'on' sequence: - action: light.turn_off target: entity_id: - light.bed_wardrobe - alias: motion_light_extend id: motion_light_extend triggers: - trigger: state entity_id: binary_sensor.home_light_extend to: 'on' for: seconds: 5 actions: - action: script.turn_on data: entity_id: script.lumi_double_switch_on - alias: change_pressure id: change_pressure triggers: - trigger: state entity_id: sensor.change_pressure conditions: condition: and conditions: - condition: template value_template: '{{ states(''sensor.change_pressure'') | float(0) | abs > states(''input_number.pressure_speed'') | float(0) }}' - condition: template value_template: "{%- if state_attr('automation.change_pressure', 'last_triggered')\ \ = None -%}\n {{\n now() - state_attr('automation.change_pressure', 'last_triggered')\ \ >\n timedelta(hours=1)\n }}\n{%- else -%}\n True\n{%- endif -%}" actions: - action: script.all_notify data_template: icon_notify: '{{state_attr(''sensor.change_pressure'', ''icon'').split('':'')[1]}}' tit: pressure change msg: '{{states(''sensor.change_pressure'')}}' - alias: weather_alert id: weather_alert triggers: - trigger: state entity_id: binary_sensor.w_alert conditions: - condition: template value_template: '{{trigger.from_state.state = trigger.to_state.state}}' actions: - action: script.all_notify data_template: icon_notify: weather-cloudy-alert tit: weather msg: "{%- if is_state('binary_sensor.w_alert', 'on') -%}\n {{ state_attr('binary_sensor.w_alert',\ \ 'awareness_type').split(';')[1] }} -{{ state_attr('binary_sensor.w_alert',\ \ 'awareness_level').split(';')[1] }}\n {{ state_attr('binary_sensor.w_alert',\ \ 'expires') }}\n{% else %}\n alert expired\n{% endif %}" - alias: temp_vent_notify id: temp_vent_notify triggers: - trigger: state entity_id: binary_sensor.temp_ventilaton actions: - variables: tit: '{{ states(''sensor.temp_out'', with_unit=True) }} out' msg: "{%-\n set val = {\n 'on': 'open window',\n 'off': 'close\ \ window',\n }\n -%}\n{{ val[states('binary_sensor.temp_ventilaton')]\ \ }}" - action: logbook.log data: name: '{{ tit }}' message: '{{ msg }}' - action: persistent_notification.create data_template: title: '{{ tit }}' message: '{{ msg }}' - if: - condition: state entity_id: media_player.livingtv state: playing then: - action: notify.kodi data: data: icon: info displaytime: 15000 title: '{{ tit }}' message: '{{ msg }}' else: - action: notify.gmail data_template: title: '{{ tit }}' message: '{{ msg }}' - alias: hall_light id: hall_light initial_state: false triggers: - trigger: state entity_id: binary_sensor.hall_motion to: 'on' id: light_on - trigger: state entity_id: binary_sensor.hall_occupancy to: 'off' for: seconds: "{%- if int(states('counter.hall_motion'), 30) > 6 -%}\n 90\n{%- elif\ \ int(states('counter.hall_motion'), 30) > 3 -%}\n 45\n{%- else -%}\n 30\n\ {%- endif -%}" id: light_off - trigger: event event_type: lights_check event_data: light: turn_off id: light_off mode: restart actions: - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: light.hall state: 'off' sequence: - action: light.turn_on target: entity_id: null - action: script.lights_on data: ctrl_light: light.hall ctrl_all: '{{ is_state(''binary_sensor.night_mode'', ''off'') }}' - conditions: - condition: trigger id: - light_off - condition: state entity_id: light.hall state: 'on' sequence: - action: script.lights_off data: ctrl_light: light.hall - choose: - conditions: - condition: trigger id: - light_on sequence: - action: counter.increment data: entity_id: - counter.hall_motion - conditions: - condition: trigger id: - light_off sequence: - action: counter.reset data: entity_id: - counter.hall_motion - alias: home_motion_detect id: home_motion_detect triggers: - trigger: state entity_id: binary_sensor.bed_motion to: 'on' - trigger: state entity_id: binary_sensor.living_motion to: 'on' - trigger: state entity_id: binary_sensor.hall_motion to: 'on' - trigger: state entity_id: binary_sensor.office_motion to: 'on' - trigger: state entity_id: input_boolean.home_motion to: 'off' conditions: - condition: template value_template: "{{\n not (\n is_state('device_tracker.root', 'home')\ \ or\n states.device_tracker.root == None\n )\n\n }}" actions: - action: input_boolean.turn_on entity_id: input_boolean.home_motion - alias: notify_record id: notify_record triggers: - trigger: state entity_id: sensor.video_rec actions: - action: script.all_notify data_template: icon_notify: record-rec tit: video rec msg: "{%- if states.sensor.video_rec -%}\n dur: {{ state_attr('sensor.video_rec',\ \ 'duration') }}\n size: {{ states('sensor.video_rec') }}\n edl: {{ state_attr('sensor.video_rec',\ \ 'edl') }}\n name: {{ state_attr('sensor.video_rec', 'fname') }}\n date:\ \ {{ state_attr('sensor.video_rec', 'date') }}\n{% else %}\n err record\n\ {% endif %}" - alias: in_call id: in_call triggers: - trigger: state entity_id: binary_sensor.in_call actions: - service_template: "{%-\n set scr = {\n 'off': 'script.in_call_off',\n\ \ 'on': 'script.in_call_on'\n }\n -%}\n{{ scr[trigger.to_state.state]\ \ }}" - alias: kitchen_light id: kitchen_light initial_state: false triggers: - trigger: state entity_id: binary_sensor.kitchen_motion to: 'on' id: light_on - trigger: state entity_id: binary_sensor.kitchen_occupancy to: 'off' for: seconds: "{%- if int(states('counter.kitchen_motion'), 30) > 14 -%}\n 120\n\ {%- elif int(states('counter.kitchen_motion'), 30) > 10 -%}\n 90\n{%- elif\ \ int(states('counter.kitchen_motion'), 30 ) > 6 -%}\n 60\n{%- else -%}\n\ \ 15\n{%- endif -%}" id: kitchen_light_off - trigger: state entity_id: binary_sensor.office_motion to: 'on' id: light_off - trigger: state entity_id: binary_sensor.bed_motion to: 'on' id: light_off - trigger: event event_type: lights_check event_data: light: turn_off id: light_off mode: restart actions: - variables: brightness_pct: "{%- if is_state('binary_sensor.night_mode', 'off') -%}\n {{\ \ range(80, 90, 1) | random }}\n{%- else -%}\n {{ range(30, 40, 1) | random\ \ }}\n{%- endif -%}" - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: light.kitchen_led state: 'off' sequence: - action: light.turn_on target: entity_id: light.kitchen_led - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: light.kitchen_led data: brightness_pct: '{{ brightness_pct }}' - conditions: - condition: trigger id: - kitchen_light_off - light_off - condition: state entity_id: light.kitchen_led state: 'on' - condition: or conditions: - condition: state entity_id: binary_sensor.kitchen_occupancy state: 'off' - condition: state entity_id: binary_sensor.kodi_active state: 'on' sequence: - action: light.turn_on target: entity_id: light.kitchen_led data: brightness_pct: 15 - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_off target: entity_id: - light.kitchen_led - choose: - conditions: - condition: trigger id: - light_on sequence: - action: counter.increment data: entity_id: - counter.kitchen_motion - conditions: - condition: trigger id: - kitchen_light_off - light_off - condition: state entity_id: binary_sensor.kitchen_occupancy state: 'off' sequence: - action: counter.reset data: entity_id: - counter.kitchen_motion - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: binary_sensor.kodi_active state: 'off' sequence: - event: kitchen_light_1 event_data: ctrl: kitchen_on brightness_pct: '{{ range(85, 95, 2) | random }}' temp: '{{ 4000 }}' transition: '{{ 1 }}' - conditions: - condition: trigger id: - kitchen_light_off sequence: - event: kitchen_light_1 event_data: ctrl: kitchen_off transition: '{{ 1 }}' - alias: kitchen_light_1 id: kitchen_light_1 initial_state: true triggers: - trigger: event event_type: kitchen_light_1 - trigger: event event_type: lights_check event_data: light: turn_off id: light_off mode: restart actions: - choose: - conditions: - condition: template value_template: '{{ trigger.event.data.ctrl == ''kitchen_on'' }}' - condition: numeric_state entity_id: sensor.living_window_lux value_template: '{{ float(state.state, 20) }}' below: 30 - condition: state entity_id: binary_sensor.night_mode state: 'off' - condition: template value_template: '{{ not is_state_attr(''light.kitchen'', ''color_temp_kelvin'', 4000) }}' sequence: - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: light.kitchen data: brightness_pct: 1 transition: 0 color_temp_kelvin: '{{ trigger.event.data.temp }}' - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: light.kitchen data: brightness_pct: '{{ trigger.event.data.brightness_pct }}' transition: '{{ trigger.event.data.transition }}' - conditions: - condition: template value_template: '{{ trigger.event.data.ctrl == ''living_on'' }}' - condition: numeric_state entity_id: sensor.living_window_lux value_template: '{{ float(state.state, 10) }}' below: 20 - condition: state entity_id: binary_sensor.night_mode state: 'off' - condition: state entity_id: light.kitchen state: 'off' - condition: state entity_id: binary_sensor.kodi_active state: 'off' sequence: - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: light.kitchen data: brightness_pct: 1 transition: 0 color_temp_kelvin: '{{ trigger.event.data.temp }}' - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: light.kitchen data: brightness_pct: '{{ trigger.event.data.brightness_pct }}' transition: '{{ trigger.event.data.transition }}' - conditions: - condition: template value_template: '{{ trigger.event.data.ctrl == ''kitchen_off'' }}' - condition: state entity_id: light.living state: 'on' - condition: state entity_id: binary_sensor.kodi_active state: 'off' - condition: numeric_state entity_id: sensor.living_window_lux value_template: '{{ float(state.state, 20) }}' below: 30 sequence: - action: light.turn_on target: entity_id: light.kitchen data: transition: 3 brightness: '{{ state_attr(''light.living'', ''brightness'') | int(220) }}' color_temp_kelvin: '{{ state_attr(''light.living'', ''color_temp_kelvin'') | int(3000) }}' - conditions: - condition: template value_template: "{{\n trigger.event.data.ctrl in ['kitchen_off', 'living_off']\ \ or\n trigger.id == 'light_off'\n }}" - condition: state entity_id: light.kitchen state: 'on' - condition: or conditions: - condition: and conditions: - condition: template value_template: "{{\n not is_state ('binary_sensor.living_occupancy',\ \ 'on')\n }}" - condition: numeric_state entity_id: counter.kitchen_motion below: 1 - condition: state entity_id: binary_sensor.kodi_active state: 'on' sequence: - action: light.turn_off target: entity_id: light.kitchen data: transition: 5 - alias: kodi sleep timer id: kodi_sleep_timer triggers: - trigger: event event_type: kodi_sleep_timer conditions: - condition: state entity_id: switch.tv_cec state: 'on' actions: - action: switch.turn_off entity_id: switch.tv_cec - delay: seconds: 100 - action: media_player.volume_set data: entity_id: media_player.livingtv volume_level: 1.0 - action: script.all_notify data: icon_notify: kodi tit: kodi msg: restore volume - alias: tv ctrl id: tv_ctrl initial_state: false triggers: - trigger: state entity_id: binary_sensor.kodi_screen_saver to: 'off' id: tv_on for: seconds: 1 - trigger: state entity_id: binary_sensor.kodi_screen_saver to: 'on' for: seconds: 30 id: tv_off - trigger: state entity_id: media_player.livingtv to: playing for: seconds: 1 id: play - trigger: state entity_id: media_player.livingtv from: playing for: seconds: 1 id: pause - trigger: state entity_id: media_player.livingtv to: paused for: seconds: 3 id: pause_long - trigger: event event_type: tv_ctrl event_data: data: tv_off id: tv_off mode: restart actions: - choose: - conditions: - condition: trigger id: - tv_on - tv_off sequence: - action: kodi.call_method data: entity_id: media_player.livingtv method: XBMC.GetInfoBooleans booleans: - System.IdleTime(60) - delay: milliseconds: 500 - choose: - conditions: - condition: trigger id: - tv_on - condition: state entity_id: media_player.livingtv state: idle - condition: state entity_id: switch.tv_cec state: 'off' sequence: - action: input_select.select_option data: entity_id: input_select.hyperion_select_effect option: Sparks - choose: - conditions: - condition: trigger id: - tv_on - condition: state entity_id: binary_sensor.kodi_idle state: 'off' sequence: - if: - condition: state entity_id: media_player.ht_mt500_501_b34d6a state: playing then: - action: media_player.turn_off data: entity_id: media_player.ht_mt500_501_b34d6a else: - action: shell_command.sound_bar_on - delay: seconds: 5 - choose: - conditions: - condition: trigger id: - tv_on - condition: state entity_id: media_player.livingtv state: idle - condition: state entity_id: switch.tv_cec state: 'off' sequence: - if: - condition: state entity_id: binary_sensor.kodi_idle state: 'off' then: - action: switch.turn_on entity_id: switch.tv_cec - wait_template: "{{\n is_state('switch.tv_cec', 'on')\n }}" timeout: seconds: 30 continue_on_timeout: true - delay: seconds: 5 - action: script.is_hdmi1 - delay: seconds: 5 - action: script.as_hdmi1 - delay: seconds: 5 - action: script.tv_hdmi1_audio - delay: seconds: 5 - action: script.as_hdmi1 - delay: seconds: 5 - action: script.tv_hdmi1_audio - action: script.state_kodi - delay: seconds: 5 - action: script.as_hdmi1 - delay: seconds: 5 - action: script.tv_hdmi1_audio - action: script.turn_on data: entity_id: - script.light_extend_clear - action: songpal.set_sound_setting data: entity_id: media_player.soundbar name: subwooferLevel value: 6 - action: songpal.set_sound_setting data: entity_id: media_player.soundbar name: voice value: type2 - action: media_player.volume_set data: entity_id: media_player.soundbar volume_level: 0.24 - action: notify.kodi data: title: cec on message: sequnce finised data: icon: info displaytime: 5000 - event: tv_cec_control_done event_data: cec: 'on' else: - action: script.all_notify data: icon_notify: television tit: living tv msg: skip on - conditions: - condition: trigger id: - tv_off - condition: state entity_id: media_player.livingtv state: idle - condition: state entity_id: switch.tv_cec state: 'on' sequence: - action: switch.turn_off entity_id: switch.tv_cec - wait_template: "{{\n is_state('switch.tv_cec', 'off')\n }}" timeout: seconds: 20 continue_on_timeout: true - choose: - conditions: - condition: state entity_id: switch.tv_cec state: 'on' sequence: - action: input_select.select_option data: entity_id: input_select.hyperion_select_effect option: Police Lights Solid - action: script.all_notify data: icon_notify: television tit: living tv msg: restart - delay: seconds: 30 - action: script.living_tv_reboot default: - delay: seconds: 5 - action: script.radio_on - action: input_select.select_option data: entity_id: input_select.hyperion_select_effect option: Matrix - event: tv_cec_control_done event_data: cec: 'off' - conditions: - condition: trigger id: - pause sequence: - action: input_select.select_option data: entity_id: input_select.hyperion_select_effect option: Lights - conditions: - condition: trigger id: - play sequence: - action: script.turn_on data: entity_id: - script.light_extend_clear - action: input_select.select_option data: entity_id: input_select.hyperion_select_effect option: None - conditions: - condition: trigger id: - pause_long sequence: - action: script.state_kodi - action: kodi.call_method data: entity_id: media_player.livingtv method: Addons.ExecuteAddon addonid: plugin.program.braviacontrol params: VolumeDown - delay: seconds: 1 - action: kodi.call_method data: entity_id: media_player.livingtv method: Addons.ExecuteAddon addonid: plugin.program.braviacontrol params: VolumeUp - alias: kodi_clear_tv_db id: kodi_clear_tv_db triggers: - trigger: event event_type: tv_cec_control_done event_data: cec: 'off' conditions: - condition: state entity_id: media_player.livingtv state: idle actions: - action: kodi.call_method data: entity_id: media_player.livingtv method: Addons.SetAddonEnabled addonid: pvr.hts enabled: false - delay: seconds: 5 - action: shell_command.tv_cleardb - delay: seconds: 5 - action: kodi.call_method data: entity_id: media_player.livingtv method: Addons.SetAddonEnabled addonid: pvr.hts enabled: true - delay: seconds: 10 - action: kodi.call_method data: entity_id: media_player.livingtv method: VideoLibrary.Clean - alias: update_video_db id: update_video_db triggers: - trigger: event event_type: tv_cec_control_done event_data: cec: 'on' - trigger: state entity_id: media_player.livingtv to: idle for: seconds: 10 - trigger: state entity_id: media_player.livingtv to: paused for: seconds: 10 actions: - action: script.update_video_db - action: logbook.log data_template: name: videodb message: trigger update - action: automation.turn_off entity_id: automation.update_video_db - alias: sonarr_radarr_db id: sonarr_radarr_db triggers: - trigger: event event_type: update_video_db mode: queued actions: - action: script.all_notify data_template: icon_notify: download-outline tit: "{{\n trigger.event.data.name\n }}" msg: "{{\n trigger.event.data.eventtype\n }}" - choose: - conditions: - condition: template value_template: "{{\n trigger.event.data.eventtype in ['Download', 'Rename']\n\ \ }}" sequence: - action: automation.turn_on entity_id: automation.update_video_db - alias: bazarr_subs id: bazarr_subs triggers: - trigger: event event_type: bazarr_subs actions: - action: script.all_notify data_template: icon_notify: subtitles-outline tit: bazarr msg: '{{trigger.event.data.message}}' - alias: living_light id: living_light initial_state: false triggers: - trigger: state entity_id: binary_sensor.living_motion to: 'on' id: light_on - trigger: state entity_id: binary_sensor.living_occupancy to: 'off' for: seconds: 60 id: light_off - trigger: state entity_id: binary_sensor.bed_motion to: 'on' id: light_off - trigger: state entity_id: binary_sensor.office_motion to: 'on' id: light_off - trigger: state entity_id: binary_sensor.light_video_pause to: 'on' id: light_on - trigger: state entity_id: binary_sensor.light_video_pause to: 'off' id: light_off_video - trigger: event event_type: lights_check event_data: light: turn_off id: light_off mode: restart actions: - variables: cfg: "{% from 'tools.jinja' import light_cfg %} {{ light_cfg(\n is_state('binary_sensor.night_mode',\ \ 'off') and\n is_state('binary_sensor.light_video_pause', 'off')\n\ \ ) | from_json\n }}" - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: light.living state: 'off' - condition: state entity_id: binary_sensor.kodi_active state: 'off' - condition: state entity_id: binary_sensor.day state: 'off' - condition: numeric_state entity_id: sensor.living_lux value_template: '{{ float(state.state, 30) }}' below: 40 sequence: - action: script.lights_on data: ctrl_light: light.living ctrl_all: '{{ is_state(''binary_sensor.night_mode'', ''off'') }}' brightness_pct: '{{ cfg.brightness }}' transition: '{{ cfg.transition }}' color_temp: '{{ cfg.temp }}' - conditions: - condition: trigger id: - light_off - condition: state entity_id: light.living state: 'on' - condition: state entity_id: binary_sensor.light_video_pause state: 'off' - condition: or conditions: - condition: state entity_id: binary_sensor.living_occupancy state: 'off' - condition: state entity_id: binary_sensor.kodi_active state: 'on' sequence: - action: script.lights_off data: ctrl_light: light.living transition: '{{ cfg.transition }}' - conditions: - condition: trigger id: - light_off_video - condition: state entity_id: light.living state: 'on' sequence: - action: script.lights_off data: ctrl_light: light.living transition: '{{ cfg.transition }}' - choose: - conditions: - condition: trigger id: - light_on sequence: - event: kitchen_light_1 event_data: ctrl: living_on brightness_pct: '{{ cfg.brightness }}' temp: "{%- if is_state('light.living', 'on') -%}\n {{ state_attr('light.living',\ \ 'color_temp_kelvin') }}\n{%- else -%}\n {{ cfg.temp }}\n{%- endif -%}" transition: '{{ cfg.transition }}' - choose: - conditions: - condition: trigger id: - light_off sequence: - event: kitchen_light_1 event_data: ctrl: living_off transition: '{{ cfg.transition }}' - alias: other_living_light id: other_living_light triggers: - trigger: state entity_id: - binary_sensor.living_motion - binary_sensor.night_mode_ctrl to: 'on' id: light_on - trigger: state entity_id: binary_sensor.living_occupancy to: 'off' for: seconds: 120 id: light_off - trigger: state entity_id: binary_sensor.night_mode_ctrl to: 'off' id: light_ctrl_off - trigger: event event_type: lights_check event_data: light: turn_off id: light_ctrl_off mode: restart actions: - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: binary_sensor.living_occupancy state: 'on' - condition: state entity_id: binary_sensor.night_mode_ctrl state: 'on' - condition: state entity_id: light.shutter_living state: 'off' sequence: - action: light.turn_on target: entity_id: - light.shutter_living - conditions: - condition: trigger id: - light_off - condition: state entity_id: binary_sensor.living_occupancy state: 'off' - condition: state entity_id: light.shutter_living state: 'on' sequence: - action: light.turn_off target: entity_id: - light.shutter_living - conditions: - condition: trigger id: - light_ctrl_off - condition: state entity_id: light.shutter_living state: 'on' sequence: - action: light.turn_off target: entity_id: - light.shutter_living - alias: n0ll_not_home id: n0ll_not_home triggers: - trigger: state entity_id: device_tracker.n0ll to: not_home for: seconds: 90 actions: - action: script.sound_bar_go_sleep - alias: root_not_home id: root_not_home initial_state: false triggers: - trigger: zone entity_id: device_tracker.root zone: zone.home event: leave actions: - action: script.turn_on data: entity_id: - script.light_extend_clear - action: media_player.turn_off entity_id: - media_player.ht_mt500_501_b34d6a - media_player.bedroom_speaker - action: script.kodi_turn_off - action: automation.turn_off entity_id: - automation.just_home - alias: home_away id: home_away triggers: - trigger: numeric_state entity_id: sensor.home_root_distance above: 15 id: away - trigger: state entity_id: input_boolean.away_skip for: seconds: 3 id: away_skip mode: restart actions: - choose: - conditions: - condition: or conditions: - condition: trigger id: - away - condition: and conditions: - condition: trigger id: - away_skip - condition: state entity_id: input_boolean.away_skip state: 'off' - condition: numeric_state entity_id: sensor.home_root_distance above: 15 sequence: - if: - condition: state entity_id: input_boolean.away_skip state: 'off' then: - action: notify.gmail data: message: home away trigger title: hass - action: script.turn_on target: entity_id: - script.doors_full_lock - action: switch.turn_off entity_id: - switch.living_tv - switch.bed_switch_1 - action: automation.turn_on entity_id: automation.home_near - action: automation.turn_off entity_id: automation.home_away else: - action: script.all_notify data: tit: home_away msg: skip - choose: - conditions: - condition: trigger id: - away_skip sequence: - action: script.all_notify data: tit: home_away msg: "{%- set _map = {\n 'on': 'disabled',\n 'off': 'enabled'\n\ \ }\n -%}\nis {{ _map[states('input_boolean.away_skip')] }}" - alias: office_light id: office_light initial_state: false triggers: - trigger: state entity_id: binary_sensor.office_motion to: 'on' id: light_on - trigger: state entity_id: binary_sensor.office_occupancy to: 'off' for: seconds: 60 id: light_off - trigger: state entity_id: binary_sensor.living_motion to: 'on' id: light_off - trigger: state entity_id: binary_sensor.bed_motion to: 'on' id: light_off - trigger: event event_type: lights_check event_data: light: turn_off id: light_off mode: restart actions: - variables: cfg: '{% from ''tools.jinja'' import light_cfg %} {{ light_cfg(is_state(''binary_sensor.night_mode'', ''off'')) | from_json }}' - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: light.office state: 'off' - condition: state entity_id: binary_sensor.day state: 'off' sequence: - if: - condition: state entity_id: - input_boolean.office_enter_dummy state: 'off' then: - action: script.lights_on data: ctrl_light: light.office ctrl_all: '{{ is_state(''binary_sensor.night_mode'', ''off'') }}' brightness_pct: '{{ cfg.brightness }}' transition: '{{ cfg.transition }}' color_temp: '{{ cfg.temp }}' else: - action: script.lights_on data: ctrl_light: light.office_desk ctrl_all: false brightness_pct: 70 transition: 5 color_temp: 4000 - action: input_boolean.turn_off entity_id: - input_boolean.office_enter_dummy - conditions: - condition: trigger id: - light_off - condition: state entity_id: light.office state: 'on' - condition: state entity_id: binary_sensor.office_occupancy state: 'off' sequence: - action: script.lights_off data: ctrl_light: light.office transition: '{{ cfg.transition }}' - alias: other_office_light id: other_office_light triggers: - trigger: state entity_id: - binary_sensor.office_motion - binary_sensor.night_mode_ctrl to: 'on' id: light_on - trigger: state entity_id: binary_sensor.office_occupancy to: 'off' for: seconds: 120 id: light_off - trigger: state entity_id: binary_sensor.night_mode_ctrl to: 'off' id: light_ctrl_off - trigger: event event_type: lights_check event_data: light: turn_off id: light_ctrl_off mode: restart actions: - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: binary_sensor.office_occupancy state: 'on' - condition: state entity_id: binary_sensor.night_mode_ctrl state: 'on' - condition: state entity_id: light.shutter_office state: 'off' sequence: - action: light.turn_on target: entity_id: - light.shutter_office - condition: state entity_id: input_boolean.office_enter_dummy state: 'on' - action: input_boolean.turn_off entity_id: - input_boolean.office_enter_dummy - conditions: - condition: trigger id: - light_off - condition: state entity_id: binary_sensor.office_occupancy state: 'off' - condition: state entity_id: light.shutter_office state: 'on' sequence: - action: light.turn_off target: entity_id: - light.shutter_office - conditions: - condition: trigger id: - light_ctrl_off - condition: state entity_id: light.shutter_office state: 'on' sequence: - action: light.turn_off target: entity_id: - light.shutter_office - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: binary_sensor.office_occupancy state: 'on' - condition: state entity_id: input_boolean.in_bed_dummy_switch state: 'off' - condition: state entity_id: light.office_wardrobe state: 'off' sequence: - action: light.turn_on target: entity_id: - light.office_wardrobe - conditions: - condition: trigger id: - light_off - condition: state entity_id: binary_sensor.office_occupancy state: 'off' - condition: state entity_id: light.office_wardrobe state: 'on' sequence: - action: light.turn_off target: entity_id: - light.office_wardrobe - conditions: - condition: trigger id: - light_ctrl_off - condition: state entity_id: light.office_wardrobe state: 'on' sequence: - action: light.turn_off target: entity_id: - light.office_wardrobe - id: bath_heating alias: bath_heating triggers: - trigger: state entity_id: switch.climate_control for: minutes: 3 id: on_off - trigger: state entity_id: input_boolean.in_bed_dummy_switch to: 'on' for: minutes: 3 id: bed_off - trigger: time at: 06:30:00 id: time_on - trigger: time at: 00:15:00 id: time_off mode: restart actions: - choose: - conditions: - condition: trigger id: - time_on - condition: state entity_id: device_tracker.root state: home - condition: state entity_id: climate.bath_tvr state: - heat sequence: - action: climate.set_hvac_mode data: entity_id: climate.bath_tvr hvac_mode: heat - delay: seconds: 3 - action: climate.set_preset_mode data: entity_id: climate.bath_tvr preset_mode: manual - delay: seconds: 3 - action: climate.set_temperature data: entity_id: climate.bath_tvr temperature: 22.5 - delay: seconds: 3 - action: switch.turn_on data: entity_id: switch.bath_tvr_boost - conditions: - condition: trigger id: - time_off - bed_off - condition: state entity_id: climate.bath_tvr state: - heat sequence: - action: climate.set_temperature data: entity_id: climate.bath_tvr temperature: 19.5 - conditions: - condition: trigger id: - on_off - condition: state entity_id: switch.climate_control state: 'on' - condition: state entity_id: select.operation_mode state: heating - condition: state entity_id: climate.bath_tvr state: - 'off' sequence: - action: climate.set_hvac_mode data: entity_id: climate.bath_tvr hvac_mode: heat - delay: seconds: 3 - action: climate.set_preset_mode data: entity_id: climate.bath_tvr preset_mode: manual - delay: seconds: 3 - action: climate.set_temperature data: entity_id: climate.bath_tvr temperature: 20.5 - conditions: - condition: trigger id: - on_off - condition: or conditions: - condition: and conditions: - condition: state entity_id: switch.climate_control state: 'off' - condition: state entity_id: select.operation_mode state: heating - condition: and conditions: - condition: state entity_id: switch.climate_control state: 'on' - condition: state entity_id: select.operation_mode state: cooling - condition: or conditions: - condition: state entity_id: climate.bath_tvr state: - heat - condition: numeric_state entity_id: climate.bath_tvr attribute: temperature above: 10.5 sequence: - action: climate.set_hvac_mode data: entity_id: climate.bath_tvr hvac_mode: heat - delay: seconds: 3 - action: climate.set_preset_mode data: entity_id: climate.bath_tvr preset_mode: manual - delay: seconds: 3 - action: climate.set_temperature data: entity_id: climate.bath_tvr temperature: 10.5 - delay: seconds: 3 - action: climate.set_hvac_mode data: entity_id: climate.bath_tvr hvac_mode: 'off' default: - action: logbook.log data: name: bath_heating data_template: message: 'check automation using default - Id: {{trigger.id}} Idx: {{ trigger.idx }}' - id: bath_light alias: bath_light initial_state: false triggers: - trigger: state entity_id: binary_sensor.bath_motion to: 'on' id: light_on - trigger: state entity_id: binary_sensor.bath_occupancy to: 'off' for: seconds: "{%- if int(states('counter.bath_motion'), 30) > 14 -%}\n 120\n{%-\ \ elif int(states('counter.bath_motion'), 30) > 10 -%}\n 90\n{%- elif int(states('counter.bath_motion'),\ \ 30) > 6 -%}\n 60\n{%- elif int(states('counter.bath_motion'), 30) > 3 -%}\n\ \ 45\n{%- else -%}\n 30\n{%- endif -%}" id: light_off - trigger: state entity_id: binary_sensor.bed_motion to: 'on' id: light_off - trigger: state entity_id: binary_sensor.living_motion to: 'on' id: light_off - trigger: event event_type: lights_check event_data: light: turn_off id: light_off mode: restart actions: - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: light.bath state: 'off' sequence: - action: script.lights_on data: ctrl_light: light.bath ctrl_all: '{{ is_state(''binary_sensor.night_mode'', ''off'') }}' - conditions: - condition: trigger id: - light_off - condition: state entity_id: light.bath state: 'on' - condition: state entity_id: binary_sensor.bath_occupancy state: 'off' sequence: - action: script.lights_off data: ctrl_light: light.bath - id: bath_fan alias: bath_fan triggers: - trigger: state entity_id: binary_sensor.bath_fan to: 'on' id: fan_on - trigger: state entity_id: binary_sensor.bath_fan to: 'off' id: fan_off - trigger: state entity_id: binary_sensor.showering id: shower to: null - trigger: state entity_id: input_boolean.fan_bath_time to: 'on' id: manual_on - trigger: state entity_id: input_boolean.fan_bath_time to: 'on' for: minutes: "{{\n int(states('input_number.fan_bath_time'), 1)\n }}" id: manual_off - trigger: event event_type: up_down_my event_data: data: start id: manual_off - trigger: state entity_id: binary_sensor.bath_motion to: 'on' id: motion - trigger: state entity_id: binary_sensor.bath_occupancy to: 'off' for: seconds: "{%- if int(states('counter.bath_motion'), 30) > 12 -%}\n 90\n{%-\ \ elif int(states('counter.bath_motion'), 30) > 8 -%}\n 70\n{%- elif int(states('counter.bath_motion'),\ \ 30) > 4 -%}\n 50\n{%- else -%}\n 30\n{%- endif -%}" id: no_motion mode: restart actions: - choose: - conditions: - condition: or conditions: - condition: and conditions: - condition: trigger id: - shower - condition: state entity_id: binary_sensor.showering state: 'on' - condition: trigger id: - fan_on - manual_on - condition: state entity_id: switch.bath_fan state: 'off' sequence: - action: switch.turn_on data: entity_id: - switch.bath_fan - conditions: - condition: trigger id: - shower - manual_off - fan_off - condition: or conditions: - condition: trigger id: - manual_off - condition: state entity_id: input_boolean.fan_bath_time state: 'off' - condition: state entity_id: binary_sensor.bath_fan state: 'off' - condition: state entity_id: binary_sensor.showering state: 'off' - condition: state entity_id: switch.bath_fan state: 'on' sequence: - action: switch.turn_off data: entity_id: - switch.bath_fan - choose: - conditions: - condition: trigger id: - shower - manual_off - condition: state entity_id: input_boolean.fan_bath_time state: 'on' sequence: - action: input_boolean.turn_off data: entity_id: - input_boolean.fan_bath_time - choose: - conditions: - condition: trigger id: - motion sequence: - action: counter.increment data: entity_id: - counter.bath_motion - conditions: - condition: trigger id: - no_motion sequence: - action: counter.reset data: entity_id: - counter.bath_motion - id: in_shower alias: in_shower triggers: - trigger: state entity_id: binary_sensor.bath_motion_1 to: 'on' id: resume - trigger: state entity_id: binary_sensor.bath_motion_2 to: 'on' id: pause conditions: - condition: state entity_id: binary_sensor.showering state: 'on' mode: single max_exceeded: silent actions: - choose: - conditions: - condition: trigger id: - pause - condition: state entity_id: - automation.water_city_1 - automation.bath_light state: 'on' sequence: - action: automation.turn_off data: entity_id: - automation.water_city_1 - automation.bath_light - conditions: - condition: trigger id: - resume - condition: state entity_id: - automation.water_city_1 - automation.bath_light state: 'off' sequence: - action: automation.turn_on data: entity_id: - automation.water_city_1 - automation.bath_light - alias: in_bed id: in_bed triggers: - trigger: state entity_id: binary_sensor.bed_in to: 'on' id: trigger_on - trigger: state entity_id: binary_sensor.hall_motion to: 'on' id: trigger_off - trigger: state entity_id: device_tracker.n0ll to: home id: trigger_off - trigger: event event_type: android_alarm id: trigger_off mode: restart actions: - choose: - conditions: - condition: trigger id: - trigger_on - condition: state entity_id: input_boolean.in_bed_dummy_switch state: 'off' - condition: state entity_id: device_tracker.root state: home - condition: template value_template: '{{ not is_state(''media_player.livingtv'', ''playing'') }}' - condition: state entity_id: device_tracker.n0ll state: not_home - condition: time after: '23:00:00' before: 07:00:00 sequence: - action: script.light_extend_clear - wait_template: "{{\n is_state('timer.lumi_double_switch_1_timer', 'idle')\n\ \ }}" timeout: seconds: 30 continue_on_timeout: true - action: input_boolean.turn_on data: entity_id: input_boolean.in_bed_dummy_switch - action: automation.turn_off data: entity_id: automation.bed_light - delay: seconds: 3 - action: timer.start entity_id: timer.dummy_in_bed data: duration: 00:00:45 - conditions: - condition: trigger id: - trigger_off - condition: state entity_id: input_boolean.in_bed_dummy_switch state: 'on' - condition: state entity_id: device_tracker.root state: home sequence: - action: input_boolean.turn_off data: entity_id: input_boolean.in_bed_dummy_switch - action: automation.turn_on data: entity_id: automation.bed_light - alias: in_bed_light id: in_bed_light triggers: - trigger: event event_type: - timer.finished - timer.restarted - timer.started event_data: entity_id: timer.dummy_in_bed conditions: - condition: and conditions: - condition: template value_template: "{{\n is_state('binary_sensor.day', 'off') or\n is_state('light.bed',\ \ 'on')\n }}" actions: - variables: cfg: '{% from ''tools.jinja'' import light_cfg %} {{ light_cfg(is_state(''binary_sensor.night_mode'', ''off'')) | from_json }}' - action: script.turn_on data: entity_id: "{%-\n set scr = {\n 'timer.finished': 'script.lights_off',\n\ \ 'timer.started': 'script.lights_on',\n 'timer.restarted': 'script.lights_on'\n\ \ }\n -%}\n{{ scr[trigger.event.event_type] }}" variables: ctrl_light: light.bed ctrl_all: '{{ is_state(''binary_sensor.night_mode'', ''off'') }}' brightness_pct: '{{ cfg.brightness }}' transition: '{{ cfg.transition }}' color_temp: '{{ cfg.temp }}' - alias: bed_charger id: bed_charger triggers: - trigger: zone entity_id: device_tracker.root zone: zone.home event: enter id: home_enter - trigger: zone entity_id: device_tracker.root zone: zone.home event: leave id: home_exit - trigger: numeric_state entity_id: sensor.pixel_6a_battery_level below: 10 id: charge_start - trigger: time at: 05:50:00 id: time_start - trigger: state entity_id: sensor.pixel_6a_charger_type to: none id: charge_stop for: seconds: 30 mode: restart actions: - choose: - conditions: - condition: or conditions: - condition: trigger id: - time_start - condition: and conditions: - condition: numeric_state entity_id: sensor.pixel_6a_battery_level below: 5 - condition: trigger id: - home_enter - charge_start - condition: state entity_id: device_tracker.root state: home - condition: state entity_id: switch.bed_switch_2 state: 'off' sequence: - action: switch.turn_on entity_id: - switch.bed_switch_2 - conditions: - condition: or conditions: - condition: and conditions: - condition: trigger id: - charge_stop - condition: numeric_state entity_id: sensor.pixel_6a_battery_level above: 95 - condition: and conditions: - condition: trigger id: - home_exit - condition: state entity_id: sensor.pixel_6a_charger_type state: none - condition: state entity_id: switch.bed_switch_2 state: 'on' sequence: - action: switch.turn_off entity_id: - switch.bed_switch_2 - alias: ligth_city_2 id: ligth_city_2 triggers: - trigger: state entity_id: binary_sensor.motion_city_2 to: 'on' id: light_on - trigger: state entity_id: light.city_2 to: 'on' for: minutes: 5 seconds: 30 id: light_off - trigger: state entity_id: binary_sensor.motion_city_2 to: 'off' for: seconds: 90 id: light_off mode: restart actions: - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: light.city_2 state: 'off' - condition: sun after: sunset sequence: - action: light.turn_on target: entity_id: light.city_2 data: brightness_pct: 90 - delay: milliseconds: 250 - action: light.turn_on target: entity_id: light.city_2 data: color_temp_kelvin: 3300 - conditions: - condition: trigger id: - light_off - condition: and conditions: - condition: state entity_id: light.city_2 state: 'on' - condition: state entity_id: binary_sensor.motion_city_2 state: 'off' sequence: - action: light.turn_off target: entity_id: light.city_2 - alias: remote_city_2 id: remote_city_2 triggers: - trigger: mqtt topic: tele/zha-bridge-city/054B/SENSOR mode: restart actions: - choose: - conditions: - condition: template value_template: "{{\n trigger.payload_json.ZbReceived[\"0x054B\"] is defined\ \ and\n trigger.payload_json.ZbReceived[\"0x054B\"].Power == 0\n}}" - condition: state entity_id: light.city_2 state: 'on' sequence: - action: light.turn_off target: entity_id: light.city_2 - condition: state entity_id: automation.ligth_city_2 state: 'off' - action: automation.turn_on target: entity_id: automation.ligth_city_2 - conditions: - condition: template value_template: "{{\n trigger.payload_json.ZbReceived[\"0x054B\"] is defined\ \ and\n trigger.payload_json.ZbReceived[\"0x054B\"].Power == 0\n}}" - condition: state entity_id: light.city_2 state: 'off' - condition: state entity_id: automation.ligth_city_2 state: 'on' sequence: - action: automation.turn_off target: entity_id: automation.ligth_city_2 - action: light.turn_on target: entity_id: light.city_2 data: brightness_pct: 95 - action: light.turn_on target: entity_id: light.city_2 data: color_temp_kelvin: 2850 - conditions: - condition: template value_template: "{{\n trigger.payload_json.ZbReceived[\"0x054B\"] is defined\ \ and\n trigger.payload_json.ZbReceived[\"0x054B\"].Power == 1\n}}" - condition: state entity_id: light.city_2 state: 'on' sequence: - action: light.turn_on target: entity_id: light.city_2 data: color_temp_kelvin: "{% from 'tools.jinja' import to_temp %} {%- set var\ \ = state_attr('light.city_2', 'color_temp') | float(0) + ((454 - 250)\ \ / 8) -%} {%- if var > 454 -%}\n {%- set var = 250 -%}\n{%- endif -%}\ \ {{ to_temp(var) }}" - conditions: - condition: template value_template: "{{\n trigger.payload_json.ZbReceived[\"0x054B\"] is defined\ \ and\n trigger.payload_json.ZbReceived[\"0x054B\"].Power == 2\n }}" - condition: state entity_id: light.city_2 state: 'on' sequence: - action: light.turn_on target: entity_id: light.city_2 data: brightness: "{%- set var = state_attr('light.city_2', 'brightness') | float(0)\ \ + ((254 - 1) / 8) -%} {%- if var > 254 -%}\n {%- set var = 1 -%}\n\ {%- endif -%} {{ var | int(0) }}" - conditions: - condition: template value_template: "{{\n trigger.payload_json.ZbReceived[\"0x054B\"] is defined\ \ and\n trigger.payload_json.ZbReceived[\"0x054B\"].Power == 1\n }}" - condition: state entity_id: light.city_2 state: 'off' sequence: - action: light.turn_on target: entity_id: light.city_2 data: brightness_pct: 85 - conditions: - condition: template value_template: "{{\n trigger.payload_json.ZbReceived[\"0x054B\"] is defined\ \ and\n trigger.payload_json.ZbReceived[\"0x054B\"].Power == 2\n}}" - condition: state entity_id: light.city_2 state: 'off' sequence: - action: light.turn_on target: entity_id: light.city_2 data: brightness_pct: 1 - alias: heat_city_2 id: heat_city_2 triggers: - trigger: zone entity_id: device_tracker.root zone: zone.city event: enter id: trigger_on - trigger: zone entity_id: device_tracker.root zone: zone.city event: leave id: trigger_off - trigger: numeric_state entity_id: sensor.city_root_distance above: 15 id: trigger_auto_off - trigger: time at: '23:30:00' id: trigger_off - trigger: time at: '10:45:00' id: trigger_on mode: restart actions: - choose: - conditions: - condition: trigger id: - trigger_on - condition: zone entity_id: device_tracker.root zone: zone.city - condition: time after: '10:45:00' before: '23:50:00' - condition: state entity_id: climate.city_2 state: 'off' sequence: - action: climate.set_hvac_mode data: entity_id: climate.city_2 hvac_mode: heat - conditions: - condition: trigger id: - trigger_off - condition: state entity_id: climate.city_2 state: heat sequence: - action: climate.set_hvac_mode data: entity_id: climate.city_2 hvac_mode: 'off' - conditions: - condition: trigger id: - trigger_auto_off sequence: - action: climate.set_hvac_mode data: entity_id: climate.city_2 hvac_mode: 'off' - action: automation.turn_off data: entity_id: automation.heat_city_2 - alias: waterheater_city id: waterheater_city triggers: - trigger: numeric_state entity_id: sensor.city_root_distance below: 25 id: trigger_on - trigger: numeric_state entity_id: sensor.city_root_distance above: 45 id: trigger_off mode: restart actions: - choose: - conditions: - condition: trigger id: - trigger_on - condition: state entity_id: switch.waterheater_city_schedule state: 'off' sequence: - action: switch.turn_on target: entity_id: - switch.waterheater_city_schedule - event: waterheater event_data: city: schedule_on - conditions: - condition: trigger id: - trigger_off - condition: state entity_id: switch.waterheater_city_schedule state: 'on' sequence: - action: switch.turn_off target: entity_id: - switch.waterheater_city_schedule - event: waterheater event_data: city: schedule_off - alias: waterheater_city_reheat id: waterheater_city_reheat triggers: - trigger: numeric_state entity_id: sensor.waterheater_city below: 19.5 id: trigger_on - trigger: numeric_state entity_id: sensor.waterheater_city above: 35.5 id: trigger_off - trigger: event event_type: waterheater event_data: city: schedule_on id: check_on - trigger: event event_type: waterheater event_data: city: trigger_off id: check_off conditions: - condition: state entity_id: switch.waterheater_city_schedule state: 'on' mode: restart actions: - choose: - conditions: - condition: trigger id: - trigger_on - condition: time after: 08:00:00 before: '20:30:00' - condition: state entity_id: switch.waterheater_city state: 'off' sequence: - action: switch.turn_on target: entity_id: switch.waterheater_city - conditions: - condition: trigger id: - trigger_off - condition: time after: 08:00:00 - condition: state entity_id: switch.waterheater_city state: 'on' sequence: - action: switch.turn_off target: entity_id: switch.waterheater_city - choose: - conditions: - condition: trigger id: - check_on - condition: time after: '13:00:00' before: '19:30:00' - condition: numeric_state entity_id: sensor.waterheater_city below: 33 - condition: state entity_id: switch.waterheater_city state: 'off' sequence: - action: switch.turn_on target: entity_id: switch.waterheater_city - conditions: - condition: trigger id: - check_off - condition: state entity_id: switch.waterheater_city state: 'on' sequence: - action: switch.turn_off target: entity_id: switch.waterheater_city - alias: av_switch_city_1 id: av_switch_city_1 triggers: - trigger: zone entity_id: device_tracker.root zone: zone.city event: enter id: trigger_on - trigger: numeric_state entity_id: sensor.city_root_distance above: 45 id: trigger_off mode: restart actions: - choose: - conditions: - condition: trigger id: - trigger_on - condition: state entity_id: switch.switch_city_av state: 'off' sequence: - action: switch.turn_on data: entity_id: - switch.switch_city_av - conditions: - condition: trigger id: - trigger_off - condition: state entity_id: switch.switch_city_av state: 'on' sequence: - action: switch.turn_off data: entity_id: - switch.switch_city_av - alias: cliamate_city1_swing_set id: cliamate_city1_swing_set triggers: - trigger: state entity_id: - input_select.cliamate_city1_swingv id: trigger_v - trigger: state entity_id: - input_select.cliamate_city1_swingh id: trigger_h mode: parallel max: 2 max_exceeded: warning actions: - choose: - conditions: - condition: trigger id: - trigger_v sequence: - action: tasmota_irhvac.set_swingv data: entity_id: climate.city_1 swingv: "{{\n states(trigger.entity_id)\n }}" - conditions: - condition: trigger id: - trigger_h sequence: - action: tasmota_irhvac.set_swingh data: entity_id: climate.city_1 swingh: "{{\n states(trigger.entity_id)\n }}" - id: climate_night alias: climate_night triggers: - trigger: state entity_id: binary_sensor.climate_night to: 'on' id: to_on - trigger: state entity_id: binary_sensor.climate_night to: 'off' id: to_off - trigger: state entity_id: switch.climate_control to: 'off' id: to_off conditions: - condition: template value_template: "{{\n trigger.from_state.state not in ['unknown', 'unavailable']\n\ \ }}" mode: restart actions: - choose: - conditions: - condition: trigger id: - to_on - condition: state entity_id: switch.climate_control state: 'on' sequence: - action: scene.create data: scene_id: restore_night_mode snapshot_entities: - fan.bed_climate - fan.office_climate - fan.living_climate - climate.temp_bed - climate.temp_office - climate.temp_living - number.temperature_control - action: number.set_value data: entity_id: - number.temperature_control value: "{%-\n set val = {\n 'auto': state_attr('climate.pump', 'temperature'),\n\ \ 'heating': state_attr('climate.pump', 'temperature') - 1,\n \ \ 'cooling': state_attr('climate.pump', 'temperature') + 1,\n }\n\ -%} {{ val[states('select.operation_mode')] }}" - action: climate.set_temperature data: entity_id: climate.temp_living temperature: "{%-\n set val = {\n 'auto': state_attr('climate.temp_living',\ \ 'temperature'),\n 'heating': state_attr('climate.temp_living',\ \ 'temperature') - 0.5,\n 'cooling': state_attr('climate.temp_living',\ \ 'temperature') + 0.5,\n }\n-%} {{ val[states('select.operation_mode')]\ \ }}" - action: climate.set_temperature data: entity_id: climate.temp_office temperature: "{%-\n set val = {\n 'auto': state_attr('climate.temp_office',\ \ 'temperature'),\n 'heating': state_attr('climate.temp_office',\ \ 'temperature') - 0.5,\n 'cooling': state_attr('climate.temp_office',\ \ 'temperature') + 0.5,\n }\n-%} {{ val[states('select.operation_mode')]\ \ }}" - action: climate.set_temperature data: entity_id: climate.temp_bed temperature: "{%-\n set val = {\n 'auto': state_attr('climate.temp_bed',\ \ 'temperature'),\n 'heating': state_attr('climate.temp_bed', 'temperature')\ \ - 0.5,\n 'cooling': state_attr('climate.temp_bed', 'temperature')\ \ + 0.5,\n }\n-%} {{ val[states('select.operation_mode')] }}" - action: fan.set_preset_mode data: entity_id: - fan.living_climate - fan.office_climate - fan.bed_climate preset_mode: night - conditions: - condition: trigger id: - to_off - condition: template value_template: "{{\n states.scene.restore_night_mode.state is defined\n\ \ }}" sequence: - action: scene.turn_on data: entity_id: scene.restore_night_mode - action: scene.delete data: entity_id: scene.restore_night_mode - id: clima_max_restore_fans alias: clima_max_restore_fans triggers: - trigger: state entity_id: device_tracker.root from: not_home to: home for: minutes: 10 id: to_home - trigger: state entity_id: device_tracker.root from: home to: not_home for: minutes: 10 id: to_away - trigger: state entity_id: input_boolean.clima_max to: 'off' for: seconds: 5 id: to_timeout mode: restart actions: - choose: - conditions: - condition: trigger id: - to_home - to_away - to_timeout sequence: - action: scene.turn_on data: entity_id: scene.clima_max_mode_fan - action: automation.turn_off data: entity_id: automation.clima_max_restore_fans - id: clima_max_restore_temps alias: clima_max_restore_temps triggers: - trigger: state entity_id: device_tracker.root from: not_home to: home for: minutes: 10 id: to_home - trigger: state entity_id: device_tracker.root from: home to: not_home for: minutes: 10 id: to_away - trigger: state entity_id: input_boolean.clima_max to: 'off' for: seconds: 5 id: to_timeout mode: restart actions: - choose: - conditions: - condition: trigger id: - to_home - to_away - to_timeout sequence: - action: scene.turn_on data: entity_id: scene.clima_max_mode_temp - action: automation.turn_off data: entity_id: automation.clima_max_restore_temps - id: clima_max_restore_switch alias: clima_max_restore_switch triggers: - trigger: state entity_id: input_boolean.clima_max to: 'off' for: minutes: 20 id: turn_off - trigger: state entity_id: alert.clima_max_restore_switch to: 'off' id: cancel mode: restart actions: - choose: - conditions: - condition: trigger id: - turn_off sequence: - action: notify.gmail data: title: clima max message: heat pump auto swiched off - action: switch.turn_off data: entity_id: - switch.climate_control - conditions: - condition: trigger id: - cancel sequence: - action: notify.gmail data: title: clima max message: heat pump skip restore - action: alert.turn_on data: entity_id: - alert.clima_max_restore_switch - action: automation.turn_off data: entity_id: - automation.clima_max_restore_switch - id: clima_sync alias: clima_sync triggers: - trigger: state entity_id: select.operation_mode for: seconds: 10 id: mode - trigger: state entity_id: - switch.climate_control to: 'on' for: seconds: 10 id: state - trigger: state entity_id: - binary_sensor.pump_temp_on_off to: 'on' for: seconds: 15 id: state_temp - trigger: state entity_id: - switch.climate_control to: 'off' for: minutes: 15 id: state - trigger: state entity_id: - binary_sensor.pump_temp_on_off to: 'off' for: minutes: 15 id: state_temp - trigger: homeassistant event: start id: start_up - trigger: state entity_id: automation.clima_max_restore_fans to: 'off' for: seconds: 10 id: max_off - trigger: state entity_id: - binary_sensor.space_cooling - binary_sensor.space_heating id: thermostat_on_off for: seconds: 10 - trigger: state entity_id: binary_sensor.thermostat_pump to: 'on' for: seconds: 10 id: thermostat_on_off conditions: - condition: or conditions: - condition: template value_template: "{{\n trigger.from_state.state not in ['unknown', 'unavailable']\ \ and\n trigger.to_state.state not in ['unknown', 'unavailable']\n }}" - condition: trigger id: - start_up - max_off mode: queued trace: stored_traces: 20 actions: - choose: - conditions: - condition: trigger id: - mode sequence: - action: script.turn_on target: entity_id: "{%-\n set val = {\n 'auto': 'script.climate_auto',\n\ \ 'heating': 'script.climate_heat',\n 'cooling': 'script.climate_cool',\n\ \ }\n-%} {{ val[trigger.to_state.state] }}" - choose: - conditions: - condition: or conditions: - condition: trigger id: - state - condition: and conditions: - condition: trigger id: - state_temp - condition: state entity_id: - switch.climate_control state: 'on' sequence: - action: "{%-\n set val = {\n 'off': 'fan.turn_off',\n 'on': 'fan.turn_on'\n\ \ }\n -%}\n{{ val[trigger.to_state.state] }}" target: entity_id: - fan.living_climate - fan.bed_climate - fan.office_climate - choose: - conditions: - condition: or conditions: - condition: trigger id: start_up - condition: and conditions: - condition: trigger id: - state - condition: state entity_id: - switch.climate_control state: 'on' - condition: state entity_id: - automation.clima_max_restore_fans state: 'off' - condition: and conditions: - condition: trigger id: - max_off - condition: state entity_id: - automation.fans_speed_modulation state: 'on' sequence: - delay: seconds: 5 - action: fan.set_preset_mode data: entity_id: - fan.living_climate - fan.bed_climate - fan.office_climate preset_mode: silent - delay: seconds: 5 - action: fan.set_preset_mode data: entity_id: - fan.living_climate - fan.bed_climate - fan.office_climate preset_mode: auto - choose: - conditions: - condition: trigger id: - thermostat_on_off - condition: state entity_id: binary_sensor.space_heating state: 'on' - condition: state entity_id: switch.pump_ctrl_heating state: 'off' sequence: - action: switch.turn_on entity_id: switch.pump_ctrl_heating - conditions: - condition: trigger id: - thermostat_on_off - condition: state entity_id: binary_sensor.space_heating state: 'off' - condition: state entity_id: switch.pump_ctrl_heating state: 'on' sequence: - action: switch.turn_off entity_id: switch.pump_ctrl_heating - conditions: - condition: trigger id: - thermostat_on_off - condition: state entity_id: binary_sensor.space_cooling state: 'on' - condition: state entity_id: switch.pump_ctrl_cooling state: 'off' sequence: - action: switch.turn_on entity_id: switch.pump_ctrl_cooling - conditions: - condition: trigger id: - thermostat_on_off - condition: state entity_id: binary_sensor.space_cooling state: 'off' - condition: state entity_id: switch.pump_ctrl_cooling state: 'on' sequence: - action: switch.turn_off entity_id: switch.pump_ctrl_cooling - id: clima_max alias: clima_max triggers: - trigger: state entity_id: input_boolean.clima_max to: 'on' id: to_on - trigger: state entity_id: input_boolean.clima_max to: 'on' for: minutes: '{{ states(''input_number.clima_max'') |int(10) }}' id: to_timeout mode: restart actions: - variables: pump_temp: "{%-\n set val = {\n 'auto': state_attr('climate.pump',\ \ 'temperature'),\n 'heating': state_attr('climate.pump', 'temperature')\ \ + 1,\n 'cooling': state_attr('climate.pump', 'temperature') - 1,\n\ \ }\n -%}\n{{\n max(\n [\n min(\n [\n \ \ val[states('select.operation_mode')],\n state_attr('climate.pump',\ \ 'max_temp')\n ]\n ),\n state_attr('climate.pump',\ \ 'min_temp')\n ]\n )\n }}\n" clima_temp: "{%-\n set val = {\n 'auto': state_attr('climate.temp_living',\ \ 'temperature'),\n 'heating': state_attr('climate.temp_living', 'temperature')\ \ + 1.5,\n 'cooling': state_attr('climate.temp_living', 'temperature')\ \ - 1.5,\n }\n -%}\n{{\n max(\n [\n min(\n \ \ [\n val[states('select.operation_mode')],\n \ \ state_attr('climate.temp_living', 'max_temp')\n ]\n \ \ ),\n state_attr('climate.temp_living', 'min_temp')\n \ \ ]\n )\n }}\n" - choose: - conditions: - condition: or conditions: - condition: trigger id: - to_on sequence: - if: - condition: state entity_id: - fan.bed_climate - fan.office_climate - fan.living_climate state: 'off' then: - action: fan.turn_on data: entity_id: - fan.bed_climate - fan.office_climate - fan.living_climate - action: scene.create data: scene_id: clima_max_mode_fan snapshot_entities: - fan.bed_climate - fan.office_climate - fan.living_climate - if: - condition: state entity_id: select.operation_mode state: - cooling - auto then: - action: scene.create data: scene_id: clima_max_mode_temp snapshot_entities: - climate.temp_bed - climate.temp_office - climate.temp_living - number.temperature_control - if: - condition: state entity_id: select.operation_mode state: heating then: - action: scene.create data: scene_id: clima_max_mode_temp snapshot_entities: - climate.temp_bed - climate.temp_office - climate.temp_living - climate.bath_tvr - number.temperature_control - action: fan.set_preset_mode data: entity_id: - fan.living_climate - fan.office_climate - fan.bed_climate preset_mode: max - if: - condition: state entity_id: select.operation_mode state: - cooling - auto then: - action: climate.set_temperature data: entity_id: - climate.temp_bed - climate.temp_living - climate.temp_office temperature: '{{ clima_temp }} ' - if: - condition: state entity_id: select.operation_mode state: heating then: - action: climate.set_hvac_mode data: entity_id: climate.bath_tvr hvac_mode: heat - delay: milliseconds: 500 - action: climate.set_preset_mode data: entity_id: climate.bath_tvr preset_mode: manual - delay: milliseconds: 500 - action: climate.set_temperature data: entity_id: - climate.temp_bed - climate.temp_living - climate.temp_office - climate.bath_tvr temperature: '{{ clima_temp }} ' - action: number.set_value data: entity_id: - number.temperature_control value: '{{ pump_temp }}' - action: automation.turn_on data: entity_id: - automation.clima_max_restore_fans - automation.clima_max_restore_temps - if: - condition: state entity_id: switch.climate_control state: 'off' then: - action: automation.turn_on data: entity_id: - automation.clima_max_restore_switch - action: switch.turn_on data: entity_id: - switch.climate_control else: - action: notify.gmail data: title: clima max message: heat pump skip auto swich off - conditions: - condition: or conditions: - condition: trigger id: - to_timeout sequence: - action: input_boolean.turn_off data: entity_id: - input_boolean.clima_max - alias: fans_speed_modulation id: fans_speed_modulation triggers: - trigger: numeric_state entity_id: - sensor.speed_living_climate - sensor.speed_office_climate - sensor.speed_bed_climate below: 1230 above: 1210 for: minutes: 20 id: to_max - trigger: numeric_state entity_id: - sensor.speed_living_climate - sensor.speed_office_climate - sensor.speed_bed_climate below: 560 above: 540 for: minutes: 10 id: to_max - trigger: numeric_state entity_id: - sensor.speed_living_climate - sensor.speed_office_climate - sensor.speed_bed_climate below: 100 id: to_max - trigger: numeric_state entity_id: - sensor.speed_living_climate - sensor.speed_office_climate - sensor.speed_bed_climate below: 690 above: 670 for: minutes: 10 id: to_auto - trigger: numeric_state entity_id: - sensor.speed_living_climate - sensor.speed_office_climate - sensor.speed_bed_climate above: 1690 for: minutes: 10 id: to_auto conditions: - condition: state entity_id: switch.climate_control state: 'on' - condition: state entity_id: - fan.living_climate - fan.bed_climate - fan.office_climate attribute: preset_mode state: - auto - max - condition: state entity_id: - automation.clima_max_restore_fans state: 'off' mode: parallel max: 10 trace: stored_traces: 30 actions: - variables: fan: "{%-\n set map = {\n 'sensor.speed_living_climate': 'fan.living_climate',\n\ \ 'sensor.speed_office_climate': 'fan.office_climate',\n 'sensor.speed_bed_climate':\ \ 'fan.bed_climate',\n }\n -%}\n{{ map[trigger.entity_id] }}" - choose: - conditions: - condition: trigger id: - to_auto - condition: template value_template: "{{\n is_state_attr( fan, 'preset_mode', 'max' )\n }}" sequence: - action: fan.set_preset_mode data: entity_id: "{{\n fan\n }}" preset_mode: auto - conditions: - condition: trigger id: - to_max - condition: template value_template: "{{\n is_state_attr( fan, 'preset_mode', 'auto' )\n }}" sequence: - action: fan.set_preset_mode data: entity_id: "{{\n fan\n }}" preset_mode: max - alias: apply_offsets id: apply_offsets triggers: - trigger: state entity_id: - input_number.living_offset - input_number.office_offset - input_number.bed_offset mode: parallel max: 10 trace: stored_traces: 20 max_exceeded: warning actions: - action: modbus.write_register data: hub: gw_rs485 slave: "{%-\n set map = {\n 'input_number.living_offset': 10,\n \ \ 'input_number.office_offset': 30,\n 'input_number.bed_offset':\ \ 20,\n }\n -%}\n{{ map[trigger.entity_id] }}" address: 242 value: "{{\n (states(trigger.entity_id) | float(0) * 10) | int (0) |\n \ \ pack('>h') | unpack('>H')\n }}" - delay: milliseconds: 10000 - action: homeassistant.update_entity data: entity_id: "{%-\n set map = {\n 'input_number.living_offset': 'climate.temp_living',\n\ \ 'input_number.office_offset': 'climate.temp_office',\n 'input_number.bed_offset':\ \ 'climate.temp_bed',\n }\n -%}\n{{ map[trigger.entity_id] }}" - id: climate_offset alias: climate_offset triggers: - trigger: state entity_id: - switch.climate_control to: 'on' for: seconds: 10 id: to_on variables: run: "{%- if state_attr('automation.climate_offset', 'last_triggered') -%}\n\ \ {{\n now() - state_attr('automation.climate_offset', 'last_triggered')\ \ > timedelta(hours=20)\n }}\n{%- else -%}\n true\n{%- endif -%}" mode: restart actions: - choose: - conditions: - condition: trigger id: - to_on sequence: - if: - condition: template value_template: "{{\n run\n }}" then: - action: input_number.set_value data: entity_id: - input_number.living_offset - input_number.office_offset - input_number.bed_offset value: 0.0 - wait_for_trigger: - trigger: state entity_id: - automation.apply_offsets attribute: current to: 0 for: seconds: 15 timeout: seconds: 30 continue_on_timeout: true - delay: seconds: '{{ wait.remaining }}' - variables: living: '{{ (states(''sensor.temp_living'') | float - state_attr(''climate.temp_living'', ''current_temperature'')) | round(1, ''ceil'') }}' office: '{{ (states(''sensor.office_temp'') | float - state_attr(''climate.temp_office'', ''current_temperature'')) | round(1, ''ceil'') }}' bed: '{{ (states(''sensor.bed_temp'') | float - state_attr(''climate.temp_bed'', ''current_temperature'')) | round(1, ''ceil'') }}' - action: persistent_notification.create data: title: temp diff message: 'living: {{ living }} office: {{ office }} bed: {{ bed }}' - action: input_number.set_value data: entity_id: - input_number.living_offset value: '{{ living }}' - action: input_number.set_value data: entity_id: - input_number.office_offset value: '{{ office }}' - action: input_number.set_value data: entity_id: - input_number.bed_offset value: '{{ bed }}' else: - action: logbook.log data_template: name: climate_offset message: skipped - alias: tariff_switch id: tariff_switch triggers: - trigger: time at: 06:00:00 id: peak variables: s: win - trigger: time at: 07:00:00 id: peak variables: s: sum - trigger: time at: '22:00:00' id: offpeak variables: s: win - trigger: time at: '23:00:00' id: offpeak variables: s: sum conditions: - condition: template value_template: "{%- set data = {\n 'win' : [1, 2, 3, 11, 12],\n \ \ 'sum' : [4, 5, 6, 7, 8, 9, 10],\n }\n -%}\n{{ now().month in data[s]\ \ }}" mode: restart actions: - action: select.select_option target: entity_id: - select.monthly_energy - select.daily_energy data: option: '{{ trigger.id }}' - alias: n0ll_home id: n0ll_home triggers: - trigger: state entity_id: device_tracker.n0ll from: not_home to: home mode: restart actions: - choose: - conditions: - condition: state entity_id: media_player.livingtv state: idle sequence: - action: "{%-\n set scr = {\n 'off': 'shell_command.kodi_screensaver',\n\ \ 'on': 'script.radio_on'\n }\n -%}\n{{ scr[states('binary_sensor.kodi_screen_saver')]\ \ }}" - condition: state entity_id: media_player.ht_mt500_501_b34d6a state: playing - action: timer.pause entity_id: timer.sound_bar - alias: home_near id: home_near triggers: - trigger: numeric_state entity_id: sensor.home_root_distance below: 35 - trigger: numeric_state entity_id: sensor.home_root_distance below: 10 mode: restart actions: - action: notify.gmail data: message: home near trigger title: hass - action: automation.turn_on data: entity_id: - automation.home_away - automation.living_tv - action: switch.turn_on data: entity_id: - switch.living_tv - switch.bed_switch_1 - action: automation.turn_off data: entity_id: automation.home_near - alias: root_home id: root_home initial_state: false triggers: - trigger: zone entity_id: device_tracker.root zone: zone.home event: enter conditions: - condition: template value_template: "{{\n trigger.from_state != None\n }}" actions: - action: automation.turn_on entity_id: automation.just_home - alias: just_home id: just_home triggers: - trigger: state entity_id: binary_sensor.hall_motion to: 'on' - trigger: state entity_id: binary_sensor.living_motion to: 'on' - trigger: state entity_id: binary_sensor.door to: 'on' mode: single max_exceeded: silent actions: - action: input_boolean.turn_off entity_id: input_boolean.home_motion - choose: - conditions: - condition: state entity_id: media_player.livingtv state: idle sequence: - action: script.turn_on data: entity_id: - script.radio_on - choose: - conditions: - condition: state entity_id: input_boolean.lumi_double_switch_1 state: 'off' - condition: state entity_id: binary_sensor.day state: 'off' sequence: - action: script.turn_on target: entity_id: script.lumi_all_lights_on data: variables: bri_t: 85 time_t: '{{ (states(''input_number.just_home_light_timer'') | float(2) * 60.0) | int(60) }}' - action: automation.turn_off data: entity_id: - automation.just_home - alias: living_tv id: living_tv triggers: - trigger: state entity_id: device_tracker.livingtv to: home for: seconds: 45 actions: - action: notify.gmail data: message: living near trigger title: hass - action: automation.turn_off data: entity_id: automation.living_tv - alias: reload_homeconect id: reload_homeconect triggers: - trigger: state entity_id: - device_tracker.washer - device_tracker.dryer - device_tracker.dishwasher to: home for: seconds: 15 actions: - action: button.press data: entity_id: button.home_connect_refresh - alias: auto_lock id: auto_lock trace: stored_traces: 20 triggers: - trigger: state entity_id: binary_sensor.door from: 'on' to: 'off' id: lock_on_door for: seconds: 30 - trigger: state entity_id: lock.building to: locked for: minutes: 1 id: lock_on_building - trigger: zone entity_id: device_tracker.root zone: zone.home event: enter id: lock_off - trigger: zone entity_id: device_tracker.root zone: zone.home event: leave id: lock_on - trigger: state entity_id: input_boolean.in_bed_dummy_switch to: 'on' for: minutes: 1 id: lock_on - trigger: mqtt topic: nuki/opener/trigger payload: button id: lock_off_building conditions: - condition: template value_template: "{{\n trigger.from_state != None\n }}" mode: restart actions: - choose: - conditions: - condition: trigger id: - lock_on_door - condition: state entity_id: lock.door state: unlocked - condition: state entity_id: input_boolean.auto_lock state: 'on' sequence: - action: lock.lock target: entity_id: lock.door - conditions: - condition: or conditions: - condition: trigger id: - lock_on - condition: and conditions: - condition: trigger id: - lock_on_building - condition: state entity_id: - device_tracker.root state: not_home - condition: state entity_id: lock.door state: unlocked sequence: - if: - condition: state entity_id: binary_sensor.door state: 'off' then: - action: lock.lock target: entity_id: lock.door else: - action: notify.gmail data: title: front door message: "{%-\n set door = {\n 'on': 'open',\n 'off': 'close'\n\ \ }\n -%}\nis {{ door[states('binary_sensor.door')]}}" - choose: - conditions: - condition: trigger id: - lock_on - condition: state entity_id: lock.building state: unlocked sequence: - action: lock.lock target: entity_id: lock.building - conditions: - condition: trigger id: - lock_off - condition: state entity_id: lock.building state: locked sequence: - action: script.turn_on target: entity_id: script.doors_full_unlock - choose: - conditions: - condition: trigger id: - lock_off_building - condition: state entity_id: lock.building state: unlocked - condition: state entity_id: lock.door state: locked sequence: - action: lock.unlock target: entity_id: lock.door - alias: ring_notify id: ring_notify triggers: - trigger: state entity_id: binary_sensor.building_ring to: 'on' mode: single max_exceeded: silent actions: - action: script.all_notify data: icon_notify: door tit: ring msg: door - delay: seconds: 60 - alias: shutter_wind id: shutter_wind triggers: - trigger: numeric_state entity_id: sensor.shutters_vibration above: 2.5 id: notify - trigger: numeric_state entity_id: sensor.shutters_vibration above: 0 id: detected - trigger: numeric_state entity_id: sensor.shutters_vibration above: 5.5 id: move_first - trigger: numeric_state entity_id: sensor.shutters_vibration above: 10.5 id: move_second - trigger: numeric_state entity_id: sensor.wind_vibration above: 15.0 id: move_tilt - trigger: template value_template: "{{\n (\n float(state_attr('sensor.shutters_open_speed_wind',\ \ 'speed_open'), 5) >\n float(states('sensor.local_wind_speed'), 6)\n\ \ ) and\n (\n float(states('sensor.local_wind_speed'), 5) >\n\ \ float(states('sensor.local_forecast_wind_speed'), 6)\n ) and\n\ \ (\n float(state_attr('sensor.shutters_open_speed_wind', 'forecast_speed_open'),\ \ 5) >\n float(states('sensor.local_forecast_wind_speed'), 6)\n \ \ ) and\n (\n float(states('sensor.wind_vibration'), 6) < 3.0\n\ \ )\n }}" id: move_restore - trigger: event event_type: up_down_my event_data: data: start id: start conditions: - condition: template value_template: "{{\n ( trigger.from_state is defined and\n trigger.from_state.state\ \ not in ['unknown', 'unavailable'] and\n trigger.to_state.state not\ \ in ['unknown', 'unavailable']\n ) or\n trigger.id == 'start'\n \ \ }}" mode: queued trace: stored_traces: 30 actions: - choose: - conditions: - condition: trigger id: - notify - condition: numeric_state entity_id: cover.bed attribute: current_tilt_position below: 80 sequence: - action: script.all_notify data: icon_notify: window-shutter-alert tit: shutters msg: detected vibration - event: shutter_event event_data: wind: notify - conditions: - condition: trigger id: - detected - condition: numeric_state entity_id: cover.bed attribute: current_tilt_position above: 80 - condition: numeric_state entity_id: cover.bed attribute: current_position above: 30 sequence: - action: script.all_notify data: icon_notify: window-shutter-alert tit: shutters msg: detected vibration while opned - event: shutter_event event_data: wind: detected - choose: - conditions: - condition: trigger id: - move_second - condition: numeric_state entity_id: sensor.temp_out value_template: '{{ float( float(state.state, states(''sensor.local_temperature'')), -1) }}' above: 0.0 - condition: numeric_state entity_id: cover.bed attribute: current_position below: 30 sequence: - action: cover.open_cover data: entity_id: cover.shutters - action: script.all_notify data: icon_notify: window-shutter-alert tit: shutter msg: open - event: shutter_event event_data: wind: open - conditions: - condition: trigger id: - move_first - condition: numeric_state entity_id: sensor.temp_out value_template: '{{ float( float(state.state, states(''sensor.local_temperature'')), -1) }}' above: 0.0 sequence: - if: - condition: numeric_state entity_id: cover.bed attribute: current_tilt_position below: 80 then: - action: cover.open_cover_tilt data: entity_id: cover.shutters - action: script.all_notify data: icon_notify: window-shutter-alert tit: shutter msg: tilt open - event: shutter_event event_data: wind: tilt_open_shutters else: - action: cover.open_cover data: entity_id: cover.shutters - action: script.all_notify data: icon_notify: window-shutter-alert tit: shutter msg: open - event: shutter_event event_data: wind: open - conditions: - condition: trigger id: - move_restore - condition: numeric_state entity_id: sensor.temp_out value_template: '{{ float( float(state.state, states(''sensor.local_temperature'')), -1) }}' above: 0.0 - condition: numeric_state entity_id: sensor.wind_vibration below: 3.0 sequence: - choose: - conditions: - condition: state entity_id: sensor.shutters_open_speed_wind attribute: state_shutters state: - open sequence: - if: - condition: template value_template: "{{\n states.scene.shutter_restore_pre.state is defined\ \ and\n states.scene.shutter_restore_post.state is defined\n\ \ }}" then: - action: scene.turn_on data: entity_id: scene.shutter_restore_pre - delay: milliseconds: 750 - wait_template: "{{\n states('cover.shutters') not in ['closing',\ \ 'openopening']\n }}" timeout: seconds: 120 continue_on_timeout: true - action: scene.turn_on data: entity_id: scene.shutter_restore_post - action: script.all_notify data: icon_notify: window-shutter-alert tit: shutter msg: restore else: - action: script.turn_on entity_id: - script.shutters_position_1 - action: script.all_notify data: icon_notify: window-shutter-alert tit: shutter msg: pos 1 - conditions: - condition: state entity_id: sensor.shutters_open_speed_wind attribute: state_shutters state: - tilt_open_wind - tilt_open_shutters sequence: - action: cover.set_cover_tilt_position data: entity_id: cover.shutters tilt_position: "{{\n states('input_number.shutters_tilt_position_1')\ \ | int(20)\n }}" - action: script.all_notify data: icon_notify: window-shutter-alert tit: shutter msg: pos tilt - event: shutter_event event_data: wind: close - if: - condition: template value_template: "{{\n states.scene.shutter_restore_pre.state is defined\ \ and\n states.scene.shutter_restore_post.state\n }}" then: - action: scene.delete data: entity_id: - scene.shutter_restore_pre - scene.shutter_restore_post - conditions: - condition: trigger id: - move_tilt - condition: state entity_id: input_boolean.shutter_wind_vibration_en state: 'on' - condition: numeric_state entity_id: sensor.temp_out value_template: '{{ float( float(state.state, states(''sensor.local_temperature'')), -1) }}' above: 0.0 - condition: state entity_id: sensor.shutters_open_speed_wind attribute: state_shutters state: - close sequence: - action: cover.open_cover_tilt data: entity_id: cover.shutters - action: script.all_notify data: icon_notify: window-shutter-alert tit: shutter msg: tilt open - event: shutter_event event_data: wind: tilt_open_wind - conditions: - condition: trigger id: - move_second - move_first - move_restore - condition: numeric_state entity_id: sensor.temp_out value_template: '{{ float( float(state.state, states(''sensor.local_temperature'')), -1) }}' below: 0.0 sequence: - action: script.all_notify data: icon_notify: window-shutter-alert tit: shutters data_template: msg: temp low {{ trigger.id }} - choose: - conditions: - condition: trigger id: - notify - condition: numeric_state entity_id: cover.bed attribute: current_tilt_position below: 80 - condition: numeric_state entity_id: cover.bed attribute: current_position below: 30 sequence: - action: scene.create data: scene_id: shutter_restore_post snapshot_entities: - cover.living_1 - cover.living_2 - cover.bed - cover.office - action: scene.create data: scene_id: shutter_restore_pre entities: cover.living_1: current_position: '{{ int(state_attr(''cover.living_1'', ''current_position'')) }}' current_tilt_position: 100 state: open cover.living_2: current_position: '{{ int(state_attr(''cover.living_2'', ''current_position'')) }}' current_tilt_position: 100 state: open cover.bed: current_position: '{{ int(state_attr(''cover.bed'', ''current_position'')) }}' current_tilt_position: 100 state: open cover.office: current_position: '{{ int(state_attr(''cover.office'', ''current_position'')) }}' current_tilt_position: 100 state: open - action: script.all_notify data: icon_notify: window-shutter-alert tit: shutter msg: store position - conditions: - condition: trigger id: - start - condition: numeric_state entity_id: sensor.temp_out value_template: '{{ float( float(state.state, states(''sensor.local_temperature'')), -1) }}' above: 0.0 - condition: numeric_state entity_id: cover.bed attribute: current_tilt_position above: 80 - condition: numeric_state entity_id: cover.bed attribute: current_position above: 30 - condition: template value_template: "{{\n (\n float(state_attr('sensor.shutters_open_speed_wind',\ \ 'speed_open'), 5) >\n float(states('sensor.local_wind_speed'),\ \ 6)\n ) and\n (\n float(states('sensor.local_wind_speed'),\ \ 5) >\n float(states('sensor.local_forecast_wind_speed'), 6)\n\ \ ) and\n (\n float(state_attr('sensor.shutters_open_speed_wind',\ \ 'forecast_speed_open'), 5) >\n float(states('sensor.local_forecast_wind_speed'),\ \ 6)\n )\n }}" - condition: numeric_state entity_id: sensor.shutters_vibration below: 2.5 - condition: numeric_state entity_id: sensor.wind_vibration below: 3.0 - condition: state entity_id: sensor.shutters_open_speed_wind attribute: state_shutters state: - open - tilt_open_wind - tilt_open_shutters sequence: - action: script.turn_on entity_id: - script.shutters_position_1 - action: script.all_notify data: icon_notify: window-shutter-alert tit: shutters data_template: msg: move to pos 1 wind {{ states('sensor.local_wind_speed') }} - event: shutter_event event_data: wind: close - alias: shutter_position_ctrl id: shutter_position_ctrl triggers: - trigger: numeric_state entity_id: - cover.living_2 - cover.office attribute: current_position above: 30 id: open - trigger: numeric_state entity_id: - cover.living_2 - cover.office attribute: current_position below: 30 id: close conditions: - condition: template value_template: "{{\n trigger.from_state.state not in ['unknown', 'unavailable']\ \ and\n trigger.from_state.attributes.current_position != 50 and\n \ \ trigger.to_state.attributes.current_position != 50\n }}" mode: queued actions: - variables: _map: "{%-\n set _map = {\n 'cover.office': 'input_boolean.shutter_position_office',\n\ \ 'cover.living_2': 'input_boolean.shutter_position_living_2',\n \ \ }\n -%}\n{{ _map }}" - choose: - conditions: - condition: trigger id: - open - condition: state entity_id: - sensor.shutters_open_speed_wind attribute: state_shutters state: - close - condition: template value_template: '{{ is_state(_map[trigger.entity_id], ''on'') }}' sequence: - action: input_boolean.turn_off data: entity_id: '{{ _map[trigger.entity_id] }}' - choose: - conditions: - condition: trigger id: - close - condition: state entity_id: - sensor.shutters_open_speed_wind attribute: state_shutters state: - close - condition: template value_template: '{{ is_state(_map[trigger.entity_id], ''off'') }}' sequence: - action: input_boolean.turn_on data: entity_id: '{{ _map[trigger.entity_id] }}' - alias: track_merge id: track_merge initial_state: false triggers: - trigger: state entity_id: device_tracker.ffeeddccbbaa - trigger: state entity_id: device_tracker.google_maps_107209225675467950565 actions: - action: python_script.device_tracker_merge data_template: device_name: root master_device: device_tracker.ffeeddccbbaa slave_device: device_tracker.google_maps_107209225675467950565 trigger_id: '{{trigger.entity_id}}' time: '{{ states(''input_number.tracker_delay'') | float(0) * 60 }}' force_update: '{{ states(''input_number.tracker_force_update'') | float(0) * 60 }}' accuracy: '{{ states(''input_number.tracker_accuracy'') | float(0) * 1000 }}' distance: '{{ distance(states.device_tracker.ffeeddccbbaa, states.device_tracker.google_maps_107209225675467950565) }}' - alias: track_merge_startup id: track_merge_startup triggers: - trigger: homeassistant event: start actions: - action: python_script.device_tracker_merge data_template: device_name: root master_device: device_tracker.google_maps_107209225675467950565 slave_device: device_tracker.google_maps_107209225675467950565 trigger_id: device_tracker.google_maps_107209225675467950565 time: '{{ states(''input_number.tracker_delay'') | float(0) * 60 }}' force_update: '{{ states(''input_number.tracker_force_update'') | float(0) * 60 }}' accuracy: '{{ states(''input_number.tracker_accuracy'') | float(0) * 1000 }}' distance: '{{ distance(states.device_tracker.google_maps_107209225675467950565, states.device_tracker.google_maps_107209225675467950565) }}' - delay: seconds: 5 - action: automation.turn_on entity_id: automation.track_merge - alias: auto_clean id: auto_clean triggers: - trigger: time at: 08:00:00 id: time_check - trigger: state entity_id: device_tracker.root from: home to: not_home for: minutes: 5 id: clean_notify - trigger: state entity_id: device_tracker.root from: home to: not_home for: minutes: 15 id: clean_run conditions: - condition: time weekday: - wed - sat - condition: template value_template: "{%- if state_attr('script.all_clean', 'last_triggered') -%}\n\ \ {{\n now() - state_attr('script.all_clean', 'last_triggered') > timedelta(hours=24)\n\ \ }}\n{%- else -%}\n true\n{%- endif -%}" mode: restart actions: - choose: - conditions: - condition: trigger id: - time_check - condition: state entity_id: device_tracker.root state: home sequence: - action: notify.gmail data: title: rockrobo message: check wash door - if: - condition: state entity_id: binary_sensor.clean_vacuum state: 'on' then: - delay: seconds: 5 - action: notify.gmail data: title: rockrobo message: bin full not clean - conditions: - condition: trigger id: - clean_notify - condition: state entity_id: binary_sensor.wash_door state: 'on' sequence: - action: notify.gmail data: title: rockrobo message: clean in 10 min - conditions: - condition: trigger id: - clean_run - condition: state entity_id: binary_sensor.clean_vacuum state: 'off' - condition: state entity_id: binary_sensor.wash_door state: 'on' sequence: - action: script.turn_on data: entity_id: - script.all_clean default: - action: logbook.log data: name: auto_clean message: 'check automation using default - Id: {{trigger.id}}' - alias: reset_bin_counter id: reset_bin_counter triggers: - trigger: state entity_id: binary_sensor.rockrobo_dustbin from: 'off' to: 'on' mode: restart actions: - action: counter.reset entity_id: counter.clean_counter - alias: ligth_village_1 id: ligth_village_1 triggers: - trigger: state entity_id: binary_sensor.motion_village_1 to: 'on' id: light_on - trigger: state entity_id: binary_sensor.motion_village_1 to: 'off' for: seconds: 90 id: light_off - trigger: state entity_id: light.village_1 to: 'on' for: minutes: 5 seconds: 30 id: light_off mode: restart actions: - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: light.village_1 state: 'off' - condition: sun after: sunset after_offset: -00:20:00 - condition: time before: '23:15:00' sequence: - action: light.turn_on target: entity_id: light.village_1 data: brightness_pct: 100 - delay: milliseconds: 250 - action: light.turn_on target: entity_id: light.village_1 data: color_temp_kelvin: 3300 - conditions: - condition: trigger id: - light_on - condition: state entity_id: light.village_1 state: 'off' - condition: or conditions: - condition: sun before: sunrise before_offset: -00:20:00 - condition: time after: '23:15:00' sequence: - action: light.turn_on target: entity_id: light.village_1 data: brightness_pct: 10 - delay: milliseconds: 250 - action: light.turn_on target: entity_id: light.village_1 data: color_temp_kelvin: 2500 - conditions: - condition: trigger id: - light_off - condition: and conditions: - condition: state entity_id: light.village_1 state: 'on' - condition: state entity_id: binary_sensor.motion_village_1 state: 'off' sequence: - action: light.turn_on target: entity_id: light.village_1 data: brightness_pct: 10 - delay: milliseconds: 250 - action: light.turn_off target: entity_id: light.village_1 - alias: ligth_top_1 id: ligth_top_1 triggers: - trigger: state entity_id: binary_sensor.motion_village_top_1 to: 'on' id: light_on - trigger: state entity_id: binary_sensor.motion_village_top_1 to: 'off' for: seconds: 90 id: light_off - trigger: state entity_id: light.village_top_1 to: 'on' for: minutes: 5 seconds: 30 id: light_off mode: restart actions: - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: light.village_top_1 state: 'off' - condition: sun after: sunset after_offset: -00:20:00 - condition: time before: '23:15:00' sequence: - action: light.turn_on target: entity_id: light.village_top_1 data: brightness_pct: 100 - delay: milliseconds: 250 - action: light.turn_on target: entity_id: light.village_top_1 data: color_temp_kelvin: 3300 - conditions: - condition: trigger id: - light_on - condition: state entity_id: light.village_top_1 state: 'off' - condition: or conditions: - condition: sun before: sunrise before_offset: -00:20:00 - condition: time after: '23:15:00' sequence: - action: light.turn_on target: entity_id: light.village_top_1 data: brightness_pct: 10 - delay: milliseconds: 250 - action: light.turn_on target: entity_id: light.village_top_1 data: color_temp_kelvin: 2500 - conditions: - condition: trigger id: - light_off - condition: and conditions: - condition: state entity_id: light.village_top_1 state: 'on' - condition: state entity_id: binary_sensor.motion_village_top_1 state: 'off' sequence: - action: light.turn_on target: entity_id: light.village_top_1 data: brightness_pct: 10 - delay: milliseconds: 250 - action: light.turn_off target: entity_id: light.village_top_1 - alias: ligth_village_out id: ligth_village_out triggers: - trigger: sun event: sunset offset: +00:00:00 id: sunset_on - trigger: sun event: sunset offset: +01:30:00 id: light_off - trigger: sun event: sunrise offset: +00:10:00 id: light_off - trigger: zone entity_id: device_tracker.root zone: zone.village event: enter id: presence_on - trigger: zone entity_id: device_tracker.root zone: zone.village event: leave id: presence_off mode: restart actions: - variables: brightness: '{{ range(45, 65, 2) | random }}' color_temp: '{{ range(300, 350, 10) | random }}' - choose: - conditions: - condition: or conditions: - condition: and conditions: - condition: trigger id: - sunset_on - condition: state entity_id: binary_sensor.village_presence state: 'on' - condition: and conditions: - condition: trigger id: - presence_on - condition: or conditions: - condition: sun before: sunrise before_offset: +00:30:00 - condition: sun after: sunset after_offset: -00:30:00 - condition: state entity_id: light.village_out state: 'off' sequence: - action: light.turn_on target: entity_id: light.village_out data: brightness_pct: '{{ brightness }}' - delay: milliseconds: 250 - action: light.turn_on target: entity_id: light.village_out data: color_temp_kelvin: '{{ color_temp }}' - conditions: - condition: trigger id: - light_off - presence_off - condition: state entity_id: light.village_out state: 'on' sequence: - action: light.turn_off target: entity_id: light.village_out - alias: ligth_garage id: ligth_garage triggers: - trigger: state entity_id: binary_sensor.motion_village_garage to: 'on' id: light_on - trigger: zone entity_id: device_tracker.root zone: zone.village event: enter id: light_on - trigger: state entity_id: binary_sensor.motion_village_garage to: 'off' for: seconds: 90 id: light_off - trigger: sun event: sunrise offset: +00:10:00 id: light_off - trigger: zone entity_id: device_tracker.root zone: zone.village event: leave id: presence_off mode: restart actions: - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: light.village_garage state: 'off' - condition: or conditions: - condition: sun before: sunrise before_offset: +00:30:00 - condition: sun after: sunset after_offset: -00:30:00 sequence: - action: light.turn_on target: entity_id: light.village_garage - conditions: - condition: trigger id: - light_off - presence_off - condition: and conditions: - condition: state entity_id: light.village_garage state: 'on' - condition: state entity_id: binary_sensor.motion_village_garage state: 'off' sequence: - action: light.turn_off target: entity_id: light.village_garage - alias: waterheater_village id: waterheater_village triggers: - trigger: state entity_id: binary_sensor.village_presence to: 'on' id: trigger_on - trigger: state entity_id: binary_sensor.village_presence to: 'off' for: minutes: 15 id: trigger_off mode: restart actions: - choose: - conditions: - condition: trigger id: - trigger_on - condition: state entity_id: switch.waterheater_village_schedule state: 'off' sequence: - action: switch.turn_on target: entity_id: switch.waterheater_village_schedule - event: waterheater event_data: village: schedule_on - conditions: - condition: trigger id: - trigger_off - condition: state entity_id: switch.waterheater_village_schedule state: 'on' sequence: - action: switch.turn_off target: entity_id: switch.waterheater_village_schedule - event: waterheater event_data: village: schedule_off - alias: waterheater_village_reheat id: waterheater_village_reheat triggers: - trigger: numeric_state entity_id: sensor.waterheater_village below: 19.5 id: trigger_on - trigger: numeric_state entity_id: sensor.waterheater_village above: 35.5 id: trigger_off - trigger: event event_type: waterheater event_data: village: schedule_on id: check_on - trigger: event event_type: waterheater event_data: village: trigger_off id: check_off conditions: - condition: state entity_id: switch.waterheater_village_schedule state: 'on' mode: restart actions: - choose: - conditions: - condition: trigger id: - trigger_on - condition: time after: 08:00:00 before: '19:30:00' - condition: state entity_id: switch.waterheater_village state: 'off' sequence: - action: switch.turn_on target: entity_id: switch.waterheater_village - conditions: - condition: trigger id: - trigger_off - condition: time after: 08:00:00 - condition: state entity_id: switch.waterheater_village state: 'on' sequence: - action: switch.turn_off target: entity_id: switch.waterheater_village - choose: - conditions: - condition: trigger id: - check_on - condition: time after: '13:00:00' before: '19:30:00' - condition: numeric_state entity_id: sensor.waterheater_village below: 33 - condition: state entity_id: switch.waterheater_village state: 'off' sequence: - action: switch.turn_on target: entity_id: switch.waterheater_village - conditions: - condition: trigger id: - check_off - condition: state entity_id: switch.waterheater_village state: 'on' sequence: - action: switch.turn_off target: entity_id: switch.waterheater_village - alias: village_remote_1 id: village_remote_1 triggers: - trigger: mqtt topic: tele/zha-bridge-city/A79A/SENSOR mode: restart actions: - choose: - conditions: - condition: template value_template: "{{\n trigger.payload_json.ZbReceived[\"0x054B\"] is defined\ \ and\n trigger.payload_json.ZbReceived[\"0x054B\"].Power == 0\n}}" - condition: state entity_id: light.village_out state: 'off' sequence: - action: light.turn_on target: entity_id: light.village_out data: brightness_pct: 95 - action: light.turn_on target: entity_id: light.village_out data: color_temp_kelvin: 2850 - conditions: - condition: template value_template: "{{\n trigger.payload_json.ZbReceived[\"0x054B\"] is defined\ \ and\n trigger.payload_json.ZbReceived[\"0x054B\"].Power == 0\n}}" - condition: state entity_id: light.village_out state: 'on' sequence: - action: light.turn_off target: entity_id: light.village_out - alias: lumi_switch_double_trigger_1 id: lumi_switch_double_trigger_1 triggers: - trigger: mqtt topic: zigbee2mqtt/living-cube value_template: '{{ value_json.action | default(None) }}' payload: shake - trigger: mqtt topic: zigbee2mqtt/bed-button value_template: '{{ value_json.action | default(None) }}' payload: shake - trigger: event event_type: timer.finished event_data: entity_id: timer.lumi_double_switch_1_timer actions: - action: "{%-\n set scr = {\n 'on': 'script.lumi_double_switch_off',\n\ \ 'off': 'script.lumi_double_switch_on'\n }\n -%}\n{{ scr[states('input_boolean.lumi_double_switch_1')]\ \ }}\n" - alias: down_lumi_switch_double_trigger_1 id: down_lumi_switch_double_trigger_1 triggers: - trigger: event event_type: up_down_my event_data: data: stop conditions: - condition: and conditions: - condition: state entity_id: input_boolean.lumi_double_switch_1 state: 'on' actions: - action: script.lumi_double_switch_off - alias: office_switch id: office_switch triggers: - trigger: mqtt topic: zigbee2mqtt/office-button value_template: '{{ value_json.action | default(None) }}' payload: single id: switch_low - trigger: mqtt topic: zigbee2mqtt/office-button value_template: '{{ value_json.action | default(None) }}' payload: double id: switch_high - trigger: mqtt topic: zigbee2mqtt/office-button value_template: '{{ value_json.action | default(None) }}' payload: long id: switch_off_hold - trigger: state entity_id: device_tracker.n0ll to: not_home for: seconds: 30 id: switch_off_pc mode: restart actions: - choose: - conditions: - condition: trigger id: - switch_high - switch_low - condition: state entity_id: automation.office_light state: 'on' sequence: - action: automation.turn_off target: entity_id: - automation.office_light - choose: - conditions: - condition: trigger id: - switch_high - switch_low - condition: state entity_id: light.office_window state: 'on' sequence: - action: light.turn_off target: entity_id: - light.office_window - choose: - conditions: - condition: trigger id: - switch_high - switch_low sequence: - action: script.lights_on data: ctrl_light: light.office_desk ctrl_all: true brightness_pct: "{%- set br = {\n 'switch_low': 5,\n 'switch_high':\ \ 90,\n }\n -%}\n{{ br[trigger.id] }}" transition: 3 color_temp: 4000 - conditions: - condition: state entity_id: automation.office_light state: 'off' - condition: trigger id: - switch_off_pc - switch_off_hold sequence: - action: light.turn_on target: entity_id: - light.office data: effect: okay - action: automation.turn_on target: entity_id: - automation.office_light - delay: milliseconds: 750 - event: lights_check event_data: light: turn_off - conditions: - condition: state entity_id: automation.office_light state: 'on' - condition: trigger id: - switch_off_hold sequence: - action: automation.turn_off target: entity_id: - automation.office_light - action: light.turn_on target: entity_id: - light.office data: effect: okay - delay: milliseconds: 550 - action: light.turn_off target: entity_id: - light.bed - light.wash - light.kitchen - light.bath - delay: milliseconds: 550 - action: light.turn_off target: entity_id: - light.kitchen_led - light.living - light.hall - action: light.turn_off target: entity_id: - light.office data: transition: 20 - wait_for_trigger: - trigger: state entity_id: - light.office to: 'off' timeout: seconds: 30 - delay: seconds: '{{ wait.remaining }}' - action: input_boolean.turn_on entity_id: - input_boolean.office_enter_dummy - action: automation.turn_on target: entity_id: - automation.office_light - alias: night_light_switch id: night_light_switch triggers: - trigger: mqtt topic: zigbee2mqtt/bed-button value_template: '{{ value_json.action | default(None) }}' payload: single id: single - trigger: mqtt topic: zigbee2mqtt/bed-button value_template: '{{ value_json.action | default(None) }}' payload: double id: double mode: restart actions: - variables: cfg: '{% from ''tools.jinja'' import light_cfg %} {{ light_cfg(is_state(''binary_sensor.night_mode'', ''off'')) | from_json }}' - choose: - conditions: - condition: trigger id: - single sequence: - action: script.turn_on data: entity_id: "{%-\n set scr = {\n 'on': 'script.lights_off',\n \ \ 'off': 'script.lights_on'\n }\n -%}\n{{ scr[states('light.bed')]\ \ }}" variables: ctrl_light: light.bed brightness_pct: '{{ cfg.brightness }}' transition: '{{ cfg.transition }}' color_temp: '{{ cfg.temp }}' - conditions: - condition: trigger id: - double - condition: state entity_id: - automation.bed_light state: 'on' sequence: - action: automation.turn_off entity_id: - automation.bed_light - action: light.turn_off entity_id: - light.bed - conditions: - condition: trigger id: - double - condition: state entity_id: - automation.bed_light state: 'off' sequence: - action: automation.turn_on entity_id: - automation.bed_light - action: light.turn_on target: entity_id: - light.bed data: effect: okay - alias: kitchen_switch id: kitchen_switch triggers: - trigger: mqtt topic: zigbee2mqtt/kitchen-button variables: action: '{{ trigger.payload_json.action | default(None) }}' conditions: - condition: template value_template: "{{\n action != None and\n action != 'release'\n }}" mode: restart actions: - choose: - conditions: - condition: and conditions: - condition: template value_template: '{{ action in [''double'', ''single''] }}' - condition: state entity_id: - automation.kitchen_light - automation.kitchen_light_1 state: 'on' sequence: - action: automation.turn_off data: entity_id: - automation.kitchen_light - automation.kitchen_light_1 - choose: - conditions: - condition: and conditions: - condition: template value_template: '{{ action in [''double'', ''single''] }}' - condition: state entity_id: - automation.kitchen_light - automation.kitchen_light_1 state: 'off' sequence: - variables: brightness_pct: "{%- set br = {\n 'single': 5,\n 'double': 90,\n \ \ }\n -%}\n{{ br[action] }}" color_temp: 4000 transition: 1 - action: light.turn_on target: entity_id: - light.kitchen_led data: brightness_pct: 20 - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: - light.kitchen_led data: brightness_pct: '{{ max(brightness_pct, 30) }}' - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: - light.kitchen data: color_temp_kelvin: '{{ color_temp }}' brightness_pct: 1 transition: 0 - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: - light.kitchen data: brightness_pct: '{{ brightness_pct }}' transition: '{{ transition }}' - conditions: - condition: template value_template: '{{ action == ''hold'' }}' sequence: - action: light.turn_on target: entity_id: - light.kitchen data: effect: okay - action: automation.turn_on data: entity_id: - automation.kitchen_light - automation.kitchen_light_1 - delay: milliseconds: 750 - event: lights_check event_data: light: turn_off - alias: living_switch id: living_switch triggers: - trigger: mqtt topic: zigbee2mqtt/living-cube variables: action: '{{ trigger.payload_json.action | default(None) }}' side: '{{ trigger.payload_json.side | default(-1) }}' action_angle: '{{ trigger.payload_json.action_angle | default(0) | abs }}' action_from_side: '{{ trigger.payload_json.action_from_side | default(-1) }}' action_side: '{{ trigger.payload_json.action_side | default(-1) }}' action_to_side: '{{ trigger.payload_json.action_to_side | default(-1) }}' conditions: - condition: template value_template: '{{ action != None }}' mode: restart actions: - variables: transition: 1 - choose: - conditions: - condition: and conditions: - condition: state entity_id: automation.living_light state: 'on' - condition: template value_template: '{{ action == ''flip90'' }}' - condition: template value_template: '{{ action_from_side == 0 }}' - condition: template value_template: '{{ action_side == 1 }}' - condition: template value_template: '{{ action_to_side == 1 }}' sequence: - variables: brightness_pct: "{%- if is_state('binary_sensor.night_mode', 'on') -%}\n\ \ 30\n{%- elif is_state('media_player.livingtv', 'playing') -%}\n 50\n\ {%- else -%}\n 90\n{%- endif -%}" color_temp: 4000 - action: automation.turn_off data: entity_id: - automation.living_light - automation.kitchen_light - automation.kitchen_light_1 - action: light.turn_on target: entity_id: - light.living data: color_temp_kelvin: '{{ color_temp }}' brightness_pct: 1 transition: 0 - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: - light.living data: brightness_pct: '{{ brightness_pct }}' transition: '{{ transition }}' - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: - light.kitchen_led data: brightness_pct: '{{ max(brightness_pct, 30) }}' - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: - light.kitchen data: color_temp_kelvin: '{{ color_temp }}' brightness_pct: 1 transition: 0 - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: - light.kitchen data: brightness_pct: '{{ brightness_pct }}' transition: '{{ transition }}' - conditions: - condition: and conditions: - condition: state entity_id: automation.living_light state: 'off' - condition: template value_template: '{{ action == ''flip90'' }}' - condition: template value_template: '{{ action_from_side == 1 }}' - condition: template value_template: '{{ action_side == 0 }}' - condition: template value_template: '{{ action_to_side == 0 }}' sequence: - action: light.turn_on target: entity_id: - light.living - light.kitchen data: effect: okay - action: automation.turn_on data: entity_id: - automation.living_light - automation.kitchen_light - automation.kitchen_light_1 - delay: milliseconds: 750 - event: lights_check event_data: light: turn_off - conditions: - condition: and conditions: - condition: state entity_id: light.living state: 'on' - condition: state entity_id: automation.living_light state: 'off' - condition: template value_template: '{{ action == ''rotate_left'' }}' - condition: template value_template: '{{ side == 1 }}' sequence: - variables: step: "{%- if action_angle > 60 -%}\n {{ -10}}\n{%- else -%}\n {{ -5 }}\n\ {%- endif -%}" kitchen_pct: "{{\n (state_attr('light.kitchen_led', 'brightness') * 100)\ \ / 254\n }}" led_pct: "{{\n int(min(max(kitchen_pct + step, 25), 90))\n }}" - action: light.turn_on target: entity_id: - light.living data: brightness_pct: '{{ int(min(max(((state_attr(''light.living'', ''brightness'') * 100) / 254) + step, 10), 90)) }}' transition: '{{ transition }}' - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: - light.kitchen data: brightness_pct: '{{ int(min(max(((state_attr(''light.kitchen'', ''brightness'') * 100) / 254) + step, 10), 90)) }}' transition: '{{ transition }}' - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: - light.kitchen_led data: brightness_pct: "{{\n min(led_pct - 5 , 20)\n }}" - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: - light.kitchen_led data: brightness_pct: '{{ led_pct }}' - conditions: - condition: and conditions: - condition: state entity_id: light.living state: 'on' - condition: state entity_id: automation.living_light state: 'off' - condition: template value_template: '{{ action == ''rotate_right'' }}' - condition: template value_template: '{{ side == 1 }}' sequence: - variables: step: "{%- if action_angle > 60 -%}\n {{ 10 }}\n{%- else -%}\n {{ 5 }}\n\ {%- endif -%}" kitchen_pct: "{{\n (state_attr('light.kitchen_led', 'brightness') * 100)\ \ / 254\n }}" led_pct: "{{\n int(min(max(kitchen_pct + step, 25), 90))\n }}" - action: light.turn_on target: entity_id: - light.living data: brightness_pct: '{{ int(min(max(((state_attr(''light.living'', ''brightness'') * 100) / 254) + step, 10), 90)) }}' transition: '{{ transition }}' - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: - light.kitchen data: brightness_pct: '{{ int(min(max(((state_attr(''light.kitchen'', ''brightness'') * 100) / 254) + step, 10), 90)) }}' transition: '{{ transition }}' - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: - light.kitchen_led data: brightness_pct: "{{\n min(led_pct - 5 , 20)\n }}" - delay: milliseconds: "{{\n states('input_number.ctrl_delay') | int (100)\n \ \ }}" - action: light.turn_on target: entity_id: - light.kitchen_led data: brightness_pct: '{{ led_pct }}' - alias: sound_bar_music id: sound_bar_music triggers: - trigger: state entity_id: media_player.ht_mt500_501_b34d6a from: 'off' for: seconds: 3 id: to_on - trigger: state entity_id: input_select.select_sound_bar not_from: - unknown - unavailable - none id: to_on - trigger: event event_type: up_down_my event_data: data: start id: start - trigger: event event_type: timer.finished event_data: entity_id: timer.sound_bar id: to_stop - trigger: state entity_id: binary_sensor.sound_bar_active to: 'off' id: to_off - trigger: state entity_id: media_player.ht_mt500_501_b34d6a to: 'off' for: seconds: 5 id: timer_clear mode: restart actions: - choose: - conditions: - condition: trigger id: - to_on - condition: state entity_id: binary_sensor.kodi_screen_saver state: 'on' sequence: - if: - condition: state entity_id: input_boolean.enable_sleep state: 'on' then: - action: timer.start entity_id: timer.sound_bar data_template: duration: 00:{{states('input_number.sound_bar_music_timer') | int}}:00 - action: media_player.play_media data_template: entity_id: media_player.ht_mt500_501_b34d6a media_content_type: audio/mp3 media_content_id: '{% from ''tools.jinja'' import name_to_url %} {{ name_to_url(''input_select.select_sound_bar'') }}' - conditions: - condition: trigger id: - to_stop sequence: - action: media_player.turn_off entity_id: media_player.ht_mt500_501_b34d6a - conditions: - condition: trigger id: - to_off sequence: - action: script.sound_bar_off - conditions: - condition: trigger id: - start sequence: - action: input_select.set_options target: entity_id: input_select.select_sound_bar data: options: '{% from ''tools.jinja'' import radio_names %} {{ radio_names() }}' - conditions: - condition: trigger id: - timer_clear - condition: state entity_id: timer.sound_bar state: - active - paused sequence: - action: timer.cancel entity_id: timer.sound_bar - alias: sound_bar_input_sleep_on id: sound_bar_input_sleep_on triggers: - trigger: state entity_id: input_boolean.enable_sleep conditions: - condition: state entity_id: media_player.ht_mt500_501_b34d6a state: playing mode: restart actions: - choose: - conditions: - condition: state entity_id: input_boolean.enable_sleep state: 'off' sequence: - action: timer.cancel entity_id: timer.sound_bar - conditions: - condition: state entity_id: input_boolean.enable_sleep state: 'on' sequence: - action: timer.start entity_id: timer.sound_bar data_template: duration: 00:05:00 - choose: - conditions: - condition: or conditions: - condition: state entity_id: input_boolean.enable_sleep state: 'off' - condition: state entity_id: device_tracker.n0ll state: home sequence: - action: timer.pause entity_id: timer.sound_bar - alias: bed_sleep_on_spot id: bed_sleep_on_spot triggers: - trigger: state entity_id: binary_sensor.bedmusic to: 'on' actions: - action: input_select.select_option data: entity_id: input_select.select_spotify option: sleep - action: script.spot_bed - wait_template: "{{\n is_state('media_player.bedroom_speaker', 'playing')\n\ \ }}" timeout: seconds: 60 continue_on_timeout: true - action: media_player.volume_set data: entity_id: media_player.bedroom_speaker volume_level: 0.14 - action: timer.start entity_id: timer.bed_music data: duration: 00:45:00 - alias: bed_sleep_on id: bed_sleep_on triggers: - trigger: state entity_id: binary_sensor.bedmusic to: 'on' conditions: - condition: and conditions: - condition: template value_template: "{{\n not is_state('media_player.bedroom_speaker', 'playing')\n\ \ }}" actions: - action: input_select.select_option data_template: entity_id: input_select.select_sleep_sound option: '{%- set c = states(''input_select.select_sleep_sound'') -%} {%- set a = state_attr(''input_select.select_sleep_sound'', ''options'') -%} {{ (((a | join("|")) | regex_replace(c, replace='''')) | regex_replace(''\|\|'', replace=''|'')).split(''|'') | random }}' - alias: bed_sleep_on_select id: bed_sleep_on_select triggers: - trigger: state entity_id: input_select.select_sleep_sound conditions: condition: and conditions: - condition: template value_template: '{{trigger.from_state.state != trigger.to_state.state}}' actions: - action: script.bed_sleep_on - alias: bed_music id: bed_music triggers: - trigger: state entity_id: media_player.bedroom_speaker from: 'off' for: seconds: 3 id: to_on - trigger: state entity_id: input_select.select_radio_bed not_from: - unknown - unavailable - none id: to_on - trigger: event event_type: up_down_my event_data: data: start id: start - trigger: state entity_id: binary_sensor.bedmusic to: 'off' id: to_off - trigger: event event_type: timer.finished event_data: entity_id: timer.bed_music id: to_off - trigger: state entity_id: media_player.bedroom_speaker to: 'off' for: seconds: 3 id: timer_clear mode: restart actions: - choose: - conditions: - condition: trigger id: - to_on - condition: template value_template: "{{\n ('input_select.select_radio_bed' == trigger.entity_id)\ \ or\n not is_state('media_player.bedroom_speaker', 'playing')\n }}" - condition: state entity_id: - script.bed_sleep_on - script.spot_bed state: 'off' sequence: - action: script.bed_music_on - conditions: - condition: trigger id: - to_off - condition: template value_template: "{{\n now() - (\n state_attr('automation.event_android_alarm',\ \ 'last_triggered') |\n default(now() - timedelta(minutes=16), true)\n\ \ ) >\n timedelta(minutes=15)\n }}" sequence: - action: media_player.turn_off entity_id: media_player.bedroom_speaker - conditions: - condition: trigger id: - timer_clear - condition: template value_template: '{{ not is_state(''timer.bed_music'', ''idle'') }}' sequence: - action: media_player.turn_off entity_id: media_player.bedroom_speaker - action: timer.cancel entity_id: timer.bed_music - conditions: - condition: trigger id: - start sequence: - action: input_select.set_options target: entity_id: input_select.select_radio_bed data: options: '{% from ''tools.jinja'' import radio_names %} {{ radio_names() }}' - alias: auto_reboot_all id: auto_reboot_all triggers: - trigger: state entity_id: binary_sensor.isp_conn to: 'off' for: minutes: 6 conditions: - condition: template value_template: "{{\n now() - (\n state_attr('automation.mydelay', 'last_triggered')\ \ |\n default(now()-timedelta(minutes=61), true)\n ) >\n timedelta(minutes=60)\n\ \ }}" actions: - action: script.all_notify data: icon_notify: restart-alert tit: reboot all msg: "{%- if states('sensor.ping_isp') | float(-1) < 0 -%}\n cant ping isp\n\ {%- else -%}\n high isp ping {{states('sensor.ping_isp') }} ms\n{%- endif\ \ -%}" - action: script.reboot_all - alias: open_ports id: open_ports triggers: - trigger: state entity_id: binary_sensor.ext_port to: 'off' for: minutes: 11 actions: - action: script.all_notify data: icon_notify: router-network-wireless tit: router msg: open ports - alias: isp_notify id: isp_notify triggers: - trigger: state entity_id: - binary_sensor.village_conn - binary_sensor.city_conn - binary_sensor.main_conn - binary_sensor.city_waterheater_conn - binary_sensor.village_pump_conn - binary_sensor.village_waterheater_conn to: null not_from: - unknown - unavailable for: minutes: 1 mode: parallel actions: - action: script.all_notify data_template: icon_notify: connection tit: '{{ trigger.to_state.name }}' msg: "{%-\n set sts = {\n 'on': 'up',\n 'off': 'down',\n \ \ }\n -%}\n{{ sts[trigger.to_state.state] }}" - choose: - conditions: - condition: template value_template: "{{\n trigger.to_state.state == 'on'\n }}" sequence: - action: script.turn_on data: entity_id: - script.startup_mqtt - alias: change_current_theme id: change_current_theme triggers: - trigger: state entity_id: input_select.current_theme actions: - action: frontend.set_theme data_template: name: '{{ states(''input_select.current_theme'') }}' - alias: theme_switch id: theme_switch triggers: - trigger: state entity_id: binary_sensor.day - trigger: homeassistant event: start actions: - action: input_select.select_option data: entity_id: input_select.current_theme data_template: option: '{%- set _map = {''on'': ''default'', ''off'': ''midnight''} -%} {{ _map[states(''binary_sensor.day'')] }}' - alias: updates_notify id: updates_notify triggers: - trigger: state entity_id: binary_sensor.docker_hub_update_available to: 'on' for: seconds: 60 id: hass - trigger: numeric_state entity_id: sensor.hacs value_template: "{{\n expand(states.update)\n | selectattr('state', 'eq',\ \ 'on')\n | map(attribute='entity_id')\n | map('device_attr', 'identifiers')\n\ \ | map('contains', 'hacs')\n | list\n | count\n }}" above: 0 for: seconds: 60 id: hacs actions: - choose: - conditions: - condition: trigger id: - hass sequence: - action: script.all_notify data: icon_notify: update tit: Update data_template: msg: '{{trigger.id}}: {{ states(''sensor.docker_hub'') }}' - conditions: - condition: trigger id: - hacs sequence: - action: script.all_notify data: icon_notify: update tit: Update data_template: msg: '{{trigger.id}}: {{ trigger.to_state.state }}' - alias: once_week_reboot id: once_week_reboot triggers: - trigger: time at: 03:00:00 conditions: - condition: time weekday: - tue actions: - action: script.roborock_reboot - action: script.all_notify data: icon_notify: restart-alert tit: weekly msg: reboot - alias: ligths_auto_off id: ligths_auto_off triggers: - trigger: state entity_id: binary_sensor.village_conn to: 'on' for: seconds: 30 id: village_lights_off - trigger: state entity_id: binary_sensor.city_conn to: 'on' for: seconds: 30 id: city_lights_off mode: parallel actions: - choose: - conditions: - condition: trigger id: - village_lights_off sequence: - repeat: for_each: - light.village_1 - light.village_garage - light.village_out - light.village_top_1 sequence: - action: light.turn_on target: entity_id: "{{\n repeat.item\n }}" - delay: milliseconds: 500 - delay: seconds: 20 - repeat: for_each: - light.village_1 - light.village_garage - light.village_out - light.village_top_1 sequence: - action: light.turn_off target: entity_id: "{{\n repeat.item\n }}" - delay: milliseconds: 500 - choose: - conditions: - condition: trigger id: - city_lights_off sequence: - action: light.turn_on target: entity_id: - light.city_2 - delay: seconds: 20 - action: light.turn_off target: entity_id: - light.city_2 - alias: transmission_notify id: transmission_notify triggers: - trigger: event event_type: transmission actions: - action: script.all_notify data_template: icon_notify: pipe tit: '{{ trigger.event.data.file }}' msg: finished - alias: transmission_idle id: transmission_idle triggers: - trigger: state entity_id: binary_sensor.download_active to: 'off' from: 'on' actions: - action: script.all_notify data: icon_notify: pipe-disconnected tit: transmission msg: download is idle - alias: timer_startup id: timer_startup triggers: - trigger: event event_type: timer.finished event_data: entity_id: timer.start_up_delay conditions: condition: or conditions: - condition: state entity_id: input_select.power_down_restart state: pending actions: - action: homeassistant.restart - alias: restart id: restart triggers: - trigger: event event_type: call_service event_data: domain: homeassistant service: restart conditions: condition: or conditions: - condition: state entity_id: input_select.power_down_restart state: 'on' actions: - event: up_down_my event_data: data: stop - action: input_select.select_option data: entity_id: input_select.power_down_restart option: 'off' - action: logbook.log data_template: name: restart message: power down restart off - alias: startup id: startup triggers: - trigger: homeassistant event: start actions: - action: "{%-\n set scr = {\n 'off': 'script.startup',\n 'on': 'script.restart',\n\ \ 'pending': 'script.powerup'\n }\n -%}\n{{ scr[states('input_select.power_down_restart')]\ \ }}\n" - alias: wash_light id: wash_light initial_state: false triggers: - trigger: state entity_id: - binary_sensor.hall_motion - binary_sensor.wash_door to: 'on' id: light_on - trigger: state entity_id: binary_sensor.hall_occupancy to: 'off' for: seconds: 45 id: light_off - trigger: state entity_id: binary_sensor.wash_door to: 'off' for: seconds: 3 id: light_off - trigger: event event_type: lights_check event_data: light: turn_off id: light_off mode: restart actions: - choose: - conditions: - condition: trigger id: - light_on - condition: state entity_id: binary_sensor.wash_door state: 'on' - condition: state entity_id: light.wash state: 'off' sequence: - action: light.turn_on target: entity_id: - light.wash - conditions: - condition: trigger id: - light_off - condition: state entity_id: light.wash state: 'on' - condition: or conditions: - condition: state entity_id: binary_sensor.hall_occupancy state: 'off' - condition: state entity_id: binary_sensor.wash_door state: 'off' sequence: - action: light.turn_off target: entity_id: light.wash - alias: wash_fan id: wash_fan triggers: - trigger: state entity_id: binary_sensor.wash_fan to: 'on' id: dryer_on - trigger: state entity_id: binary_sensor.wash_fan to: 'off' id: dryer_off - trigger: numeric_state entity_id: sensor.bath_hum_change above: 10.0 id: shower_on - trigger: state entity_id: binary_sensor.showering to: 'off' id: shower_off - trigger: state entity_id: input_boolean.fan_wash_time to: 'on' id: manual_on - trigger: state entity_id: input_boolean.fan_wash_time to: 'on' for: minutes: "{{\n states('input_number.fan_wash_time') | int(0)\n }}" id: manual_off - trigger: event event_type: up_down_my event_data: data: start id: manual_off mode: restart actions: - choose: - conditions: - condition: and conditions: - condition: trigger id: - shower_on - dryer_on - manual_on - condition: state entity_id: switch.wash_fan state: 'off' sequence: - action: switch.turn_on data: entity_id: - switch.wash_fan - conditions: - condition: and conditions: - condition: trigger id: - shower_off - dryer_off - manual_off - condition: and conditions: - condition: state entity_id: binary_sensor.showering state: 'off' - condition: state entity_id: binary_sensor.wash_fan state: 'off' - condition: state entity_id: switch.wash_fan state: 'on' sequence: - action: switch.turn_off data: entity_id: - switch.wash_fan - choose: - conditions: - condition: trigger id: - shower - manual_off - condition: state entity_id: input_boolean.fan_wash_time state: 'on' sequence: - action: input_boolean.turn_off data: entity_id: - input_boolean.fan_wash_time - id: water_boiler alias: water_boiler triggers: - trigger: time at: 05:05:00 id: time_heat variables: s: win - trigger: time at: 06:05:00 id: time_heat variables: s: sum - trigger: time at: 04:45:00 id: time_clean variables: s: win - trigger: time at: 05:00:00 id: time_clean variables: s: sum - trigger: time at: 06:35:00 id: time_off variables: s: win - trigger: time at: 07:35:00 id: time_off variables: s: sum conditions: - condition: template value_template: "{%- set data = {\n 'win' : [1, 2, 3, 11, 12],\n \ \ 'sum' : [4, 5, 6, 7, 8, 9, 10],\n }\n -%}\n{{ now().month in data[s]\ \ }}" mode: restart actions: - choose: - conditions: - condition: trigger id: - time_heat - condition: state entity_id: device_tracker.root state: home - condition: numeric_state entity_id: climate.hot_water attribute: current_temperature below: 39.0 - condition: state entity_id: climate.hot_water state: 'off' sequence: - action: climate.set_temperature target: entity_id: climate.hot_water data: hvac_mode: heat temperature: 45 - conditions: - condition: trigger id: - time_clean - condition: time weekday: - wed - condition: state entity_id: climate.hot_water state: 'off' sequence: - action: climate.set_hvac_mode target: entity_id: climate.hot_water data: hvac_mode: heat - conditions: - condition: trigger id: - time_off - condition: state entity_id: climate.hot_water state: heat sequence: - action: climate.set_hvac_mode target: entity_id: climate.hot_water data: hvac_mode: 'off' - id: water_city_1 alias: water_city_1 triggers: - trigger: state entity_id: - binary_sensor.water_motion - binary_sensor.water_wash to: 'on' id: water_on - trigger: state entity_id: binary_sensor.water_occupancy to: 'off' id: water_off for: seconds: "{%- if int(states('counter.water_motion'), 5) > 50 -%}\n 300\n{%-\ \ elif int(states('counter.water_motion'), 5) > 30 -%}\n 180\n{%- elif int(states('counter.water_motion'),\ \ 5 ) > 10 -%}\n 120\n{%- else -%}\n 60\n{%- endif -%}" - trigger: state entity_id: binary_sensor.water_wash to: 'off' id: water_off - trigger: event event_type: up_down_my event_data: data: start id: water_off mode: restart actions: - choose: - conditions: - condition: trigger id: - water_on sequence: - action: counter.increment data: entity_id: - counter.water_motion - conditions: - condition: trigger id: - water_off sequence: - action: counter.reset data: entity_id: - counter.water_motion - choose: - conditions: - condition: trigger id: - water_on - condition: state entity_id: switch.water_valve state: 'off' sequence: - action: switch.turn_on data: entity_id: switch.water_valve - conditions: - condition: trigger id: - water_off - condition: state entity_id: switch.water_valve state: 'on' - condition: state entity_id: binary_sensor.water_occupancy state: 'off' - condition: state entity_id: binary_sensor.water_wash state: 'off' sequence: - action: switch.turn_off data: entity_id: switch.water_valve - alias: wled_lights id: wled_lights triggers: - trigger: state entity_id: binary_sensor.wled_living to: 'on' id: to_on - trigger: state entity_id: binary_sensor.wled_living to: 'off' id: to_off - trigger: state entity_id: binary_sensor.wled_living from: unavailable for: seconds: 45 id: from_off - trigger: state entity_id: - light.living - light.hall to: 'off' id: after_off - trigger: state entity_id: binary_sensor.wled_ambient to: 'on' id: to_ambient - trigger: state entity_id: binary_sensor.wled_ambient to: 'off' id: from_ambient - trigger: event event_type: up_down_my event_data: data: stop id: to_off - trigger: state entity_id: binary_sensor.day to: 'off' - trigger: event event_type: up_down_my event_data: data: start id: to_start - trigger: state entity_id: device_tracker.n0ll to: not_home for: seconds: 95 id: to_start - trigger: event event_type: kodi_living_startup id: to_start mode: restart actions: - choose: - conditions: - condition: trigger id: - to_ambient sequence: - action: mqtt.publish data: topic: wled/wled-living/api payload: SN=0 - action: mqtt.publish data: topic: wled/wled-window/api payload: T=0 - action: mqtt.publish data: topic: wled/wled-living/api payload: "{{\n 'A=%d' | format( states('input_number.wled_video_brightness')\ \ | int(64))\n }}" - choose: - conditions: - condition: trigger id: - to_on sequence: - variables: data: A=200&FP=51&FX=112&NL=0 - action: mqtt.publish data: topic: wled/wled-living/api payload: '{{ data }}' - action: mqtt.publish data: topic: wled/wled-window/api payload: '{{ data }}' - conditions: - condition: trigger id: - to_off - condition: state entity_id: binary_sensor.wled_ambient state: 'off' sequence: - variables: data: NL=1&NF=2&A=200&PL=1 - action: mqtt.publish data: topic: wled/wled-living/api payload: '{{ data }}' - action: mqtt.publish data: topic: wled/wled-window/api payload: '{{ data }}' - conditions: - condition: trigger id: - from_off - condition: state entity_id: binary_sensor.wled_ambient state: 'off' sequence: - variables: data: "{%- if is_state('binary_sensor.wled_living', 'on') -%}\n A=200&FP=51&FX=112&NL=0\n\ {%- else -%}\n A=200&FP=15&FX=38&NL=5&NF=2\n{%- endif -%}" - action: mqtt.publish data: topic: wled/wled-living/api payload: '{{ data }}' - action: mqtt.publish data: topic: wled/wled-window/api payload: '{{ data }}' - conditions: - condition: trigger id: - after_off - condition: state entity_id: binary_sensor.wled_living state: 'off' - condition: state entity_id: binary_sensor.wled_ambient state: 'off' - condition: state entity_id: binary_sensor.day state: 'off' sequence: - variables: data: A=200&PL=3&NL=3&NF=2 - action: mqtt.publish data: topic: wled/wled-living/api payload: '{{ data }}' - action: mqtt.publish data: topic: wled/wled-window/api payload: '{{ data }}' - conditions: - condition: trigger id: - to_start - condition: state entity_id: binary_sensor.day state: 'off' - condition: state entity_id: binary_sensor.wled_living state: 'off' - condition: state entity_id: device_tracker.root state: home sequence: - variables: data: A=200&FP=15&FX=43&NL=1&NF=2 - action: mqtt.publish data: topic: wled/wled-living/api payload: '{{ data }}' - action: mqtt.publish data: topic: wled/wled-window/api payload: '{{ data }}' - conditions: - condition: trigger id: - from_ambient sequence: - variables: data: A=200&FP=15&FX=112&NL=1&NF=2 - action: mqtt.publish data: topic: wled/wled-living/api payload: '{{ data }}' - action: mqtt.publish data: topic: wled/wled-window/api payload: '{{ data }}' - alias: hyperion_clear_effects id: hyperion_clear_effects triggers: - trigger: event event_type: timer.finished event_data: entity_id: timer.hyperion_effect_timer actions: - action: input_select.select_option data: entity_id: input_select.hyperion_select_effect option: None - alias: send_effect_hyperion id: send_effect_hyperion triggers: - trigger: state entity_id: input_select.hyperion_select_effect conditions: - condition: template value_template: "{{\n trigger.to_state.state != 'None'\n }}" - condition: template value_template: "{{\n now() - (\n state_attr('automation.tv_ctrl', 'last_triggered')\ \ |\n default(now() - timedelta(seconds=31), true)\n ) >\n \ \ timedelta(seconds=30) or\n is_state('binary_sensor.day', 'off')\n }}" actions: - action: shell_command.hyperion_cmd data_template: value: "'{\n \"command\":\"componentstate\",\n \"componentstate\": {\n \ \ \"component\": \"LEDDEVICE\",\n \"state\": false\n }\n}'" - delay: milliseconds: 250 - action: shell_command.hyperion_cmd data_template: value: "'{\n \"command\": \"effect\",\n \"priority\": {{ 105 | int(0)\ \ }},\n \"duration\": {{ (states('input_number.slider_effect_time') | float(0)\ \ * 60000) | int(0) }},\n \"effect\": { \"name\" : \"{{ states('input_select.hyperion_select_effect')\ \ }}\"}\n }'" - delay: milliseconds: 250 - action: shell_command.hyperion_cmd data_template: value: "'{\n \"command\":\"componentstate\",\n \"componentstate\": {\n \ \ \"component\": \"LEDDEVICE\",\n \"state\": true\n }\n}'" - action: timer.start entity_id: timer.hyperion_effect_timer data_template: duration: '{{ (states(''input_number.slider_effect_time'') | float(0) * 60) | int(0) }}' - alias: video_grabber id: video_grabber triggers: - trigger: state entity_id: binary_sensor.grabber_living - trigger: event event_type: kodi_living_startup actions: - action: shell_command.hyperion_cmd data_template: value: "{%-\n set cmd = {\n 'command': 'componentstate',\n \ \ 'componentstate': {\n 'component': 'GRABBER',\n 'state':\ \ is_state('binary_sensor.grabber_living', 'on')\n }\n }\n -%}\n\ '{{ cmd | to_json }}'" - delay: milliseconds: 250 - action: shell_command.hyperion_cmd data_template: value: "{%-\n set cmd = {\n 'command': 'componentstate',\n \ \ 'componentstate': {\n 'component': 'LEDDEVICE',\n 'state':\ \ false\n }\n }\n -%}\n'{{ cmd | to_json }}'" - delay: milliseconds: 250 - action: shell_command.hyperion_cmd data_template: value: "{%-\n set cmd = {\n 'command': 'componentstate',\n \ \ 'componentstate': {\n 'component': 'LEDDEVICE',\n 'state':\ \ true\n }\n }\n -%}\n'{{ cmd | to_json }}'" - alias: send_effect_hyperion_none id: send_effect_hyperion_none triggers: - trigger: state entity_id: input_select.hyperion_select_effect to: None for: seconds: 3 actions: - action: shell_command.hyperion_cmd data_template: value: '''{"command": "clear", "priority": {{ 105 | int(0) }}}''' - action: timer.cancel entity_id: timer.hyperion_effect_timer - alias: led_scheme_send id: led_scheme_send triggers: - trigger: state entity_id: input_select.wled_colors_palette - trigger: state entity_id: input_select.wled_effects conditions: condition: and conditions: - condition: state entity_id: light.wled_living state: 'on' actions: - action: mqtt.publish data: topic: wled/wled-living/api payload_template: '{{states(''input_select.wled_effects'')}}' - action: mqtt.publish data: topic: wled/wled-living/api payload_template: '{{states(''input_select.wled_colors_palette'')}}' - alias: zigbee2mqtt_start id: zigbee2mqtt_start triggers: - trigger: mqtt topic: zigbee2mqtt/bridge/state actions: - repeat: for_each: - device: bed-light-1 payload: state: '' brightness: '' color_temp: '' - device: bed-light-2 payload: state: '' brightness: '' color_temp: '' - device: bed-light-3 payload: state: '' brightness: '' color_temp: '' - device: bed-light-4 payload: state: '' brightness: '' color_temp: '' - device: bed-light-5 payload: state: '' brightness: '' color_temp: '' - device: bed-light-6 payload: state: '' brightness: '' color_temp: '' - device: bed-light-7 payload: state: '' brightness: '' color_temp: '' - device: bed-light-8 payload: state: '' brightness: '' color_temp: '' - device: office-light-1 payload: state: '' brightness: '' color_temp: '' - device: office-light-2 payload: state: '' brightness: '' color_temp: '' - device: office-light-3 payload: state: '' brightness: '' color_temp: '' - device: office-light-4 payload: state: '' brightness: '' color_temp: '' - device: office-light-5 payload: state: '' brightness: '' color_temp: '' - device: office-light-6 payload: state: '' brightness: '' color_temp: '' - device: office-light-7 payload: state: '' brightness: '' color_temp: '' - device: office-light-8 payload: state: '' brightness: '' color_temp: '' - device: kitchen-light-1 payload: state: '' brightness: '' color_temp: '' - device: kitchen-light-2 payload: state: '' brightness: '' color_temp: '' - device: kitchen-light-3 payload: state: '' brightness: '' color_temp: '' - device: kitchen-light-4 payload: state: '' brightness: '' color_temp: '' - device: kitchen-light-5 payload: state: '' brightness: '' color_temp: '' - device: kitchen-light-6 payload: state: '' brightness: '' color_temp: '' - device: kitchen-light-7 payload: state: '' brightness: '' color_temp: '' - device: living-light-1 payload: state: '' brightness: '' color_temp: '' - device: living-light-2 payload: state: '' brightness: '' color_temp: '' - device: living-light-3 payload: state: '' brightness: '' color_temp: '' - device: living-light-4 payload: state: '' brightness: '' color_temp: '' - device: living-light-5 payload: state: '' brightness: '' color_temp: '' - device: living-light-6 payload: state: '' brightness: '' color_temp: '' - device: living-light-7 payload: state: '' brightness: '' color_temp: '' - device: kitchen-led payload: state: '' brightness: '' - device: hall-light payload: state_l1: '' state_l2: '' - device: bath-light payload: state_l1: '' state_l2: '' - device: bath-mirror payload: state_l1: '' state_l2: '' - device: wash-switch payload: state_l1: '' state_l2: '' - device: bath-mirror payload: state_l1: '' state_l2: '' - device: office-wardrobe payload: state: '' - device: bed-wardrobe payload: state: '' - device: bath-water payload: state_l1: '' state_l2: '' - device: wash-switch payload: state_l1: '' state_l2: '' - device: living-switch-tv payload: state: '' - device: bed-switch-1 payload: state_l1: '' state_l2: '' sequence: - action: mqtt.publish data_template: topic: zigbee2mqtt/{{ repeat.item.device }}/get payload: '{{ repeat.item.payload | to_json }}' - action: mqtt.publish data: topic: zigbee2mqtt/bath-tvr/set payload: '{"online": "on"}' - delay: seconds: 1 - action: mqtt.publish data: topic: zigbee2mqtt/bath-tvr/set payload: '{"online": "off"}'