Detect a Power Outage

See above post from this morning. The Rules are there, posted as screenshots.

That's not the case when the driver is polling the smart plug periodically, When unplugged from the mains (or when the power is down) the plug will stop responding to the periodic poll commands, and after a few minutes the driver will change the presence status to 'not present'

Although this may be a fast and simple workaround, I agree that the Ring Range Extender is a much better solution!

1 Like

Correct. But there are no built-in drivers that support presence as described. There are a few community drivers that do it.

Wondering what everyone thinks of this idea (I just implemented this based upon reading this thread so cannot vouch for how well it will work in the long runā€¦and I am relatively new to HE).

I had a spare Sonoff S31 Lite smart plug (WiFi) laying around that I had Tasmotized but was no longer using. Even though it was Tasmotized, being a WiFi plug, I imagine it would work without being modified at any rate.

Using HTTP Presence Sensor, I set up a virtual device using the HTTP Presence Sensor driver and pointed the URL to the local network static (or reserved) IP address of my plug. Whenever the wall socket that the smart plug is plugged into is powered, a ā€œpresentā€ state is reported by HTTP Presence Sensor. If the power goes out (or if the plug is physically unplugged), the state goes to ā€œnot presentā€.

I then set up a RM5.1 rule so that if the presence state changes (the ā€œtriggerā€ set by selecting the presence attribute on the virtual switch), and if the state is ā€œnot presentā€, a notification goes out to my mobile devices that a power outage has occurred. This then starts a cancellable delay (set by a local variable so it can be easily changed to less than how long your UPS can keep your hub and network powered) before another notification to my mobile devices informing me that my hub will be undergoing a ā€œsoftā€ shutdown in 30 secs. After this 30 sec delay, Hub Controller sends a command to soft shutdown the hub to prevent data corruption that might occur with a hard shutdown.

If after the trigger event, the state is ā€œpresentā€, then any delay is cancelled and the rule is exited. I tested this out to see if it would work by simply unplugging my ā€œpresence sensorā€ smart plug and then waiting to see if the hub would shut down after the delay set up in the local variable and it seems to work. It also seems to work to cancel the shutdown if power is restored prior to the shutdown delay period.

The limitation to this (compared to the Ring Extender method) is that I believe the polling interval set by HTTP Presence Sensor is 5 mins? (although I think you can go into the driver code to change this). Another limitation is that since the S31 is a WiFi device, if you lose the WiFi signal, your hub will think that a power outage had occurred (even though it hadnā€™t) and will initiate the countdown for a soft shutdown of your hub.

Anyway, let me know what you think of this and if there is anything that I am missing as far as functionality and other pros and cons of this set up in concerned. IIRC, I paid about $10 for my Sonoff S31 (WiFi version) and since I already had it and was not using it for anything else, I figured i might as well play around with it (and, it still functions as a smart plug where I have it plugged in).

This was my thinking exactly.

Agreed. I mainly threw out the smart plug idea as an alternative since many of us have extra smart plugs already on hand. Quick, easy, and cheap is sometimes a "good enough" solution even if it's not the best.

If your UPS lifetime is sufficiently long, and if the presence sensing is reliable, it should work. Iā€™m not sure presence sensing is 100% reliable.

1 Like

image

Today I discovered this free/bonus service by Ring Security system :slight_smile:

1 Like

@672southmain, have you had problems with HTTP Presence Sensorā€™s reliability to report presence of a plug? IIRC, based on other presence sensing posts, I understand that presence sensing when using a mobile phone as the ā€œsensorā€ can be hit or miss due in some part to limitations in how geofencing is handled by the phone itself (and/or Iā€™m sure some of this may also be due to problems with various other methods and presence sensing apps used in HE as well).

Given this, what has your experience been regarding the reliability (or non-reliability) of HTTP Presence Sensor in monitoring a stationary, always powered device like a smart plug (like the type I am using as a ā€œquick fixā€ alternative to monitoring by Zigbee or Z-wave)?

If you have found this method to be unreliable based on experience, I will have to rethink my approach and go with something like the Ring Extender. I was just concerned that given all the other threads on Z-wave and Zigbee problems, that Zigbee and Z-wave are also not 100% reliable, so I figured why not try with stuff I already had. Looking forward to hearing about your experience. Thanks for any further input.

I use @thebearmay's Hubitat Ping to monitor IP devices. It is hit-or-miss on phones (because of the phone) but it is 100% on fixed devices. So yes you could use the method you describe and actually it seems like a pretty solid approach! Of course there are other things that could make the ping fail besides a commercial power outage... but it seems like as good a method as any. For that matter you could use any mains-powered wifi device. Wouldn't necessarily have to be a device dedicated to that purpose. Or poll a half-dozen of them and use some sort of voting mechanism.

2 Likes

I have not used it on plugs - I do not have any WiFi plugs. I have only used it on phones, and I have not found it to have the needed reliability there, which would made me hesitant to use it to reliably detect power fail.

Thanks @brad5 ,
I was thinking of also polling a constantly powered but ethernet connected device as well. That way, if my polled wifi device showed ā€œnot presentā€, but my ethernet connected device showed ā€œpresentā€, then it would be likely that the problem might be a wifi issue. Whereas if both the wifi and ethernet device reported ā€œnot presentā€, then it would be likely be a power outage problem.

Regarding taking a vote between a number of devices (to prevent false positive reporting of power outage), is there a simple way of doing this in RM, or do I have to set up a ā€œIf-thenā€ logic for each potential permutation/combination of device presence states? That is, how to most efficiently set up a rule for say . . . ā€œif 3 out of 4 devices report not present, then start hub shutdown processā€.

I'd take a look at a couple of the presence combiner apps... Presence Plus by @bptworld has a "voting" function that might be just the ticket. It actually includes a ping function but only one device, so you'd probably have to create a couple of ping presence sensors and then use PP to combine them.

1 Like

See my rules at the end of my post above.

The reason I did it the way I did, which may seem complex at first glance, is because of retriggering as power goes down/up/down/up/down on the different devices, perhaps not all at the same time. The logic of each of the rules is independent and always moving forward, no conditionals, except for the actual power fail rule that intentionally retriggers at the beginning so that the last device does the full run-through, just adding up the power fail semaphores, in a manner that should work with all the concurrency that is happening.

1 Like

Thanks again @brad5 ! Since I am already using HTTP Presence Sensor by @jwetzel1492 I am going to try his Combined Presence to see how it works. Someone in another thread felt that Combined Presence was working rock solid and since HTTP Presence Sensor also seems to be rock solid as well (when used with a plugged in device), this seems to be a much simpler way to go as you suggested. I am thinking that @672southmain ā€˜s feeling that HTTP Presence Sensor was unreliable may have been based on his experience due to phone limitations (as others have suggested as well in other threads). At any rate, thank you to all for your input. I will update on how well (or badly, lol) this approach works. I really appreciate the membership here and how helpful everyone is.

1 Like

I would imagine his would work just fine. I have used his combined presence app and it, too, works great. The only advantage I can see to Presence Plus is it has that voting function built in, but no biggie.

1 Like

Again @brad5 , thank you. I did not realize that Combined Presence did not do voting. I will also check out Presence Plus. Thanks again.

1 Like

Just an update for anyone trying to do the sameā€¦

I ended up trying Presence Plus as well as the HTTP Presence Sensor driver in conjunction with the Combined Presence app. Presence Plus was much more ā€œsophisticatedā€, but hence, much more confusing (at least in this noobā€™s hands, lol). I also noted that when I was using Presence Plus, the operating temp of my Hub was raised to around 102 F compared to the usual operating temp (gotten from Hub Information app) of around 95 - 98 F (I have a fan in the cabinet blowing air over the Hub). This may completely be a coincidence and not due to Presence Plus, but I also noticed that my CPU usage and the DB file seemed to also increase somewhat. It may be due to my lack of knowledge in its proper use as it seems to be well used by others here on the forum and it does appear to have MANY more options which provides a great deal of flexibility in its use.

At any rate, using the HTTP Presence Sensor driver and Combined Presence app was much simpler in this ā€œsimple mindedā€ userā€™s hands and it turns out that it also allows a simplified form of voting as well (you can specify if ANY or ALL sensors need to poll presence whether when detecting arrival or departure.

I set up presence sensors to detect the variety of always on WiFi devices I have in the house so I can tell if, and which Wifi SSIDs are down (e.g. guest vs local Wifi used in home automation). I set up a ā€œwifi device dashboard so I can easily see if and what wifi is down, and a Power Outage dashboard (which is on a USP along with the Hub and my network) so I can be notified when a power outage occurs, along with a countdown timer letting me know when my Hub will be soft powered down. In addition, per the original purpose of this thread, I utilize an always on ethernet device to detect whether a power outage occurs. I tested this out and it seems to work (at least at this time).

I just want to thank everyone who has contributed to this thread (and my knowledge). This community is what originally brought me to using HE and I am grateful to all. Perhaps when I get a little more experience and knowledge, I may be able to contribute more as well.

3 Likes

You can get a sense for what kind of load an app puts on your hub by looking at the App Stats tab on the Logs page and then looking at CPU usage.

1 Like

Hi @brad5 , once again you have helped with great information!

I checked the logs and as I suspected, my Envisalink Integration (which I knew from previous research to be quite chatty) and my Ecobee thermostat integration is at the top of the list, followed by Hubigraph and my power outage monitor which manages the shutdown of my hub. It seems that the polling rate of associated with these integrations/apps/rules take up a fair amount (percentage wise) of the Hubā€™s activities. A little further down the list is the Combined Presence app, I suppose due to the polling rate (which I believe I read is set in the HTTP Presence driver to 1 min, but I could be mistaken).

Luckily, I have not experienced any slowdown of my Hub as I have an automatic reboot performed when Free Memory goes below 300,000 KB which occurred about once every 7 days (prior to me using the Combined Presence app). Is this rate of memory ā€œleakageā€ normal or is it time to get an additional hub to separate out monitoring activities from strictly home automation stuff? Generally, what is a reasonable reboot frequency to ā€œresetā€ the Free Memory and Data Base, or should this even be necessary at all with a stable Hub? I pretty much have most of the things working that I want at this time on one C7, but I suppose that I will be wanting more and more the more I learn of various ways in which HE can be used, lol.
Anyway, thanks for all your insights!

Theoretically you should only have to reboot your hub when thereā€™s an upgrade. I reboot mine once a week just because and that seems to keep things running just fine though there are lots of folks who run for weeks and weeks.

Sounds like you and I are using many of the same apps. Envisalink is a hog for sure but still relatively low when compared to total CPU. At least for me. Lutron and my two Hue integrations are next, with ecobee not too far behind.

I do have a couple of intensive apps that run on a secondary hub. Mostly the apps that ping the crap out of our iPhones. I am not allowed to install geofencing apps because apparently ā€œtrackingā€ your significant other isnā€™t a thing. So I use four different wifi presence apps all running pretty much constantly. It actually works remarkably reliably - as reliably as life360 worked anyway. But it does take a toll on the poor hub. I also have some TV integrations that generate a lot of activity so I have those all on my secondary hub too.

1 Like