turn ON when power is back again

Moderator: leecollings

Post Reply
User avatar
abdolhamednik
Posts: 39
Joined: Sunday 27 September 2020 7:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Contact:

turn ON when power is back again

Post by abdolhamednik »

hello everyone :)

how to tell a switch to turn on by script, exactly after electricity power came
can u plz help me?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: turn ON when power is back again

Post by waaren »

abdolhamednik wrote: Wednesday 30 September 2020 14:35 how to tell a switch to turn on by script, exactly after electricity power came
dzVents can launge an eventscript triggered by a domoticz start but without additional conditions it would also switch when domoticz was restarted without a power outage. (manual system reboot or domoticz stop/start or -restart)

So you would need to build a checkfile when you intentionally reboot your system, or stop or restart domoticz.
If the checkfile is not present, the logic in dzVents will then recognize that the start was because of an external reason (eg power outage) perform the necessary actions and remove the checkfile
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
abdolhamednik
Posts: 39
Joined: Sunday 27 September 2020 7:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Contact:

Re: turn ON when power is back again

Post by abdolhamednik »

could u plz suggest an easier way?
thanks
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: turn ON when power is back again

Post by waaren »

abdolhamednik wrote:could u plz suggest an easier way?
If I knew an easier way, I would have suggested it already.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
erem
Posts: 230
Joined: Tuesday 27 March 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Amsterdam/netherlands
Contact:

Re: turn ON when power is back again

Post by erem »

this article will get you started.
https://unix.stackexchange.com/question ... -of-reboot

like waaren said, you need to distinguish between intentional power down and power loss
so, use this to write a signal file (touch ~/normalpowerdown) and test for that file on boot..
the absence if the file ~/normalpowerdown tells you if the last power down was abnormal

btw ~ is shorthand for the home dir of the logged on user.
Regards,

Rob
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest