Ok all, time to throw this out there…
I have seen a number of posts about creating an app that could detect when power is out at home, but many relate to turning LED lights down from 100% when the power comes back on. My issue is simpler - to find out when the power has gone off at the ST hub location in the first place.
The scenario is for a user with a ST hub and internet connectivity on battery backup, so the Hub thinks there is still power (and ST does not notify as offline until the UPS dies). Of course we could tackle this by getting a UPS that can send SMS/text or other messages, but that’s no fun when it could be accomplished with ST
The challenge is that I’m in IT, but am no programmer so I’m just throwing this out there while I grab snippets of code from here and there and try to assemble something that works. I would love to see someone tackle this who has more coding experience or who is willing to provide some advice or guidance. Maybe I’m biting off more than I can chew, but hey - I’m game to learn, regardless of the outcome.
Here’s what I have so far as potential requirements that ST code could handle, inspired by several existing apps:
- Monitor an A/C only switch for its “Last Update At” as seen in Device page in the IDE.
- If A/C power is detected as lost, (by creating a calculation comparing current time to the last update), send a notification or SMS message stating House Power has been lost based on no update from that switch in nn minutes. Note: some latency is not an issue. Even up to 30 minutes would be acceptable in my use case, which is simply to preserve food in multiple freezers and return to hook up a manual backup generator.
- Using the above, devices with capability.energyMeter are natural options. Perhaps just capability.Switch would work, too - but i assumed energyMeter would be metering A/C electricity plugged in and wouldn’t ever be battery-powered.
- For example, I could use a Aeotec Smart Switch 6, and using its configuration, set updates to 120 seconds to ensure “Last Update At” sees an update at least every 2 minutes. Then, in this proposed app, send an SMS or ST Notification if there are no updates from the selected switch in a user-selected number of minutes, (like 7-15 minutes - giving some lenience for missed updates but not waiting too long).
The apps that have ‘inspired’ me to think about this are:
@krlaframboise Kevin’s Simple Device Manager reminds me in his app that we can look at the last update time from the device and calculate the difference between now and that last update.
@twack Todd Wackford’s MimoLite Power Is Out uses this same concept to monitor a MimoLite device as a contact sensor and send the notification. I decided to try another capability that might cover a wider range of devices that are more likely to be A/C power (only) than only sensors, which in my case are 100% battery operated.
So now I have a bit of code as examples, have dabbled a bit and realize this is more than I can chew. Any takers, mentors or comments/discussion?