-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbosch_camera_signal_alert.yaml
More file actions
146 lines (129 loc) · 4.96 KB
/
Copy pathbosch_camera_signal_alert.yaml
File metadata and controls
146 lines (129 loc) · 4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
blueprint:
name: "Bosch Camera — Signal Alert with Snapshot"
description: >
Sends a Signal message with the event snapshot when a Bosch Smart Home
camera detects motion or an audio alarm.
Requires a Signal notification service in HA (e.g. signal_messenger via
signal-cli-rest-api, or any notify.* service that supports images).
The integration fires `bosch_shc_camera_motion` and `bosch_shc_camera_audio_alarm`
events on the HA event bus — this blueprint triggers on those events.
Works with both FCM push (instant, ~2s) and polling (interval_events, default 5min).
domain: automation
author: mosandlt
source_url: https://github.com/mosandlt/Bosch-Smart-Home-Camera-Tool-HomeAssistant/blob/main/blueprints/bosch_camera_signal_alert.yaml
input:
notify_service:
name: Notification service
description: >
The notify service to use (e.g. notify.signal_messenger, notify.mobile_app_iphone).
Must support sending images via the `data.attachment.url` or `data.photo` field.
selector:
text:
default: "notify.signal_messenger"
event_types:
name: Event types to alert on
description: Which event types trigger a notification
selector:
select:
multiple: true
options:
- label: "Motion (MOVEMENT)"
value: "motion"
- label: "Audio Alarm (AUDIO_ALARM)"
value: "audio"
default:
- motion
- audio
cooldown_seconds:
name: Cooldown (seconds)
description: Minimum seconds between alerts per camera (prevents notification spam)
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
default: 30
include_snapshot:
name: Include snapshot image
description: Download and attach the event JPEG snapshot to the notification
selector:
boolean:
default: true
message_template:
name: Message template
description: >
Notification message. Available variables:
{{ camera_name }}, {{ event_type }}, {{ timestamp }}
selector:
text:
multiline: true
default: "{{ camera_name }}: {{ event_type }} um {{ timestamp }}"
# ─────────────────────────────────────────────────────────────────────────────
trigger:
- platform: event
event_type: bosch_shc_camera_motion
id: motion
- platform: event
event_type: bosch_shc_camera_audio_alarm
id: audio
condition:
# Check if this event type is enabled
- condition: template
value_template: >
{{ trigger.id in (input_event_types | default(['motion', 'audio'])) }}
# Per-camera cooldown
mode: queued
max: 5
variables:
input_event_types: !input event_types
input_notify_service: !input notify_service
input_cooldown: !input cooldown_seconds
input_include_snapshot: !input include_snapshot
input_message_template: !input message_template
camera_name: "{{ trigger.event.data.camera_name }}"
event_type: >
{% if trigger.id == 'motion' %}Bewegung{% else %}Audio-Alarm{% endif %}
timestamp: "{{ trigger.event.data.timestamp[:19] | default('?') }}"
image_url: "{{ trigger.event.data.image_url | default('') }}"
event_id: "{{ trigger.event.data.event_id | default('') }}"
source: "{{ trigger.event.data.get('source', 'polling') }}"
action:
# Cooldown check — skip if last alert for this camera was too recent
- condition: template
value_template: >
{% set last = state_attr('automation.' ~ this.entity_id.split('.')[1], 'last_triggered') %}
{% if last is none %}true
{% else %}{{ (now() - last).total_seconds() > input_cooldown }}
{% endif %}
# Wait 2s for the snapshot to be available on the Bosch cloud
- delay:
seconds: 2
# Send notification with or without image
- choose:
- conditions:
- condition: template
value_template: "{{ input_include_snapshot and image_url != '' }}"
sequence:
# Download snapshot to /config/www/ for local access
- service: downloader.download_file
data:
url: "{{ image_url }}"
filename: "bosch_alert_{{ event_id[:8] }}.jpg"
overwrite: true
continue_on_error: true
- service: "{{ input_notify_service }}"
data:
title: "{{ camera_name }}"
message: "{{ input_message_template }}"
data:
photo:
- url: "{{ image_url }}"
caption: "{{ camera_name }}: {{ event_type }} ({{ timestamp }})"
attachment:
url: "{{ image_url }}"
image: "{{ image_url }}"
default:
- service: "{{ input_notify_service }}"
data:
title: "{{ camera_name }}"
message: "{{ input_message_template }}"