Hello hellooo!
I’ve started just recently with HA and Node RED.
I’m trying to get the automations to work via yaml first, and then integrate them into node red. I prefer the node red because of the visual aspect, but I’m still learning both. I got the yaml configuration somewhere here from the forum.
I need a little help with the following to implement this in node red:
alias: Frigate - Notification email
description: ""
trigger:
- platform: mqtt
topic: frigate/events
condition:
- condition: template
value_template: "{{ trigger.payload_json[\"type\"] == \"end\" }}"
action:
- service: notify.email_notify
data:
title: "Camera {{trigger.payload_json['after']['camera']}}: Motion!"
message: >-
Detected object {{trigger.payload_json['after']['label']}} by camera
{{trigger.payload_json['after']['camera']}}.
data:
images:
- >-
/media/frigate/clips/{{trigger.payload_json['after']['camera']}}-{{trigger.payload_json['after']['id']}}.jpg
html: >
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Intruder alert</title>
</head>
<body>
<div>
<div>
<h5>Motion detected by camera: <b>{{trigger.payload_json['after']['camera']}}</b></h5>
</div>
<div>
Picture<br><img style="width: 100%; "alt="snapshot1" src="cid:{{trigger.payload_json['after']['camera']}}-{{trigger.payload_json['after']['id']}}.jpg" />
<br>
Object: {{trigger.payload_json["after"]["label"]}}
<br>
Time: '{{trigger.payload_json["after"]["start_time"]|int}}'
</div>
<div>
<p>
<h5>Links</h5>
<ul>
<li><a href="http://192.168.50.247:8123/api/frigate/notifications/{{trigger.payload_json['after']['id']}}/snapshot.jpg">Link to Snapshot</a></li>
<li><a href="http://192.168.50.247:8123/lovelace/cameras">Home Assistant Cameras</a></li>
<li><a href="http://192.168.50.247:8123/media-browser/browser/app%2Cmedia-source%3A%2F%2Ffrigate">Home Assistant Media Browser</a></li>
</ul>
</p>
</div>
</div>
</body>
</html>
- service: notify.matrix_notify
data:
title: "Camera {{trigger.payload_json['after']['camera']}}: Motion!"
message: >-
Detected object {{trigger.payload_json['after']['label']}} by camera
{{trigger.payload_json['after']['camera']}}.
data:
images:
- >-
/media/frigate/clips/{{trigger.payload_json['after']['camera']}}-{{trigger.payload_json['after']['id']}}.jpg
I have trouble with the condition and html output for emails. Is it even possible to use html in node red? The rest works.
I would also like to attach the records to the email and send them also to Matrix if possible. The path to the records is /media/frigate/recordings/2022-12/16/15/Camera1/26.16.mp4
which is basically /media/frigate/recordings/year-month/day/hour/Camera1/minutes.seconds.mp4
.
Anyone out there who can help me?
Thanks!