I finished a home security alarm a couple of weeks ago but I think there is still something missing.
I want the system to send me some kind of status report when I use a command in Telegram Messenger.
The status report should say something like:
The system has been active for X hours X minutes, last detection was on X date and the total amount of detections.
I have no idea how i can get started with this,
Anyone a good idea?
If your alarm system has an api available and/or can be talked to via http(s) then you can use node-red to accomplish this quite easily*
*(depending on your technical knowledge)
You can't really do that. If they are formatted, you do get a feel for what's going on if you read a few.
But best to run up Node-RED on your Windows PC. That's what I do for all my development as it is a lot easier than messing with remote servers.
I use Telegram bots extensively. I get Node-RED to send me all sorts of messages automatically and have a couple of groups so that I can have one that is very "chatty" for me to use to monitor what is going on and then another that isn't chatty, just the important things, that the family can use and that has notifications turned on for my phone. I also have commands set up so that I can query things and so that I can control things like lights and temperature.
If Node-RED is inactive because something is wrong - that might be difficult since you are relying on Node-RED to activate the bot.
If you mean that the bot tells you how loaded (how much CPU/RAM/etc is in use) your system is - then absolutely, that is pretty straight-forwards once you've set up a bot since all you need to do is send it the data. I've even set up flows that let me use MQTT to control the input/output to the bot. So I don't need to keep messing with the bot.
Well no system can respond if it is dead! You would need a parallel system in order to do that. Indeed, that is exactly what I do. I have 2 Pi's, each with their own MQTT brokers. They each send heartbeats to each other and both are on a UPS to keep them running - at least for a while - even if the power goes out (obviously the router and switch also have to be on the UPS). That way, I am notified if Node-RED stops working on one of them. I'm also notified if one of them is no longer reachable over the network. I could set it up so that I get informed of other services going down but, to be honest, with a decent SD-Card, power supply and UPS, the Pi's keep running just fine for years on end so not really worth much effort.
With node-red you can ping your alarm system, if no response > telegram message
You can also build a command interface (like /status) that returns a status like armed/disarmed etc: as long as you can interface with your alarm system.
The best solution would be too use another machine that’s off-site. That machine could be in the cloud, etc. and have a heart beat between them. This way you’ll be notified if the system is no longer able to communicate for one reason or another. If you planning another alarm system at another place you could just use that.
Or some other device, yes. If the primary device isn't running, there is nothing to send from any service. You need another service on a different device to be monitoring. Not hard to set up.
If you build a bot with a request status command, when you request the status and you don't get any response, you will know that there is a problem but not where or why unless there is another service somewhere that your primary sends updates to.
Maybe. Unfortunately, most powerbanks can't deliver power while they themselves are receiving power (e.g. plugged into the mains) so that wont work. Also many powerbanks struggle to return to delivering power once they have gone below a certain % charge. Since powerbanks have no data interface, the Pi can't know when power is running out and cannot shut down gracefully.
Really a UPS, while more expensive, is by far the best option. Don't forget that it isn't just the Pi that you need to power if you need external access, it is also your router at the very least. In addition, a UPS should have a data interface that your Pi can use to shut itself down once the batteries are reaching their limit.
"best" may be overstating it a little. It is arguably the best from a resilience point of view but certainly not the best from a security perspective. But yes, that is an option for the secondary. That server needs to also run Node-RED of course in order to be able to make use of that to run a bot.
You also will want to ensure that connections between your Pi and the external server are well secured.
Commercial alarm systems are expensive for a reason. They (should!) take much of this into account for you.
Just in case anyone hasn't seen them, there are now "mini" ups boards that can be fitted to RPi, Arduino and many other devices. They are based on the 18650 battery so that may be problematic for some I guess. But they do work. I have powered a Pi Zero + camera for a few hours off a single 18650 in this configuration.
Thanks for that. Also worth checking out Pete Scargill's blog as he has tried out a number of solutions and has discussed the issues most of them have.
Yes, Pete has done a fair bit of research in this area, although I think things have moved on a bit since he last looked at these devices. Even since I bought some a couple of months ago there appears to be a design incorporating 2 x 18650s now. I assume a balancing circuit is included. The beauty of a single battery was not needing to balance. Anyhow, this has become OT. Hope the NR gods aren't watching.