Code: Select all
local scriptVar = 'Pioggia'
return
{
on =
{
devices =
{
'Sensore Pioggia',
-- change to name of device to monitor
},
customEvents =
{
scriptVar,
},
},
data =
{
notificationsSend =
{
history = true,
maxHours = 6, -- Only 1 notification every 4 hours change to how many you want
},
logging =
{
level = domoticz.LOG_ERROR, -- change to doomticz.LOG_DEBUG when script works without issues
}
},
execute = function(dz, item)
local Presenza = dz.devices('Presenza')
local Sensore = dz.devices('Sensore Pioggia')
local buonanotte = dz.devices('Buonanotte')
if dz.time.matchesRule('at 09:00-22:00') then
if (Sensore.state == "On" ) and ( dz.data.notificationsSend.sum() < 1 ) and (Presenza.state == "On") and (buonanotte.state == "Off")then
dz.notify("Meteo", 'Fuori sta piovendo', dz.PRIORITY_NORMAL,dz.SOUND_DEFAULT, "" , dz.NSS_TELEGRAM)
dz.executeShellCommand('/home/pi/domoticz/alexa_remote_control.sh -d "Zona Giorno" -e speak:"Attenzione fuori sta piovendo"')
end
end
end
}