From f88a730aa11348b6941f5b720c0fda322d0b1ff4 Mon Sep 17 00:00:00 2001 From: ttrabatt Date: Sat, 1 Feb 2025 01:54:28 +0100 Subject: [PATCH] motion light Dual and Trix OK - cleanuo of blueprint directory --- automations.yaml | 292 ++++++------------ .../homeassistant/motion_light_dual_ng.yaml | 164 ++++++++++ .../homeassistant/motion_light_trix_ng.yaml | 186 +++++++++++ .../motion-light-new.yaml | 0 .../motion_light_dual_lux.yaml | 0 .../motion_light_tris_lux.yaml | 0 6 files changed, 447 insertions(+), 195 deletions(-) create mode 100644 blueprints/automation/homeassistant/motion_light_dual_ng.yaml create mode 100644 blueprints/automation/homeassistant/motion_light_trix_ng.yaml rename {blueprints/automation/homeassistant => examples}/motion-light-new.yaml (100%) rename {blueprints/automation/homeassistant => examples}/motion_light_dual_lux.yaml (100%) rename {blueprints/automation/homeassistant => examples}/motion_light_tris_lux.yaml (100%) diff --git a/automations.yaml b/automations.yaml index 17f9102..37c0988 100644 --- a/automations.yaml +++ b/automations.yaml @@ -1,4 +1,4 @@ -- id: "1729875991469" +- id: '1729875991469' alias: BagnoOvest-save-energy description: Thermostat will close upon window open use_blueprint: @@ -6,247 +6,149 @@ input: window_sensor: binary_sensor.bagnoovest_finestra_contact climate_target: climate.bagnoovest_termosifone -- id: "1729887529602" +- id: '1729887529602' alias: BagnoPT-save-energy - description: "" + description: '' use_blueprint: path: homeassistant/heat_save.yaml input: window_sensor: binary_sensor.bagnopt_finestra_contact climate_target: climate.bagnopt_termosifone ext_temp_limit: 17 -- id: "1729887632269" +- id: '1729887632269' alias: SoggiornoPT-save-energy - description: "" + description: '' use_blueprint: path: homeassistant/heat_save.yaml input: window_sensor: binary_sensor.soggiornopt_finestrasud_contact climate_target: climate.soggiornopt_termosifonesud ext_temp_limit: 17 -- id: "1731410549094" - alias: EVcharge_front_charging - description: "" - triggers: - - trigger: state - entity_id: - - input_boolean.evcharge_front_start - for: - hours: 0 - minutes: 0 - seconds: 10 - conditions: [] - actions: - - wait_for_trigger: - - trigger: time - at: input_datetime.evcharge_good_time_start - - type: turn_on - device_id: 62352ecf274ff68e3ddfbc979406d49d - entity_id: c1f2a5e1b3bc7807a8b291b6fd6dbb31 - domain: switch - - wait_for_trigger: - - trigger: time - at: input_datetime.evcharge_good_time_end - - type: turn_off - device_id: 62352ecf274ff68e3ddfbc979406d49d - entity_id: c1f2a5e1b3bc7807a8b291b6fd6dbb31 - domain: switch - mode: single -- id: "1731705145404" +- id: '1731705145404' alias: Luce Automatica Scala Mansarda - description: "" + description: '' use_blueprint: - path: homeassistant/motion_light_dual_lux.yaml + path: homeassistant/motion_light_dual_ng.yaml input: - motion_entity_down: binary_sensor.presenza_bassa_scala_mansarda_occupancy - motion_entity_up: binary_sensor.presenza_alta_scala_mansarda_occupancy + motion_entity1: binary_sensor.presenza_alta_scala_mansarda_occupancy + motion_entity2: binary_sensor.presenza_bassa_scala_mansarda_occupancy light_target: device_id: 702137a6f2c17b89fdb0598f7003743c - no_motion_wait: 10 -- id: "1731705400752" +- id: '1731705400752' alias: Luce Automatica Scala Taverna - description: "" + description: '' use_blueprint: - path: homeassistant/motion_light_dual_lux.yaml + path: homeassistant/motion_light_dual_ng.yaml input: - motion_entity_down: binary_sensor.presenza_bassa_scala_taverna_occupancy - motion_entity_up: binary_sensor.presenza_alta_scala_taverna_occupancy + motion_entity1: binary_sensor.presenza_alta_scala_taverna_occupancy + motion_entity2: binary_sensor.presenza_bassa_scala_taverna_occupancy light_target: device_id: 226779fb30bd68c5a2784ccd762d90e9 - sun_condition: false -- id: "1731953745814" - alias: EVcharge-front-program - description: "" - triggers: - - trigger: state - entity_id: - - input_boolean.evcharge_front_start - from: "off" - to: "on" - conditions: - - condition: time - after: input_datetime.evcharge_good_time_start - before: input_datetime.evcharge_good_time_end - weekday: - - sun - - mon - - tue - - wed - - thu - - fri - - sat - actions: - - action: switch.turn_on - metadata: {} - data: {} - target: - device_id: 62352ecf274ff68e3ddfbc979406d49d - - wait_template: - "{{ states('sensor.presa_smart_1_power') < states('input_number.evcharge_no_charge_threshold') - }}" - continue_on_timeout: true - timeout: 00:30:00 - - action: switch.turn_off - metadata: {} - data: {} - target: - device_id: 62352ecf274ff68e3ddfbc979406d49d - mode: single -- id: "1732739522749" + use_sun: false + dont_disturb: false +- id: '1732739522749' alias: Luce Automatica Taverna Garage - description: "" + description: '' use_blueprint: - path: homeassistant/motion_light_tris_lux.yaml + path: homeassistant/motion_light_trix_ng.yaml input: - motion_entity_uno: binary_sensor.presenza_bassa_scala_taverna_occupancy - motion_entity_due: binary_sensor.presenza_taverna_garage_occupancy - motion_entity_tre: binary_sensor.presenza_taverna_lavanderia_occupancy light_target: entity_id: light.taverna_garage - sun_condition: false - dont_disturb_condition: false -- id: "1733907515800" + motion_entity1: binary_sensor.presenza_bassa_scala_taverna_occupancy + motion_entity2: binary_sensor.presenza_taverna_garage_occupancy + motion_entity3: binary_sensor.presenza_taverna_lavanderia_occupancy + use_sun: false + dont_disturb: false + no_motion_wait: 40 +- id: '1733907515800' alias: EVcharge-front-temp-automation - description: - Temporary Automation of EVcharge front from 23:01 to 9:00 all days + description: Temporary Automation of EVcharge front from 23:01 to 9:00 all days the same triggers: - - trigger: time - at: "23:04:00" - id: EVcharge-front-on - - trigger: time - at: 09:00:00 - id: EVcharge-front-off - conditions: [] - actions: - - if: - - condition: trigger - id: - - EVcharge-front-on - then: - - type: turn_on - device_id: b69c1ca977ec6590e58689a8ab48cf3c - entity_id: 62f4895f11ca37d023aad1fddee7c0a0 - domain: switch - else: - - type: turn_off - device_id: b69c1ca977ec6590e58689a8ab48cf3c - entity_id: 62f4895f11ca37d023aad1fddee7c0a0 - domain: switch - mode: single -- id: "1735298237446" - alias: P1-confort-light - description: "" - triggers: - - trigger: time - at: input_datetime.dont_disturb_nighttime_to - - trigger: sun - event: sunset - offset: 00:30:00 - id: p1-confort-light-on - - trigger: time - at: "23:00:00" - id: p1-confort-light-off + - trigger: time + at: '23:04:00' + id: EVcharge-front-on + - trigger: time + at: 09:00:00 + id: EVcharge-front-off conditions: [] actions: + - if: - condition: trigger id: - - p1-confort-light-on + - EVcharge-front-on + then: - type: turn_on - device_id: e0397b54f1c2d1514be403e2996ca368 - entity_id: ef6706dbe425caf09693c084182ec228 - domain: light - brightness_pct: 100 - - condition: trigger - id: - - p1-confort-light-off + device_id: b69c1ca977ec6590e58689a8ab48cf3c + entity_id: 62f4895f11ca37d023aad1fddee7c0a0 + domain: switch + else: - type: turn_off - device_id: e0397b54f1c2d1514be403e2996ca368 - entity_id: ef6706dbe425caf09693c084182ec228 - domain: light + device_id: b69c1ca977ec6590e58689a8ab48cf3c + entity_id: 62f4895f11ca37d023aad1fddee7c0a0 + domain: switch mode: single -- id: "1736805701473" +- id: '1736805701473' alias: P1confort-light - description: "" + description: '' use_blueprint: path: homeassistant/confort_light.yaml input: light_target: device_id: e0397b54f1c2d1514be403e2996ca368 -- id: "1737850967154" - alias: test-new-motion - description: "" +- id: '1738142303265' + alias: test-pulsante1 + description: '' + triggers: + - trigger: mqtt + topic: zigbee2mqtt/Pulsante-01 + payload: single + value_template: '{{ value_json[''action''] }}' + id: Pulsante1-single + - trigger: mqtt + topic: zigbee2mqtt/Pulsante-01 + payload: double + value_template: '{{ value_json[''action''] }}' + id: Pulsante1-double + conditions: [] + actions: + - choose: + - conditions: + - condition: trigger + id: + - Pulsante1-single + sequence: + - action: light.turn_on + metadata: {} + data: + rgb_color: + - 255 + - 0 + - 0 + brightness_pct: 100 + transition: 10 + target: + device_id: '{{ device_id(''light.test_lamp1'')}}' + - conditions: + - condition: trigger + id: + - Pulsante1-double + sequence: + - action: light.turn_off + metadata: {} + data: + transition: 10 + target: + device_id: '{{ device_id(''light.test_lamp1'')}}' + mode: queued +- id: '1738366774549' + alias: Test-motion-light-ng + description: '' use_blueprint: - path: homeassistant/motion-light-new.yaml + path: homeassistant/motion_light_dual_ng.yaml input: motion_entity1: binary_sensor.presenza_alta_scala_mansarda_occupancy motion_entity2: binary_sensor.presenza_bassa_scala_mansarda_occupancy light_target: - entity_id: light.test_lamp1 -- id: "1738142303265" - alias: test-pulsante1 - description: "" - triggers: - - trigger: mqtt - topic: "zigbee2mqtt/Pulsante-01" - payload: "single" - value_template: "{{ value_json['action'] }}" - id: Pulsante1-single - - trigger: mqtt - topic: "zigbee2mqtt/Pulsante-01" - payload: "double" - value_template: "{{ value_json['action'] }}" - id: Pulsante1-double - - conditions: [] - actions: - - choose: - - conditions: - - condition: trigger - id: - - Pulsante1-single - sequence: - - action: light.turn_on - metadata: {} - data: - rgb_color: - - 255 - - 0 - - 0 - brightness_pct: 100 - transition: 10 - target: - device_id: "{{ device_id('light.test_lamp1')}}" - # device_id: "9f46c5b7c07f1495e0f4bf8d6f72a525" - - conditions: - - condition: trigger - id: - - Pulsante1-double - sequence: - - action: light.turn_off - metadata: {} - data: - transition: 10 - target: - device_id: "{{ device_id('light.test_lamp1')}}" - mode: queued + device_id: 9f46c5b7c07f1495e0f4bf8d6f72a525 + no_motion_wait: 0 diff --git a/blueprints/automation/homeassistant/motion_light_dual_ng.yaml b/blueprints/automation/homeassistant/motion_light_dual_ng.yaml new file mode 100644 index 0000000..7fd19e8 --- /dev/null +++ b/blueprints/automation/homeassistant/motion_light_dual_ng.yaml @@ -0,0 +1,164 @@ +blueprint: + name: Motion-activated-Light NG (dual motion sensors) + description: Turn on a light when motion is detected NG (dual motion sensor) + domain: automation + author: Tiziano Trabattoni + input: + motion_entity1: + name: Motion-sensor1 + description: First Sensor motion entity + selector: + entity: + filter: + device_class: motion + domain: binary_sensor + motion_entity2: + name: Motion-sensor2 + description: Second Sensor motion entity + selector: + entity: + filter: + device_class: motion + domain: binary_sensor + light_target: + name: Light + description: Entity of the Lamp to be controlled + selector: + target: + entity: + domain: light + use_sun: + name: Sun_driven + description: Controlled by sunrise and sunset flag + default: on + selector: + boolean: + dont_disturb: + name: dont_disturb_light_control + description: Controls if lamp brightness has to be reduced to not disturb + default: on + selector: + boolean: + no_motion_wait: + name: Wait time + description: Time to leave the light on after last motion is detected. + default: 20 + selector: + number: + min: 0 + max: 300 + unit_of_measurement: seconds + +# Every motion state change is captured and managed by the script therefore we need to restart by queueing triggers +# in this automation the poweroff of light is started only if all managed motion sensor are in clear state (= "off") +mode: queued +max_exceeded: silent + +triggers: + - trigger: state + entity_id: !input motion_entity1 + from: "off" + to: "on" + id: motion_entity1_on + - trigger: state + entity_id: !input motion_entity2 + from: "off" + to: "on" + id: motion_entity2_on + - trigger: state + entity_id: !input motion_entity1 + from: "on" + to: "off" + id: motion_entity1_off + - trigger: state + entity_id: !input motion_entity2 + from: "on" + to: "off" + id: motion_entity2_off + +variables: + use_sun_flag: !input use_sun + dont_disturb_flag: !input dont_disturb + light_target_var: !input light_target + motion_entity1_var: !input motion_entity1 + motion_entity2_var: !input motion_entity2 + +actions: + - choose: + # Conditions for triggering on light + - conditions: + - condition: trigger + id: + - motion_entity1_on + - motion_entity2_on + sequence: + - if: + - condition: template + value_template: "{{ use_sun_flag }}" + then: # Sun and luminescence controlled + - if: + - or: + # external light is LOW (below Helper daylight_luminescence set value) + - condition: template + value_template: "{{ ( states('sensor.esterno_luminosita_illuminance_lux') | int ) < ( states('input_number.daylight_luminescence') | int ) }}" + # after sunrise and before sunset + - condition: sun + after: sunset + after_offset: "-01:00:00" + before: sunrise + before_offset: "+01:00:00" + then: + - if: + - condition: template + value_template: "{{ dont_disturb_flag }}" + then: + - action: light.turn_on + target: !input light_target + data: + brightness_pct: "{{ states('input_number.dont_disturb_light_brightness') | float }}" + color_temp_kelvin: 2500 + else: + - action: light.turn_on + target: !input light_target + data: + brightness_pct: 100 + color_temp_kelvin: 2500 + else: # Always active + - if: + - condition: template + value_template: "{{ dont_disturb_flag }}" + then: + - action: light.turn_on + target: !input light_target + data: + brightness_pct: "{{ states('input_number.dont_disturb_light_brightness') | float }}" + color_temp_kelvin: 2500 + else: + - action: light.turn_on + target: !input light_target + data: + brightness_pct: 100 + color_temp_kelvin: 2500 + + # conditions for triggering off lights + - conditions: + - condition: trigger + id: + - motion_entity1_off + - motion_entity2_off + sequence: + - if: + - alias: "None of motion sensor are detected" + condition: not + conditions: + - condition: template + value_template: "{{ is_state(motion_entity1_var, 'on') }}" + - condition: template + value_template: "{{ is_state(motion_entity2_var, 'on') }}" + + then: + - alias: "Wait for delay set before turn off" + delay: !input no_motion_wait + - alias: "Turn off the light" + action: light.turn_off + target: !input light_target diff --git a/blueprints/automation/homeassistant/motion_light_trix_ng.yaml b/blueprints/automation/homeassistant/motion_light_trix_ng.yaml new file mode 100644 index 0000000..18b8b84 --- /dev/null +++ b/blueprints/automation/homeassistant/motion_light_trix_ng.yaml @@ -0,0 +1,186 @@ +blueprint: + name: Motion-activated-Light NG (trix motion sensors) + description: Turn on a light when motion is detected NG (trix motion sensor) + domain: automation + author: Tiziano Trabattoni + input: + motion_entity1: + name: Motion-sensor1 + description: First Sensor motion entity + selector: + entity: + filter: + device_class: motion + domain: binary_sensor + motion_entity2: + name: Motion-sensor2 + description: Second Sensor motion entity + selector: + entity: + filter: + device_class: motion + domain: binary_sensor + motion_entity3: + name: Motion-sensor3 + description: Third Sensor motion entity + selector: + entity: + filter: + device_class: motion + domain: binary_sensor + light_target: + name: Light + description: Entity of the Lamp to be controlled + selector: + target: + entity: + domain: light + use_sun: + name: Sun_driven + description: Controlled by sunrise and sunset flag + default: on + selector: + boolean: + dont_disturb: + name: dont_disturb_light_control + description: Controls if lamp brightness has to be reduced to not disturb + default: on + selector: + boolean: + no_motion_wait: + name: Wait time + description: Time to leave the light on after last motion is detected. + default: 20 + selector: + number: + min: 0 + max: 300 + unit_of_measurement: seconds + +# Every motion state change is captured and managed by the script therefore we need to restart by queueing triggers +# in this automation the poweroff of light is started only if all managed motion sensor are in clear state (= "off") +mode: queued +max_exceeded: silent + +triggers: + - trigger: state + entity_id: !input motion_entity1 + from: "off" + to: "on" + id: motion_entity1_on + - trigger: state + entity_id: !input motion_entity2 + from: "off" + to: "on" + id: motion_entity2_on + - trigger: state + entity_id: !input motion_entity3 + from: "off" + to: "on" + id: motion_entity3_on + - trigger: state + entity_id: !input motion_entity1 + from: "on" + to: "off" + id: motion_entity1_off + - trigger: state + entity_id: !input motion_entity2 + from: "on" + to: "off" + id: motion_entity2_off + - trigger: state + entity_id: !input motion_entity3 + from: "on" + to: "off" + id: motion_entity3_off + +variables: + use_sun_flag: !input use_sun + dont_disturb_flag: !input dont_disturb + light_target_var: !input light_target + motion_entity1_var: !input motion_entity1 + motion_entity2_var: !input motion_entity2 + motion_entity3_var: !input motion_entity3 + +actions: + - choose: + # Conditions for triggering on light + - conditions: + - condition: trigger + id: + - motion_entity1_on + - motion_entity2_on + - motion_entity3_on + sequence: + - if: + - condition: template + value_template: "{{ use_sun_flag }}" + then: # Sun and luminescence controlled + - if: + - or: + # external light is LOW (below Helper daylight_luminescence set value) + - condition: template + value_template: "{{ ( states('sensor.esterno_luminosita_illuminance_lux') | int ) < ( states('input_number.daylight_luminescence') | int ) }}" + # after sunrise and before sunset + - condition: sun + after: sunset + after_offset: "-01:00:00" + before: sunrise + before_offset: "+01:00:00" + then: + - if: + - condition: template + value_template: "{{ dont_disturb_flag }}" + then: + - action: light.turn_on + target: !input light_target + data: + brightness_pct: "{{ states('input_number.dont_disturb_light_brightness') | float }}" + color_temp_kelvin: 2500 + else: + - action: light.turn_on + target: !input light_target + data: + brightness_pct: 100 + color_temp_kelvin: 2500 + else: # Always active + - if: + - condition: template + value_template: "{{ dont_disturb_flag }}" + then: + - action: light.turn_on + target: !input light_target + data: + brightness_pct: "{{ states('input_number.dont_disturb_light_brightness') | float }}" + color_temp_kelvin: 2500 + else: + - action: light.turn_on + target: !input light_target + data: + brightness_pct: 100 + color_temp_kelvin: 2500 + + # conditions for triggering off lights + - conditions: + - condition: trigger + id: + - motion_entity1_off + - motion_entity2_off + - motion_entity3_off + sequence: + - if: + - alias: "None of motion sensor are detected" + condition: not + conditions: + - condition: template + value_template: "{{ is_state(motion_entity1_var, 'on') }}" + - condition: template + value_template: "{{ is_state(motion_entity2_var, 'on') }}" + - condition: template + value_template: "{{ is_state(motion_entity3_var, 'on') }}" + then: + - alias: "Wait for delay set before turn off" + delay: !input no_motion_wait + - alias: "Turn off the light" + action: light.turn_off + target: !input light_target diff --git a/blueprints/automation/homeassistant/motion-light-new.yaml b/examples/motion-light-new.yaml similarity index 100% rename from blueprints/automation/homeassistant/motion-light-new.yaml rename to examples/motion-light-new.yaml diff --git a/blueprints/automation/homeassistant/motion_light_dual_lux.yaml b/examples/motion_light_dual_lux.yaml similarity index 100% rename from blueprints/automation/homeassistant/motion_light_dual_lux.yaml rename to examples/motion_light_dual_lux.yaml diff --git a/blueprints/automation/homeassistant/motion_light_tris_lux.yaml b/examples/motion_light_tris_lux.yaml similarity index 100% rename from blueprints/automation/homeassistant/motion_light_tris_lux.yaml rename to examples/motion_light_tris_lux.yaml