motion_light rewritten (no permanence between two motion sensor)

This commit is contained in:
2024-11-06 21:18:18 +01:00
parent 437553f5ec
commit 126df51438
3 changed files with 123 additions and 119 deletions

View File

@@ -1,13 +1,3 @@
- id: '1728594248560'
alias: Luce Scala Mansarda (sensore alto)
description: Attiva Luce Scala Mansarda su presenza
use_blueprint:
path: homeassistant/motion_light_custom.yaml
input:
motion_entity: binary_sensor.presenza_alta_scala_mansarda_occupancy
light_target:
device_id: 702137a6f2c17b89fdb0598f7003743c
no_motion_wait: 20
- id: '1729875991469' - id: '1729875991469'
alias: BagnoOvest-save-energy alias: BagnoOvest-save-energy
description: Thermostat will close upon window open description: Thermostat will close upon window open
@@ -56,33 +46,3 @@
light_target: light_target:
device_id: 702137a6f2c17b89fdb0598f7003743c device_id: 702137a6f2c17b89fdb0598f7003743c
no_motion_wait: 20 no_motion_wait: 20
- id: '1730750325096'
alias: Luce Scala Mansarda (sensore basso)
description: Attiva Luce Scala Mansarda su presenza
use_blueprint:
path: homeassistant/motion_light_custom.yaml
input:
motion_entity: binary_sensor.presenza_bassa_scala_mansarda_occupancy
light_target:
device_id: 702137a6f2c17b89fdb0598f7003743c
no_motion_wait: 20
- id: '1730750447496'
alias: Luce Scala Taverna (sensore alto)
description: Attiva Luce Scala Mansarda su presenza
use_blueprint:
path: homeassistant/motion_light_custom.yaml
input:
motion_entity: binary_sensor.presenza_alta_scala_taverna_occupancy
light_target:
device_id: 226779fb30bd68c5a2784ccd762d90e9
no_motion_wait: 20
- id: '1730750486844'
alias: Luce Scala Taverna (sensore basso)
description: Attiva Luce Scala Mansarda su presenza
use_blueprint:
path: homeassistant/motion_light_custom.yaml
input:
motion_entity: binary_sensor.presenza_bassa_scala_taverna_occupancy
light_target:
device_id: 226779fb30bd68c5a2784ccd762d90e9
no_motion_wait: 20

View File

@@ -45,6 +45,49 @@ blueprint:
trigger_variables: trigger_variables:
use_sun: !input sun_condition use_sun: !input sun_condition
triggers:
- trigger: state
entity_id:
- !input motion_entity_up
- !input motion_entity_down
to: "on"
id: motion-detected
- trigger: state
entity_id:
- !input motion_entity_up
- !input motion_entity_down
to: "off"
for:
hours: 0
minutes: 0
seconds: !input no_motion_wait
conditions:
- condition: sun
after: sunset
after_offset: "-01:00:00"
before: sunrise
before_offset: "+01:00:00"
actions:
- if:
- condition: trigger
id:
- motion-detected
then:
- action: light.turn_on
target: !input light_target
data: {}
else:
- action: light.turn_off
metadata: {}
data:
transition: 10
target: !input light_target
mode: single
######################## Save Esperimenti ##############################
# local_condition: # local_condition:
# mode: single # mode: single
# sequence: # sequence:
@@ -65,50 +108,55 @@ trigger_variables:
# sequence: # sequence:
# data: [] # data: []
#################### Original single sensor motion detector ###########
# If motion is detected within the delay, # If motion is detected within the delay,
# we restart the script. # we restart the script.
mode: restart # mode: restart
max_exceeded: silent # max_exceeded: silent
#
triggers: # triggers:
- trigger: state # - trigger: state
entity_id: !input motion_entity_down # entity_id: !input motion_entity_down
from: "off" # id: motion_entity_down_id
to: "on" # from: "off"
- trigger: state # to: "on"
entity_id: !input motion_entity_up # - trigger: state
from: "off" # entity_id: !input motion_entity_up
to: "on" # id: motion_entity_up_id
# from: "off"
# {% if states( use_sun ) %} # to: "on"
conditions: #
- condition: sun # # {% if states( use_sun ) %}
after: sunset # conditions:
after_offset: "-01:00:00" # - condition: sun
before: sunrise # after: sunset
before_offset: "+01:00:00" # after_offset: "-01:00:00"
# {% endif %} # before: sunrise
# before_offset: "+01:00:00"
# conditions: "{{ local_conditions }}" # # {% endif %}
#
actions: # # conditions: "{{ local_conditions }}"
- alias: "Turn on the light" #
action: light.turn_on # actions:
target: !input light_target # - alias: "Turn on the light"
- alias: "Wait until there is no motion from up device" # action: light.turn_on
wait_for_trigger: # target: !input light_target
trigger: state # - alias: "Wait until there is no motion from up device"
entity_id: !input motion_entity_up # wait_for_trigger:
from: "on" # trigger: state
to: "off" # id: trigger_alto
- alias: "Wait until there is no motion from dow device" # entity_id: !input motion_entity_up
wait_for_trigger: # from: "on"
trigger: state # to: "off"
entity_id: !input motion_entity_down # - alias: "Wait until there is no motion from dow device"
from: "on" # wait_for_trigger:
to: "off" # trigger: state
- alias: "Wait the number of seconds that has been set" # id: trigger_basso
delay: !input no_motion_wait # entity_id: !input motion_entity_down
- alias: "Turn off the light" # from: "on"
action: light.turn_off # to: "off"
target: !input light_target # - 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

View File

@@ -1,5 +1,5 @@
blueprint: blueprint:
name: Dual Sensor Motion-activated Light Customised temporary no sun condition name: Dual Sensor Motion-activated Light Customised with selectable condition after sunset and before sunrise
description: Turn on a light when motion is detected. description: Turn on a light when motion is detected.
domain: automation domain: automation
# source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml # source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml
@@ -22,7 +22,7 @@ blueprint:
device_class: motion device_class: motion
domain: binary_sensor domain: binary_sensor
light_target: light_target:
name: Light` name: Light
selector: selector:
target: target:
entity: entity:
@@ -46,43 +46,39 @@ blueprint:
trigger_variables: trigger_variables:
use_sun: !input sun_condition use_sun: !input sun_condition
# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent
triggers: triggers:
- trigger: state - trigger: state
entity_id: !input motion_entity_down entity_id:
from: "off" - !input motion_entity_up
- !input motion_entity_down
to: "on" to: "on"
id: motion-detected
- trigger: state - trigger: state
entity_id: !input motion_entity_up entity_id:
from: "off" - !input motion_entity_up
to: "on" - !input motion_entity_down
to: "off"
for:
hours: 0
minutes: 0
seconds: !input no_motion_wait
# Temporary no condition for scala taverna
conditions: [] conditions: []
# Unable to set different condition based on sun condition flag
actions: actions:
- alias: "Turn on the light" - if:
action: light.turn_on - condition: trigger
target: !input light_target id:
- alias: "Wait until there is no motion from up device" - motion-detected
wait_for_trigger: then:
trigger: state - action: light.turn_on
entity_id: !input motion_entity_up target: !input light_target
# from: "on" data: {}
to: "off" else:
- alias: "Wait until there is no motion from down device" - action: light.turn_off
wait_for_trigger: metadata: {}
trigger: state data:
entity_id: !input motion_entity_down transition: 10
# from: "on" target: !input light_target
to: "off"
- alias: "Wait the number of seconds that has been set" mode: single
delay: !input no_motion_wait
- alias: "Turn off the light"
action: light.turn_off
target: !input light_target