@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: falseThis is followed by:
Message 596 received on camera/balcony/motion at 14:45 :
motion_stop
QoS: 0 - Retain: falseAnd 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: trueNow, 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