From 390b5c59729ec00576c758adebf2b0f74e224158 Mon Sep 17 00:00:00 2001 From: ttrabatt Date: Thu, 30 Jan 2025 00:24:45 +0100 Subject: [PATCH] Pulsante e MQTT trigger - test motion light new --- .HA_VERSION | 2 +- .gitignore | 1 + automations.yaml | 307 +++++++++++------- .../homeassistant/motion-light-new.yaml | 71 ++++ .../homeassistant/motion_light_dual_lux.yaml | 46 ++- .../homeassistant/motion_light_tris_lux.yaml | 5 +- 6 files changed, 301 insertions(+), 131 deletions(-) create mode 100644 blueprints/automation/homeassistant/motion-light-new.yaml diff --git a/.HA_VERSION b/.HA_VERSION index 34ca124..c50e97c 100644 --- a/.HA_VERSION +++ b/.HA_VERSION @@ -1 +1 @@ -2025.1.2 \ No newline at end of file +2025.1.4 \ No newline at end of file diff --git a/.gitignore b/.gitignore index ac64287..23f07db 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ themes/* .storage/core.restore_state .storage/repairs.issue_registry home-assistant.log* +zigbee2mqtt \ No newline at end of file diff --git a/automations.yaml b/automations.yaml index 590418b..30e112b 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,55 +6,55 @@ 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' +- id: "1731410549094" alias: EVcharge_front_charging - description: '' + description: "" triggers: - - trigger: state - entity_id: - - input_boolean.evcharge_front_start - for: - hours: 0 - minutes: 0 - seconds: 10 + - 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 + - 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 input: @@ -62,9 +62,10 @@ motion_entity_up: binary_sensor.presenza_alta_scala_mansarda_occupancy light_target: device_id: 702137a6f2c17b89fdb0598f7003743c -- id: '1731705400752' + no_motion_wait: 10 +- id: "1731705400752" alias: Luce Automatica Scala Taverna - description: '' + description: "" use_blueprint: path: homeassistant/motion_light_dual_lux.yaml input: @@ -73,46 +74,47 @@ light_target: device_id: 226779fb30bd68c5a2784ccd762d90e9 sun_condition: false -- id: '1731953745814' +- id: "1731953745814" alias: EVcharge-front-program - description: '' + description: "" triggers: - - trigger: state - entity_id: - - input_boolean.evcharge_front_start - from: 'off' - to: 'on' + - 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 + - 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 + - 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' +- id: "1732739522749" alias: Luce Automatica Taverna Garage - description: '' + description: "" use_blueprint: path: homeassistant/motion_light_tris_lux.yaml input: @@ -122,70 +124,141 @@ light_target: entity_id: light.taverna_garage sun_condition: false -- id: '1733907515800' + dont_disturb_condition: false +- 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 + - 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 conditions: [] actions: - - if: - condition: trigger id: - - EVcharge-front-on - then: + - p1-confort-light-on - type: turn_on - device_id: b69c1ca977ec6590e58689a8ab48cf3c - entity_id: 62f4895f11ca37d023aad1fddee7c0a0 - domain: switch - else: + device_id: e0397b54f1c2d1514be403e2996ca368 + entity_id: ef6706dbe425caf09693c084182ec228 + domain: light + brightness_pct: 100 + - condition: trigger + id: + - p1-confort-light-off - type: turn_off - device_id: b69c1ca977ec6590e58689a8ab48cf3c - entity_id: 62f4895f11ca37d023aad1fddee7c0a0 - domain: switch + device_id: e0397b54f1c2d1514be403e2996ca368 + entity_id: ef6706dbe425caf09693c084182ec228 + domain: light 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 - conditions: [] - actions: - - condition: trigger - id: - - p1-confort-light-on - - type: turn_on - device_id: e0397b54f1c2d1514be403e2996ca368 - entity_id: ef6706dbe425caf09693c084182ec228 - domain: light - brightness_pct: 100 - - condition: trigger - id: - - p1-confort-light-off - - type: turn_off - device_id: e0397b54f1c2d1514be403e2996ca368 - entity_id: ef6706dbe425caf09693c084182ec228 - domain: light - 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: "" + use_blueprint: + path: homeassistant/motion-light-new.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 + # - domain: mqtt + # # device_id: 0b221729867cef10dcb428820c082f79 + # type: action + # subtype: single + # trigger: device + # id: Pulsante1-single + # - domain: mqtt + # device_id: 0b221729867cef10dcb428820c082f79 + # type: action + # subtype: double + # trigger: device + # 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 diff --git a/blueprints/automation/homeassistant/motion-light-new.yaml b/blueprints/automation/homeassistant/motion-light-new.yaml new file mode 100644 index 0000000..7921faa --- /dev/null +++ b/blueprints/automation/homeassistant/motion-light-new.yaml @@ -0,0 +1,71 @@ +blueprint: + name: Motion-activated Light NEW + description: Turn on a light when motion is detected NEW. + domain: automation + source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml + author: Home Assistant + input: + motion_entity1: + name: Motion-sensor1 + selector: + entity: + filter: + device_class: switch + domain: binary_sensor + motion_entity2: + name: Motion-sensor2 + selector: + entity: + filter: + device_class: motion + domain: binary_sensor + light_target: + name: Light + selector: + target: + entity: + domain: light + 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 + +# If motion is detected within the delay, +# we restart the script. +mode: restart +max_exceeded: silent + +triggers: + - trigger: state + entity_id: !input motion_entity1 + from: "off" + to: "on" + - trigger: state + entity_id: !input motion_entity2 + from: "off" + to: "on" + +actions: + - alias: "Turn on the light" + action: light.turn_on + target: !input light_target + - alias: "Wait until there is no motion from device1" + wait_for_trigger: + - trigger: state + entity_id: !input motion_entity1 + from: "on" + to: "off" + - trigger: state + entity_id: !input motion_entity2 + from: "on" + to: "off" + - alias: "Wait the number of seconds that has been set" + 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_dual_lux.yaml b/blueprints/automation/homeassistant/motion_light_dual_lux.yaml index 4ec8b09..1e9f383 100644 --- a/blueprints/automation/homeassistant/motion_light_dual_lux.yaml +++ b/blueprints/automation/homeassistant/motion_light_dual_lux.yaml @@ -33,6 +33,12 @@ blueprint: default: on selector: boolean: + dont_disturb_condition: + 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. @@ -89,11 +95,21 @@ actions: id: - motion-detected then: - - action: light.turn_on - target: !input light_target - data: - brightness_pct: 100 - color_temp_kelvin: 2700 + - if: + - condition: template + value_template: "{{ dont_disturb_condition }}" + then: + - action: light.turn_on + target: !input light_target + data: + brightness_pct: states('dont_disturb_light_brightness') + color_temp_kelvin: 2500 + else: + - action: light.turn_on + target: !input light_target + data: + brightness_pct: 100 + color_temp_kelvin: 2500 else: - action: light.turn_off metadata: {} @@ -107,11 +123,21 @@ actions: id: - motion-detected then: - - action: light.turn_on - target: !input light_target - data: - brightness_pct: 100 - color_temp_kelvin: 2700 + - if: + - condition: template + value_template: "{{ dont_disturb_condition }}" + then: + - action: light.turn_on + target: !input light_target + data: + brightness_pct: states('dont_disturb_light_brightness') + color_temp_kelvin: 2500 + else: + - action: light.turn_on + target: !input light_target + data: + brightness_pct: 100 + color_temp_kelvin: 2500 else: - action: light.turn_off metadata: {} diff --git a/blueprints/automation/homeassistant/motion_light_tris_lux.yaml b/blueprints/automation/homeassistant/motion_light_tris_lux.yaml index 77e3b07..50c8f0b 100644 --- a/blueprints/automation/homeassistant/motion_light_tris_lux.yaml +++ b/blueprints/automation/homeassistant/motion_light_tris_lux.yaml @@ -111,8 +111,7 @@ actions: then: - if: - condition: template - # value_template: "{{ use_dont_disturb }}" - value_template: "{{ dont_disturb_nighttime }}" + value_template: "{{ dont_disturb_condition }}" then: - action: light.turn_on target: !input light_target @@ -142,7 +141,7 @@ actions: then: - if: - condition: template - value_template: "{{ use_dont_disturb }}" + value_template: "{{ dont_disturb_condition }}" then: - action: light.turn_on target: !input light_target