Page 1 of 1
Help sensor motion 10 mins ago
Posted: Saturday 21 November 2020 8:58
by Hydci
Hello,
I wrote this automation in Dzvent I would like a helping hand because I think I was wrong I would like the notification of my motion sensor to be sent only when the previous ON state was 10 mins ago
Code: Select all
return {
on = { devices = { ["Capteur BAT"] = {'at 8:00-20:00'} }
},
execute = function(domoticz, item )
if item.state == "On" and domoticz.devices("Capteur BAT").lastUpdate.minutesAgo >10 then
os.execute("curl -u XXXXX:XXXXX -s -o /dev/null 2>&1 'http://XXXXXX:7080/send.html?smsto=XXXXXXXXX&smsbody=Courier+dans+la+bo%C3%AEte+au+lettre&smstype=sms'")
end
end
}
Re: Help sensor motion 10 mins ago
Posted: Saturday 21 November 2020 15:00
by waaren
Hydci wrote: ↑Saturday 21 November 2020 8:58
I wrote this automation in Dzvent I would like a helping hand because I think I was wrong I would like the notification of my motion sensor to be sent only when the previous ON state was 10 mins ago.
I don't know about the curl but the rest of the script seem to be OK.
You could check the logic with
Code: Select all
return
{
on =
{
devices =
{
["Capteur BAT"] = {'at 8:00-20:00'},
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'lastUpdate Capteur BAT',
},
execute = function(dz, item )
if item.state == "On" and item.lastUpdate.secondsAgo > 20 then
dz.log(item.name .. '.lastUpdate.secondsAgo = ' .. item.lastUpdate.secondsAgo .. ' seconds (> 20)',dz.LOG_DEBUG)
elseif item.state == "On" then
dz.log(item.name .. '.lastUpdate.secondsAgo = ' .. item.lastUpdate.secondsAgo .. ' seconds (=< 20)' ,dz.LOG_DEBUG)
else
dz.log('State of ' .. item.name .. ' is ' .. item.state,dz.LOG_DEBUG)
end
end
}
Re: Help sensor motion 10 mins ago
Posted: Wednesday 25 November 2020 15:14
by Hydci
Hello @waaren
I haven't seen your answer before thank you that helped me get it working however I got an error adding a second sensor syntax error I don't think I'm wrong though
Code: Select all
on =
{
devices =
{
["Capteur BAT", "Capteur Porte" ] = {'at 8:00-20:00'},
},
},
Re: Help sensor motion 10 mins ago [Solved]
Posted: Wednesday 25 November 2020 15:57
by waaren
Hydci wrote: ↑Wednesday 25 November 2020 15:14
I haven't seen your answer before thank you that helped me get it working however I got an error adding a second sensor syntax error I don't think I'm wrong though
I would not go as far to say it's wrong. Let's agree it's almost right..
Please try with:
Code: Select all
on =
{
devices =
{
["Capteur BAT"] = {'at 8:00-20:00'},
["Capteur Porte" ] = {'at 8:00-20:00'},
},
},
Re: Help sensor motion 10 mins ago
Posted: Thursday 26 November 2020 23:02
by Hydci
Hello, I confirm the syntax and the correct thanks for the help my script and add-in solved thank you