Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 96121

Get mp4 file from MQTT message and send through telegram

$
0
0

@MoiZie wrote:

I am using 2 Xiaomi yi 1080p cams, hacked with https://github.com/roleoroleo/yi-hack-MStar so I can recieve MQTT messages. My goal is to create a low cost alarm system and I have already set up HomeAssistant (venv), mosquitto MQTT and working Telegram config. But now I’m struggling with getting the required movie files from the camera and sending them.

My camera MQTT messages are as follows:
First, upon detection of motion the camera sends:
Message 595 received on camera/balcony/motion at 14:44 :
motion_start
QoS: 0 - Retain: false

This is followed by:
Message 596 received on camera/balcony/motion at 14:45 :
motion_stop
QoS: 0 - Retain: false

And lastly:

Message 597 received on camera/balcony/files at 14:46 :
{
“start”: “2020-03-16T13:27:51+0000”,
“end”: “2020-03-16T13:28:53+0000”,
“files”: [
“2020Y03M16D13H/28M00S60.mp4”,
“2020Y03M16D13H/27M50S10.mp4”
]
}
QoS: 0 - Retain: true

Now, I am able to scp / SSH into the camera and use
“scp root:pass@ip:/file/2020Y03M16D13H/28M00S60.mp4 telegramalert” to locally store my file in the telegramalert directory, but this is done manually.
Also, I can use telegram_bot.send_video service to send the file to myself… But this is also manually.
And then I delete the file, but also by hand.

I have created a template sensor with:

  • platform: mqtt
    name: balkoncamfilm
    state_topic: “camera/balcony/files”
    value_template: '{{ value_json[“files”] }} ’

But this outputs:

[‘2020Y03M16D13H/28M00S60.mp4’, ‘2020Y03M16D13H/27M50S10.mp4’]

My scripting / bash / shell command skills are not advanced enough to know where to go from here. Basically I want HomeAssistant to determine the 2 file names, download those from the camera and send them through telegram. But I don’t know how I should do this automatically.

Edit; and it appears sometimes there is even more motion files, longer duration of the event provides more video files:

[‘2020Y03M16D15H/38M00S60.mp4’, ‘2020Y03M16D15H/37M00S60.mp4’, ‘2020Y03M16D15H/36M00S60.mp4’, ‘2020Y03M16D15H/35M24S36.mp4’]

So I need to somehow break everything up in multiple files, ‘foreach’ loop.

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 96121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>