Page 1 of 1
Script for IoT air freshener
Posted: Tuesday 08 January 2019 22:13
by QSKONE
Hi , Can you help me? Need script for my IoT air freshener.
https://www.youtube.com/watch?v=gjjP781KOzw
When I try double click - spray it twice action (spray-pause-spray) then everything I make is a loop.
Thanks
Re: Script for IoT air freshener
Posted: Tuesday 08 January 2019 22:17
by waaren
QSKONE wrote: ↑Tuesday 08 January 2019 22:13
Hi , Can you help me? Need script for my IoT air freshener.
https://www.youtube.com/watch?v=gjjP781KOzw
When I try double click - spray it twice action (spray-pause-spray) then everything I make is a loop.
Thanks
What are the device ID's of button and sprayer ?
and what is types and subtype of the activator for the sprayer ?
What should be the pause ?
Re: Script for IoT air freshener
Posted: Tuesday 08 January 2019 22:20
by QSKONE
Spray is switch idx is 90 , button idx is 9 and pause 2 seconds.
Re: Script for IoT air freshener [Solved]
Posted: Tuesday 08 January 2019 22:59
by waaren
QSKONE wrote: ↑Tuesday 08 January 2019 22:20
Spray is switch idx is 90 , button idx is 9 and pause 2 seconds.
Can you test this ? You have to add a uservariable type string with name spray first.
Code: Select all
-- sprayer
local sprayVariable = "spray" -- create this variable with name spray as type string
return {
on = { variables = { sprayVariable },
devices = { 9 }},
logging = { level = domoticz.LOG_DEBUG,
marker = "sprayer" },
execute = function(dz,item)
local sprayer = dz.devices(90)
local sprayTrigger = dz.variables(sprayVariable)
local pause = 2
local function spray(cycles)
if cycles == 2 then
sprayTrigger.set(os.date("%x %X")).afterSec(pause)
end
sprayer.switchOn()
sprayer.switchOff().afterSec(1)
end
if item.isDevice then
local buttonState = item.levelName
if buttonState == "Click" then spray(1)
elseif buttonState == "Double Click" then spray(2) end
else
spray(1)
end
end
}
Re: Script for IoT air freshener
Posted: Tuesday 08 January 2019 23:13
by QSKONE
Thanks you very much warren. Script works like a charm.
https://www.youtube.com/watch?v=V5Ll-xLg5LQ