How to send notification when UPS state change (power outage)
Posted: Sunday 09 April 2017 18:58
Hi,
I have APC UPS and I monitor it state using this thread scripts ( https://www.domoticz.com/forum/viewtopic.php?t=3673 ). It report state every minute, not just if state changes
The purpose is that I could get a message only when the state changes from ON to OFF or OFF to ON. I have tried this script, but problem is that it thinks that state is changing every time when APC UPS report ON or OFF states. Any ideas what should I change to that script?
I have APC UPS and I monitor it state using this thread scripts ( https://www.domoticz.com/forum/viewtopic.php?t=3673 ). It report state every minute, not just if state changes
Code: Select all
2017-04-09 19:27:01 On
2017-04-09 19:26:02 On
2017-04-09 19:25:03 On
2017-04-09 19:24:01 On
Code: Select all
-- Variables
devicename = "UPS state" --Name of the device
tempSensorName = "Living room" --Name of the temperature sensor
tempSensorName2 = "Garden" --Name of the outside temperature sensor
insideTemperature = otherdevices_temperature[tempSensorName] --Temperature is stored to the variable
outsideTemperature = otherdevices_temperature[tempSensorName2]
commandArray = {}
if (devicechanged[devicename]) then
print(devicename.." power supply script running...")
if (devicechanged[devicename] == "Off") then
bodytext = string.format("Power outage detected. Temperature inside of the house is now %.1f°C and outside %.1f°C", insideTemperature, outsideTemperature)
print(bodytext)
commandArray['SendNotification']="Domoticz - Power outage detected#"..bodytext.."#0"
elseif (devicechanged[devicename] == "On") then
bodytext = string.format("Power outage has ended. Temperature inside of the house is now %.1f°C and outside %.1f°C", insideTemperature, outsideTemperature)
print(bodytext)
commandArray['SendNotification']="Domoticz - Power outage has ended#"..bodytext.."#0"
end
end
return commandArray