I needed a solution for the following scenario: My NAS (QNAP) as well as my OH3-server (Raspberry 4B) are powered by an UPS (uninterruptable power supply, PowerWalker Basic VI 650 SB) to avoid uncontrolled shutdown and data loss when there is a power outage.
The NAS is connected via USB to the UPS and will be shutdown after 30 mins of power outage.
The NAS serves as Master in a NUT environment and will send a “power failure” message via LAN to the openHAB Raspberry.
How te set up the Raspi as “NUT slave” is very well documented in this topic: Guide to Network UPS Tools (NUT) on multiple Raspberry PI’s (Openhab 2.5 and other systems
What to observe to receive the message from the QNAP NAS master is documented here.
Now my challenge: If the power outage exceeds 30 mins, the UPS will send a shutdown command to the NAS (and this to the Raspi) which works well. After power is restored, both should be restarted remotely.
For the NAS, this can be done by connecting to my local network via VPN and sending a WakeOnLAN command - works well.
In another forum I found it mentioned to connect the Raspi to the USB of another device to get it started when this device is powered up. As the 4B needs a 3A USB supply, the USB from the NAS would be overloaded. The other method known is to shorten Pin5 of the GPIO to Ground.
So I constructed a very simple cicuit which is connected to the Gnd/5V wires of an USB connector at the NAS and will shorten Pin 5 of the Raspi to Gnd once the USB Voltage is applied - which happens when the UPS is restarted via WakeOn LAN.
Attached is the schematic - the component values are not very critical, but the transistor should be a medium/high gain type (beta~150+).
Of course this restarting of a Raspi which has been shutdown will work with any remote controlled device having an USB output.