Hi,
I’ve got a little recommendation for all of you how use a
Single-Board-Computer (SBC) like the Raspberry PI as (openhab) server.
The power supply itself is a beefy USB power supply from aliexpress (non-affiliate) for approx. 15 €.
Included in the supply is the ability to drop a 18650 LiPo battery in to provide power in case of power failure!
DIY part:
Now for the server to know when the outage occured in order to take aktion (notify, power down after a set time…) the USB connection may be used. I tapped into the supply and added one wire (yellow) from one LED to the data lines of the USB connection. This line carries +3.3V (slightly more, safe for RPI).
!
On the Pi-Side, add a wire between the data lines of the micro USB (tricky to solder, be sure to not short anything) and f.e. GPIO4.
In openhab, I’ve added a item with the GPIO binding:
Contact Mains "Mains" <mains> { gpio="pin:4 activelow:no" }
And this rule:
rule "Mains"
when
Item Mains changed
then
if (Mains.state == ON)
sendLogNotification("Mains active")
else
sendNotification("..@...", "BATTERY BACKUP ACTIVE")
end
Best,
Sascha