The caravan which is powered up to the mains on my drive, recently suffered a spurious electrical spike which tripped the onboard RCD and cut the power off as it should. Problem was that the fridge and freezer began to thaw and yes, you guessed it, it got a bit funky in there. So I now have the power lead connected through a smart socket that has power monitoring capability, which I can observe from the "Smart Life" app. I can check as often as I like to see if the power consumption has dropped to zero indicating some kind of protection device operation. I would love to Tazmotise the smart socket (flash it with custom firmware) but it seems that the manufactures have made it almost impossible on recent models. I have found some pre-loaded Tasmota smart sockets from a well know Chinese supplier but they're gonna take a good long time to arrive.
Has anyone else considered or successfully addressed the monitoring of mains power through some kind of smart device and constructing a Node Red flow to control and monitor it? Not seen anything on these forums tackling this topic before. There may be a better option to what I'm proposing? Just throwing it out there.
Sure you can use NR, but..... From a practical side of things:
You can do most of this outside the software world.
Caravan power point.
Plug in a small phone charger supply. Use this to power a circuit that is active with electricity.
Basically hold a relay operated and so the contacts are open.
If the relay releases, the contacts close.
12v battery close by.
Connect a circuit through the normally open contacts of the relay.
When the contacts close (relay released / power gone) an alarm is sounded.
As a slight spin on that:
Get an ARDUINO and have the contacts looking at the relay's contacts.
If they short, it sends a WIFI signal to your WAP (use MQTT) and Node-Red can receive the signal and.... your choice.
Hope that helps.
(Relay: Optocoupler that detects an LED glowing and is biased off)
There are lots of ways this could be set up without the need for a 12v battery, assuming you can get a Wi-Fi signal into the caravan, you could use an ESP device with a small battery (Wemos have an addon for the D1-mini for example). You could detect when the USB power cut of and send a signal. You only need enough battery to see you through connecting to Wi-Fi and sending a message.
Even easier would be to have an ESP always on and sending a heartbeat MQTT message with a last will and testament message defined so that if the ESP doesn't report in, the LWT message is sent by the broker and you can watch for that in Node-RED.
Another way that doesn't need any new hardware at all would be to regularly network ping the non-controllable smart-switch. When the ping fails, you know that the switch is offline.
@Surefire01 The above is an easy and cheap option - Make sure you have the smart plug inside the caravan so its after the RCD, with fridge plugged into it.
A lot of devices with "smartlife" could be OTA flashed with Tuya-Convert, but this option is mostly closed off now in newer device firmware. You can still do a serial flash if you can get to the internal connections, but this requires taking the device apart and needs special care ! You could goolge for your specific device to see if there are instructions for doing this.
Thanks for the helpful suggestions chaps. I do like the idea of Pinging a smart device within the caravan connected to the mains supply. I have a spare Sonoff TH16 kicking around that could be pressed into service. It has already been flashed with Tasmota so all I need to do now is figure out how to create a Node Red flow that will take the MQTT data from it and inform me with an alarm or notification when the data is no longer being received (i.e. it's powered off). Fortunately I get a fairly good WiFi signal form inside the caravan as it's pretty close to the house.
I've tried setting a Last Will message but I'm not very confident with it and can't recall it being successful.
My MQTT broker used to be Aedes, now I have Mosquitto which certainly supports LWT.
I suppose it's reassuring that I can see Node-Red monitoring devices rather than relying on the broker doing something in the shadows.
I spent the morning updating to the latest Tamota version so this is a good time to have another look at birth, disconnect and lwt messages.
Jbudd, thanks for the pointer about using a trigger node. I simulated a power outage on a spare Sonoff th16 and set up an email node to send a message when when the trigger node doesn’t receive anything for a while. Worked a treat
The 'heartbeat' method is the simplest way to proceed IMO.
Having previously had a trailer stolen, I now have a Wemos board on the (new) trailer which sends a signal to the house every two minutes. A timer node running in NodeRed is set to send an alert message to my phone every /three/ minutes. When a message (a 'heartbeat') arrives from the trailer, it resets the three minute timer.... So while the trailer is plugged into the mains, the heartbeats keep coming, and the alert signal is held off. Should a miscreant unplug the trailer to drive off with it, I'll get an alert within maximum three minutes.
You can use the same approach to the power in the caravan ~ a regular heartbeat message over MQTT, and trigger an event if it doesn't arrive in time.
No battery, no charger required!
Just to close this topic down, I found a solution was to use a trigger node (thanks Jbudd for the pointer) to check the timings and absence of an MQTT payload and respond with and email node if the MQTT data doesn't arrive.
I also incorporated a Telegram node with an account so that I am also notified via a Telegram bot on my mobile devices. As an aside it also works as a theft alarm as any villains would have to disconnect the power should they want to steal the caravan. Great, two birds one stone.