I have a rule which sends me a Telegram message when Alarm is detected in my home. Basically it uses the members.filter method to filter switches which are ON.
I have added some cameras to my setup and I want to include them in that rule.
What I want to achieve is to Telegram should send the same message as now (Message with zones in alarm) and after send each camera snapshot picture where zones are on (with caption of the name of the zone).
Cameras are simple Xiaomi cameras, I view it in openHAB by an rtsp URL.
I’m looking for the cleanest solution for this. Easiest would be to make a switch case or if statements and it will send each seperately. However is there a better solution for this?
If statements is the way since it could be any combination of zones turned on. A case/switch would work only if one zone needed to match.
Btw the latest build of the Ipcamera Binding can create a animated gif from your RTSP stream and that would be nicer than a static snapshot.
Another way could be to generate a single gif that contains footage from each of your cameras. It could rotate through all camera views, search the forum for pushover gif and there is a script you could use as a starter that takes inputs from snapshots
I have a similar setup at my home, I use MotionEye as my server to manage my cameras, so you will have to figure out how to get the image from the camera to a place you can send it via telegram. I use the motion detection in MotionEye that sends a get request to turn on a proxy motion switch in OpenHAB. If my “alarm” system is turned on, my rule will send me a telegram image of the motion when detected. I use groups for the cameras and motion sensors. I have a small script that handles copying the image from MotionEye to the “tmp/” directory in OpenHabThis is the code that I have been using for the past 6 months or so:
rule "interior motion detected"
Member of gMotion changed from OFF to ON
var String motion = triggeringItem.name.toString.split("_").get(0)
var CommandM = "/etc/openhab2/scripts/./"+motion+".sh"
sendTelegram("bot1","ALERT - Motion in the "+motion+"!")
logInfo("motion.rules","ALERT - Motion in the "+motion+"!")
Status.postUpdate("ALERT _ Motion detected in the "+motion+"!")}
var String motionD = triggeringItem.name.toString.split("_").get(0)
Status.postUpdate("Motion has been detected in the " +motionD)
logInfo("motion.rules", "Motion detected in the "+motionD)}
The “ypogeio.png” is for the image from the camera in the basement, so you will have to make adjustments for your camera names, I have a separate script for each camera. I will have to check out the IP Camera Binding, I like the idea of getting an animated gif from my camera feeds. I hope this helps!
If you want to send multiple images in one message you need to use the api function sendMediaGroup. I just googled about this, i do not know how to use this. I just read you can group multiple images, i do not know, if you can group a text with multiple images.
Sadly, the sendMediaGroup function is not supported by the openHAB library, so i can’t do a quick test.
You could use the Ipcamera Binding to watch your RTSP stream in HLS format which works great in iOS and can work in chrome if the right add on is installed to the browser. At the moment you will need to set it up as a ONVIF thing type to get your camera working even if it is not an onvif camera.
Thanks, its great to hear it is apricated and others use it as that is why I share to help others get a system working quickly.
The binding now supports MP4 recording much the same way as the GIF and the telegram API allows the sending of mp4. Need some people to raise an issue on GitHub asking for the features to be added if it makes sense to. People are already doing it by calling scripts and such so thanks for posting calls that you have tested to work, always good when people give back.
GIF = great for watching things move faster than realtime as you can specify the playback speed.
MP4 = great for high resolution, but you have to watch in realtime.
Yes If it makes sense to have it added. I don’t use telegram so not sure if it makes sense to add it to the binding or if having the API call advertised in the forum is enough like you have already done.
I may have missed it, but I do not see a way to issue an API call straight through from the Telegram add-on (maybe that is a better solution than continuing to chase the Telegram API as it is changed). Do you have a way you send either the .gif or .mp4 files to an iOS device based upon rules?