diff --git a/homeassistant/automation/motion/detected_animal_notify.yaml b/homeassistant/automation/motion/detected_animal_notify.yaml index 256e3b6e8..306f896b4 100644 --- a/homeassistant/automation/motion/detected_animal_notify.yaml +++ b/homeassistant/automation/motion/detected_animal_notify.yaml @@ -34,11 +34,17 @@ notification_id: > motion_detected_animal-{{- states('sensor.motion_detected_animal_camera') -}} message: >- - {{ '![](' - + states('sensor.motion_base_url') - + '/local/images/motion_detected_animal-' - + states('sensor.motion_detected_animal_camera') - + '.jpg?e=' + {{ '[![](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_animal-' + + states('sensor.motion_detected_animal_camera') + + '.jpg?e=' + + states('sensor.motion_detected_animal_event_' + states('sensor.motion_detected_animal_camera')) + + ')](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_animal_animated-' + + states('sensor.motion_detected_animal_camera') + + '.gif?e=' + states('sensor.motion_detected_animal_event_' + states('sensor.motion_detected_animal_camera')) + ')' }} Detected {{ states('sensor.motion_detected_animal_count') }} animal(s) diff --git a/homeassistant/automation/motion/detected_entity_notify.yaml b/homeassistant/automation/motion/detected_entity_notify.yaml index c9302dc98..2a0dae2dd 100644 --- a/homeassistant/automation/motion/detected_entity_notify.yaml +++ b/homeassistant/automation/motion/detected_entity_notify.yaml @@ -4,18 +4,24 @@ - id: motion_detected_entity_notify alias: motion_detected_entity_notify - initial_state: on + initial_state: 'on' trigger: - platform: state - entity_id: sensor.motion_detected_entity_when + entity_id: binary_sensor.motion_detected_entity condition: condition: and conditions: - condition: template - value_template: >- + value_template: > + {{ trigger.to_state.state != trigger.from_state.state }} + - condition: template + value_template: > + {{ is_state('binary_sensor.motion_detected_entity','on') }} + - condition: template + value_template: > {{ is_state('input_boolean.motion_detected_entity_notify','on') }} - condition: template - value_template: >- + value_template: > {{ states('sensor.motion_detected_entity_count')|int > 0 }} action: - service: persistent_notification.create @@ -24,15 +30,21 @@ Detected {{ states('sensor.motion_detected_entity_count') }} {{ states('sensor.motion_detect_entity') -}}(s) from {{ states('sensor.motion_detected_entity_camera') }} notification_id: > - detected_entity-{{- states('sensor.motion_event_detected_entity_camera') -}} + motion_detected_entity-{{- states('sensor.motion_detected_entity_camera') -}} message: >- - {{ '![](' - + states('sensor.motion_base_url') - + '/local/images/motion_detected_entity-' - + states('sensor.motion_detected_entity_camera') - + '.jpg?v1' + {{ '[![](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_entity-' + + states('sensor.motion_detected_entity_camera') + + '.jpg?e=' + + states('sensor.motion_detected_entity_event_' + states('sensor.motion_detected_entity_camera')) + + ')](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_entity_animated-' + + states('sensor.motion_detected_entity_camera') + + '.gif?e=' + + states('sensor.motion_detected_entity_event_' + states('sensor.motion_detected_entity_camera')) + ')' }} Detected {{ states('sensor.motion_detected_entity_count') }} {{ states('sensor.motion_detect_entity') -}}(s) - from {{ states('sensor.motion_detected_entity_camera') }} for {{ states('sensor.motion_detected_entity_elapsed') }} seconds at {{ states('sensor.motion_detected_entity_when') }} diff --git a/homeassistant/automation/motion/detected_notify.yaml b/homeassistant/automation/motion/detected_notify.yaml index 5c1553fd8..c8e45269c 100644 --- a/homeassistant/automation/motion/detected_notify.yaml +++ b/homeassistant/automation/motion/detected_notify.yaml @@ -36,3 +36,50 @@ from {{ states('sensor.motion_detected_camera') }} for {{ states('sensor.motion_detected_elapsed') }} seconds at {{ states('sensor.motion_detected_when') }} + +- id: motion_detected_notify + alias: motion_detected_notify + initial_state: 'on' + trigger: + - platform: state + entity_id: binary_sensor.motion_detected + condition: + condition: and + conditions: + - condition: template + value_template: > + {{ trigger.to_state.state != trigger.from_state.state }} + - condition: template + value_template: > + {{ is_state('binary_sensor.motion_detected','on') }} + - condition: template + value_template: > + {{ is_state('input_boolean.motion_detected_notify','on') }} + - condition: template + value_template: > + {{ states('sensor.motion_detected_count')|int > 0 }} + action: + - service: persistent_notification.create + data_template: + title: >- + Detected {{ states('sensor.motion_detected_count') }} entity(s) + from {{ states('sensor.motion_detected_camera') }} + notification_id: > + motion_detected-{{- states('sensor.motion_detected_camera') -}} + message: >- + {{ '[![](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected-' + + states('sensor.motion_detected_camera') + + '.jpg?e=' + + states('sensor.motion_detected_event_' + states('sensor.motion_detected_camera')) + + ')](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_animated-' + + states('sensor.motion_detected_camera') + + '.gif?e=' + + states('sensor.motion_detected_event_' + states('sensor.motion_detected_camera')) + + ')' }} + Detected {{ states('sensor.motion_detected_count') -}}: {{ states('sensor.motion_detected_list') }}: + for {{ states('sensor.motion_detected_elapsed') }} seconds + at {{ states('sensor.motion_detected_when') }} diff --git a/homeassistant/automation/motion/detected_person_notify.yaml b/homeassistant/automation/motion/detected_person_notify.yaml index 0568c751b..ca4346937 100644 --- a/homeassistant/automation/motion/detected_person_notify.yaml +++ b/homeassistant/automation/motion/detected_person_notify.yaml @@ -34,11 +34,17 @@ notification_id: > motion_detected_person-{{- states('sensor.motion_detected_person_camera') -}} message: >- - {{ '![](' - + states('sensor.motion_base_url') - + '/local/images/motion_detected_person-' - + states('sensor.motion_detected_person_camera') - + '.jpg?e=' + {{ '[![](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_person-' + + states('sensor.motion_detected_person_camera') + + '.jpg?e=' + + states('sensor.motion_detected_person_event_' + states('sensor.motion_detected_person_camera')) + + ')](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_person_animated-' + + states('sensor.motion_detected_person_camera') + + '.gif?e=' + states('sensor.motion_detected_person_event_' + states('sensor.motion_detected_person_camera')) + ')' }} Detected {{ states('sensor.motion_detected_person_count') }} person(s) diff --git a/homeassistant/automation/motion/detected_vehicle_notify.yaml b/homeassistant/automation/motion/detected_vehicle_notify.yaml index d4bec76bf..063b2fbbd 100644 --- a/homeassistant/automation/motion/detected_vehicle_notify.yaml +++ b/homeassistant/automation/motion/detected_vehicle_notify.yaml @@ -34,11 +34,17 @@ notification_id: > motion_detected_vehicle-{{- states('sensor.motion_detected_vehicle_camera') -}} message: >- - {{ '![](' - + states('sensor.motion_base_url') - + '/local/images/motion_detected_vehicle-' - + states('sensor.motion_detected_vehicle_camera') - + '.jpg?e=' + {{ '[![](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_vehicle-' + + states('sensor.motion_detected_vehicle_camera') + + '.jpg?e=' + + states('sensor.motion_detected_vehicle_event_' + states('sensor.motion_detected_vehicle_camera')) + + ')](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_vehicle_animated-' + + states('sensor.motion_detected_vehicle_camera') + + '.gif?e=' + states('sensor.motion_detected_vehicle_event_' + states('sensor.motion_detected_vehicle_camera')) + ')' }} Detected {{ states('sensor.motion_detected_vehicle_count') }} vehicle(s) diff --git a/homeassistant/motion/automation.webcam.yaml.tmpl b/homeassistant/motion/automation.webcam.yaml.tmpl index 4d4b954ae..16007473c 100644 --- a/homeassistant/motion/automation.webcam.yaml.tmpl +++ b/homeassistant/motion/automation.webcam.yaml.tmpl @@ -1712,11 +1712,11 @@ - service: persistent_notification.create data_template: title: > - Camera ${MOTION_CAMERA} found + ${MOTION_CAMERA} camera found notification_id: > ${MOTION_CAMERA} message: >- - Camera ${MOTION_CAMERA} was {{ trigger.from_state.state }}; + ${MOTION_CAMERA} camera was {{ trigger.from_state.state }}; found at {{ now().timestamp()|int|timestamp_custom("%a %b %d @ %I:%M %p %Z") | default(null) }} ## lost @@ -1739,11 +1739,11 @@ - service: persistent_notification.create data_template: title: > - Camera ${MOTION_CAMERA} lost + ${MOTION_CAMERA} camera lost notification_id: > ${MOTION_CAMERA} message: >- - Camera ${MOTION_CAMERA} was {{ trigger.from_state.state }}; + ${MOTION_CAMERA} camera was {{ trigger.from_state.state }}; lost at {{ now().timestamp()|int|timestamp_custom("%a %b %d @ %I:%M %p %Z") | default(null) }} ### @@ -1752,35 +1752,49 @@ - id: motion_detected_notify_${MOTION_CAMERA} alias: motion_detected_notify_${MOTION_CAMERA} - initial_state: off + initial_state: 'on' trigger: - platform: state - entity_id: counter.motion_detected_counter_${MOTION_CAMERA} + entity_id: binary_sensor.motion_detected_${MOTION_CAMERA} condition: - condition: template - value_template: > - {{ is_state('input_boolean.motion_detected_notify','on') }} + condition: and + conditions: + - condition: template + value_template: > + {{ trigger.to_state.state != trigger.from_state.state }} + - condition: template + value_template: > + {{ is_state('binary_sensor.motion_detected_${MOTION_CAMERA}','on') }} + - condition: template + value_template: > + {{ is_state('input_boolean.motion_detected_notify_${MOTION_CAMERA}','on') }} + - condition: template + value_template: > + {{ states('sensor.motion_detected_count_${MOTION_CAMERA}')|int > 0 }} action: - service: persistent_notification.create data_template: title: >- - Detected {{ states.sensor.motion_annotated_count_${MOTION_CAMERA}.state }} {{ states.sensor.motion_detect_entity_${MOTION_CAMERA}.state }}(s) - from {{ states.sensor.motion_event_annotated_${MOTION_CAMERA}.attributes.event.camera }} - notification_id: > - detected-{{- states.sensor.motion_event_annotated_${MOTION_CAMERA}.attributes.event.camera -}} + Detected {{ states('sensor.motion_detected_count_${MOTION_CAMERA}') }} entity(s) + from {{ states('sensor.motion_detected_camera_${MOTION_CAMERA}') }} + notification_id: >- + {{ 'motion_detected-${MOTION_CAMERA}' }} message: >- - {{ '![](' - + states('sensor.motion_base_url') - + '/local/images/motion_detected-' - + '${MOTION_CAMERA}' + {{ '[![](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected-${MOTION_CAMERA}' + '.jpg?e=' - + states('sensor.motion_detected_event_${MOTION_CAMERA}') + + states('sensor.motion_detected_event_${MOTION_CAMERA}' + + ')](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_animated-${MOTION_CAMERA}' + + '.gif?e=' + + states('sensor.motion_detected_event_${MOTION_CAMERA}' + ')' }} - Detected {{ states.sensor.motion_annotated_count_${MOTION_CAMERA}.state }} entity(s) - from {{ states.sensor.motion_event_annotated_${MOTION_CAMERA}.attributes.event.camera }} - for {{ states.sensor.motion_event_annotated_${MOTION_CAMERA}.attributes.event.elapsed }} seconds - ({{ states.sensor.motion_event_annotated_${MOTION_CAMERA}.attributes.event.images|length }} frames) - at {{ states.sensor.motion_event_annotated_${MOTION_CAMERA}.attributes.event.start|int|timestamp_custom("%a %b %d @ %I:%M %p UTC") | default(null) }} + Camera ${MOTION_CAMERA} detected {{ states('sensor.motion_detected_count_${MOTION_CAMERA}') -}}: + {{ states('sensor.motion_detected_list_${MOTION_CAMERA}') -}}; + for {{ states('sensor.motion_detected_elapsed_${MOTION_CAMERA}') }} seconds + at {{ states('sensor.motion_detected_when_${MOTION_CAMERA}') }} ## # notify detected_entity @@ -1788,40 +1802,48 @@ - id: motion_detected_entity_notify_${MOTION_CAMERA} alias: motion_detected_entity_notify_${MOTION_CAMERA} - initial_state: on + initial_state: 'on' trigger: - platform: state - entity_id: counter.motion_detected_entity_counter_${MOTION_CAMERA} + entity_id: binary_sensor.motion_detected_entity_${MOTION_CAMERA} condition: condition: and conditions: - condition: template value_template: > {{ trigger.to_state.state != trigger.from_state.state }} + - condition: template + value_template: > + {{ is_state('binary_sensor.motion_detected_entity_${MOTION_CAMERA}','on') }} - condition: template value_template: > {{ is_state('input_boolean.motion_detected_entity_notify_${MOTION_CAMERA}','on') }} + - condition: template + value_template: > + {{ states('sensor.motion_detected_entity_count_${MOTION_CAMERA}')|int > 0 }} action: - service: persistent_notification.create data_template: title: >- - Detected {{ states.sensor.motion_annotated_count_entity_${MOTION_CAMERA}.state }} {{ states.sensor.motion_detect_entity_${MOTION_CAMERA}.state }}(s) - from {{ states.sensor.motion_event_annotated_${MOTION_CAMERA}.attributes.event.camera }} - notification_id: > - detected_entity-{{- states.sensor.motion_event_annotated_${MOTION_CAMERA}.attributes.event.camera -}} + Detected {{ states('sensor.motion_detected_entity_count_${MOTION_CAMERA}') }} entity(s) + from {{ states('sensor.motion_detected_entity_camera_${MOTION_CAMERA}') }} + notification_id: >- + {{ 'motion_detected_entity-${MOTION_CAMERA}' }} message: >- - {{ '![](' - + states('sensor.motion_base_url') - + '/local/images/motion_detected_entity-' - + '${MOTION_CAMERA}' + {{ '[![](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_entity-${MOTION_CAMERA}' + '.jpg?e=' - + states('sensor.motion_detected_entity_event_${MOTION_CAMERA}') + + states('sensor.motion_detected_entity_event_${MOTION_CAMERA}' + + ')](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_entity_animated-${MOTION_CAMERA}' + + '.gif?e=' + + states('sensor.motion_detected_entity_event_${MOTION_CAMERA}' + ')' }} - Detected {{ states.sensor.motion_annotated_count_entity_${MOTION_CAMERA}.state }} {{ states.sensor.motion_detect_entity_${MOTION_CAMERA}.state }}(s) - from {{ states.sensor.motion_event_annotated_${MOTION_CAMERA}.attributes.event.camera }} - for {{ states.sensor.motion_event_annotated_${MOTION_CAMERA}.attributes.event.elapsed }} seconds - ({{ states.sensor.motion_event_annotated_${MOTION_CAMERA}.attributes.event.images|length }} frames) - at {{ states.sensor.motion_event_annotated_${MOTION_CAMERA}.attributes.event.start|int|timestamp_custom("%a %b %d @ %I:%M %p UTC") | default(null) }} + Camera ${MOTION_CAMERA} detected {{ states('sensor.motion_detected_entity_count_${MOTION_CAMERA}') }} entity(s) + for {{ states('sensor.motion_detected_entity_elapsed_${MOTION_CAMERA}') }} seconds + at {{ states('sensor.motion_detected_entity_when_${MOTION_CAMERA}') }} ## # notify detected_person @@ -1853,18 +1875,22 @@ data_template: title: >- Detected {{ states('sensor.motion_detected_person_count_${MOTION_CAMERA}') }} person(s) - from ${MOTION_CAMERA} - notification_id: > - motion_detected_person_${MOTION_CAMERA}-{{- states('sensor.motion_detected_person_camera') -}} + from {{ states('sensor.motion_detected_person_camera_${MOTION_CAMERA}') }} + notification_id: >- + {{ 'motion_detected_person-${MOTION_CAMERA}' }} message: >- - {{ '![](' - + states('sensor.motion_base_url') - + '/local/images/motion_detected_person-' - + '${MOTION_CAMERA}' + {{ '[![](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_person-${MOTION_CAMERA}' + '.jpg?e=' - + states('sensor.motion_detected_person_event_${MOTION_CAMERA}') + + states('sensor.motion_detected_person_event_${MOTION_CAMERA}' + + ')](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_person_animated-${MOTION_CAMERA}' + + '.gif?e=' + + states('sensor.motion_detected_person_event_${MOTION_CAMERA}' + ')' }} - Detected {{ states('sensor.motion_detected_person_count_${MOTION_CAMERA}') }} person(s) + Camera ${MOTION_CAMERA} detected {{ states('sensor.motion_detected_person_count_${MOTION_CAMERA}') }} person(s) for {{ states('sensor.motion_detected_person_elapsed_${MOTION_CAMERA}') }} seconds at {{ states('sensor.motion_detected_person_when_${MOTION_CAMERA}') }} @@ -1898,18 +1924,22 @@ data_template: title: >- Detected {{ states('sensor.motion_detected_vehicle_count_${MOTION_CAMERA}') }} vehicle(s) - from ${MOTION_CAMERA} - notification_id: > - motion_detected_vehicle_${MOTION_CAMERA}-{{- states('sensor.motion_detected_vehicle_camera') -}} + from {{ states('sensor.motion_detected_vehicle_camera_${MOTION_CAMERA}') }} + notification_id: >- + {{ 'motion_detected_vehicle-${MOTION_CAMERA}' }} message: >- - {{ '![](' - + states('sensor.motion_base_url') - + '/local/images/motion_detected_vehicle-' - + '${MOTION_CAMERA}' + {{ '[![](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_vehicle-${MOTION_CAMERA}' + '.jpg?e=' - + states('sensor.motion_detected_vehicle_event_${MOTION_CAMERA}') + + states('sensor.motion_detected_vehicle_event_${MOTION_CAMERA}' + + ')](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_vehicle_animated-${MOTION_CAMERA}' + + '.gif?e=' + + states('sensor.motion_detected_vehicle_event_${MOTION_CAMERA}' + ')' }} - Detected {{ states('sensor.motion_detected_vehicle_count_${MOTION_CAMERA}') }} vehicle(s) + Camera ${MOTION_CAMERA} detected {{ states('sensor.motion_detected_vehicle_count_${MOTION_CAMERA}') }} vehicle(s) for {{ states('sensor.motion_detected_vehicle_elapsed_${MOTION_CAMERA}') }} seconds at {{ states('sensor.motion_detected_vehicle_when_${MOTION_CAMERA}') }} @@ -1943,18 +1973,22 @@ data_template: title: >- Detected {{ states('sensor.motion_detected_animal_count_${MOTION_CAMERA}') }} animal(s) - from ${MOTION_CAMERA} - notification_id: > - motion_detected_animal_${MOTION_CAMERA}-{{- states('sensor.motion_detected_animal_camera') -}} + from {{ states('sensor.motion_detected_animal_camera_${MOTION_CAMERA}') }} + notification_id: >- + {{ 'motion_detected_animal-${MOTION_CAMERA}' }} message: >- - {{ '![](' - + states('sensor.motion_base_url') - + '/local/images/motion_detected_animal-' - + '${MOTION_CAMERA}' + {{ '[![](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_animal-${MOTION_CAMERA}' + '.jpg?e=' - + states('sensor.motion_detected_animal_event_${MOTION_CAMERA}') + + states('sensor.motion_detected_animal_event_${MOTION_CAMERA}' + + ')](' + + states('sensor.motion_base_url') + + '/local/images/motion_detected_animal_animated-${MOTION_CAMERA}' + + '.gif?e=' + + states('sensor.motion_detected_animal_event_${MOTION_CAMERA}' + ')' }} - Detected {{ states('sensor.motion_detected_animal_count_${MOTION_CAMERA}') }} animal(s) + Camera ${MOTION_CAMERA} detected {{ states('sensor.motion_detected_animal_count_${MOTION_CAMERA}') }} animal(s) for {{ states('sensor.motion_detected_animal_elapsed_${MOTION_CAMERA}') }} seconds at {{ states('sensor.motion_detected_animal_when_${MOTION_CAMERA}') }}