Skip to content

Instantly share code, notes, and snippets.

@barto95100
Last active June 1, 2021 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barto95100/c3f8e2f55651509f23304644747ebaa6 to your computer and use it in GitHub Desktop.
Save barto95100/c3f8e2f55651509f23304644747ebaa6 to your computer and use it in GitHub Desktop.
Notification sur détection de mouvement de camera + délais de pause
blueprint:
name: Envoi d'une notification sur détection de mouvement avec pause de notification
description: >
Cette automatisation permet de créer une instantanée si une detection de mouvement est détecter
et envoie l'image sur le mobile souhaiter
domain: automation
input:
motion_sensor:
name: Motion sensor
description: Le capteur qui déclenche la création de l'instantané
selector:
entity:
domain: binary_sensor
device_class: motion
camera:
name: Camera
description: La caméra qui crée l'instantané
selector:
entity:
domain: camera
notify_device:
name: Device to notify
description: Le mobile doit exécuter l'application officielle Home Assistant pour recevoir des notifications
default: false
selector:
device:
integration: mobile_app
is_ios:
name: Is it an iOS device?
description: Activer si le mobile recevant la notification est sous IOS sinon laissez désactiver pour mobile sous Android
selector:
boolean:
default: false
notification_title:
name: Notification title (Optional)
description: 'Default: "Motion detected!"'
default: "Motion detected!"
notification_message:
name: Notification message (Optional)
description: 'Default: "{{ motion_sensor_name }} detected movement!"'
default: "{{ motion_sensor_name }} detected movement!"
delay:
name: Delay (Optional)
description: Délais avant la création de l'instantané de la caméra après détection de mouvement
default: ""
selector:
number:
min: 0
max: 60
unit_of_measurement: seconds
mode: slider
cooldown:
name: (Optional) Cooldown
description: Délai avant l'envoi d'une autre notification pour cette caméra après la dernière détection de mouvement.
default: 30
selector:
number:
max: 300
min: 0
unit_of_measurement: seconds
silence_timer:
name: (Optional) Silence Notifications
description: >
Temps de désactivation pendant laquel la notification sera suspendu.
default: 30
selector:
number:
max: 300
min: 0
unit_of_measurement: minutes
trigger:
platform: state
entity_id: !input motion_sensor
from: "off"
to: "on"
variables:
motion_sensor: !input motion_sensor
motion_sensor_name: "{{ states[motion_sensor].name }}"
camera: !input camera
notify_device: !input notify_device
is_ios: !input is_ios
notification_title: !input notification_title
notification_message: !input notification_message
delay: !input delay
snapshot_create_file_path: "/config/www/tmp/snapshot_{{ states[camera].object_id }}.jpg"
snapshot_access_file_path: "{{ snapshot_create_file_path | replace('/config/www','/local') }}"
action:
- delay: "{{ delay }}"
- service: camera.snapshot
entity_id: !input camera
data:
filename: "{{ snapshot_create_file_path }}"
- device_id: !input notify_device
domain: mobile_app
type: notify
title: "{{ notification_title }}"
message: "{{ notification_message }}"
data: >
{% set android_data = {"image": "%s"} | format(snapshot_access_file_path) %}
{% set ios_data = {"attachment": {"url": "%s", "content_type": "JPEG"}} | format(snapshot_access_file_path) %}
{{ ios_data if is_ios else android_data }}
actions:
- action: 'silence-{{ camera }}'
title: Silence Notifications
destructive: true
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: 'silence-{{ camera }}'
timeout:
seconds: !input cooldown
continue_on_timeout: false
- delay:
minutes: !input silence_timer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment