Page 1 of 1
add dummy to automatic script
Posted: Thursday 17 September 2020 21:42
by Larsoss
hello guys,
I have a question .. I use the script below to automatically switch the lamps on LUX .. Works perfectly, no problem ..
However, I want to add a dummy sensor that I use. This one is geolocated from my phone .. and turns on / off nicely when I am or not near my house .. however I now want to have it switch on / off + lux when the dummy is on.
so dummy 'Lars phone & Desiree phone' = on and the lux is lower than 'xx' then the group can be on .. actually like the script already works but this addition ..
how / what / where should I put this?
Code: Select all
return {
on = { timer = { "every 3 minutes on mon, tue, wed, thu, fri between 06:50 and 21:00 " } },
execute = function(dz)
lowerLux = 11 -- Onder welke niveau moet het script starten.
upperLux = 45 -- Boven de waarde gaan de lampen automatisch uit.
currentLux = dz.devices(46).lux --lux sensor
woonkamerlampen = dz.groups("Woonkamer") --Dummy switch day/night.
if currentLux < lowerLux then
woonkamerlampen.switchOn().checkFirst()
elseif currentLux > upperLux then
woonkamerlampen.switchOff().checkFirst()
end
end
}
Re: add dummy to automatic script
Posted: Thursday 17 September 2020 22:30
by waaren
Larsoss wrote: Thursday 17 September 2020 21:42
so dummy 'Lars phone & Desiree phone' = on and the lux is lower than 'xx' then the group can be on .. actually like the script already works but this addition ..
how / what / where should I put this?
Can you try this?
Code: Select all
return
{
on =
{
timer =
{
"every 3 minutes on mon, tue, wed, thu, fri between 06:50 and 21:00",
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'lux',
},
execute = function(dz)
local lowerLux = 11 -- Onder welke niveau moet het script starten.
local upperLux = 45 -- Boven de waarde gaan de lampen automatisch uit.
local currentLux = dz.devices(46).lux --lux sensor
local woonkamerlampen = dz.groups("Woonkamer") --Dummy switch day/night.
local phonesOn = dz.devices('Lars phone & Desiree phone').state == 'On'
if ( currentLux < lowerLux ) and phonesOn then
woonkamerlampen.switchOn().checkFirst()
elseif currentLux > upperLux then
woonkamerlampen.switchOff().checkFirst()
end
end
}
Re: add dummy to automatic script
Posted: Friday 18 September 2020 15:43
by Larsoss
waaren wrote: Thursday 17 September 2020 22:30
Larsoss wrote: Thursday 17 September 2020 21:42
so dummy 'Lars phone & Desiree phone' = on and the lux is lower than 'xx' then the group can be on .. actually like the script already works but this addition ..
how / what / where should I put this?
Can you try this?
Code: Select all
return
{
on =
{
timer =
{
"every 3 minutes on mon, tue, wed, thu, fri between 06:50 and 21:00",
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'lux',
},
execute = function(dz)
local lowerLux = 11 -- Onder welke niveau moet het script starten.
local upperLux = 45 -- Boven de waarde gaan de lampen automatisch uit.
local currentLux = dz.devices(46).lux --lux sensor
local woonkamerlampen = dz.groups("Woonkamer") --Dummy switch day/night.
local phonesOn = dz.devices('Lars phone & Desiree phone').state == 'On'
if ( currentLux < lowerLux ) and phonesOn then
woonkamerlampen.switchOn().checkFirst()
elseif currentLux > upperLux then
woonkamerlampen.switchOff().checkFirst()
end
end
}
Yes Waaren, that works .. Only 1 mistake in which I was perhaps not clear ... There are 2 dummies that switch, so 1 phone from Lars and 1 from Desiree ... Now they both have to be on for the script to turn on the lights But the intention is if one of the dummies is on .. Either lars foon or dees foon ....
Sorry I was not clear enough about what I wanted .. I suspect that an if / or should be added very simply?
Re: add dummy to automatic script
Posted: Friday 18 September 2020 15:54
by waaren
Larsoss wrote: Friday 18 September 2020 15:43
There are 2 dummies that switch, so 1 phone from Lars and 1 from Desiree ... Now they both have to be on for the script to turn on the lights But the intention is if one of the dummies is on .. Either lars foon or dees foon ....
This should do it for one or both phones.
Code: Select all
return
{
on =
{
timer =
{
"every 3 minutes on mon, tue, wed, thu, fri between 06:50 and 21:00",
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'lux',
},
execute = function(dz)
local lowerLux = 11 -- Onder welke niveau moet het script starten.
local upperLux = 45 -- Boven de waarde gaan de lampen automatisch uit.
local currentLux = dz.devices(46).lux --lux sensor
local woonkamerlampen = dz.groups("Woonkamer") --Dummy switch day/night.
local phoneLarsOn = dz.devices('Lars phone').state == 'On'
local phoneDesireeOn = dz.devices('Desiree phone').state == 'On'
if ( currentLux < lowerLux ) and ( phoneLarsOn or phoneDesireeOn ) then
woonkamerlampen.switchOn().checkFirst()
elseif currentLux > upperLux then
woonkamerlampen.switchOff().checkFirst()
end
end
}
Re: add dummy to automatic script
Posted: Friday 18 September 2020 15:57
by Larsoss
Thank you..
This is working perfectly.
Re: add dummy to automatic script
Posted: Friday 18 September 2020 20:29
by Larsoss
waaren wrote: Friday 18 September 2020 15:54
Larsoss wrote: Friday 18 September 2020 15:43
There are 2 dummies that switch, so 1 phone from Lars and 1 from Desiree ... Now they both have to be on for the script to turn on the lights But the intention is if one of the dummies is on .. Either lars foon or dees foon ....
This should do it for one or both phones.
Code: Select all
return
{
on =
{
timer =
{
"every 3 minutes on mon, tue, wed, thu, fri between 06:50 and 21:00",
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'lux',
},
execute = function(dz)
local lowerLux = 11 -- Onder welke niveau moet het script starten.
local upperLux = 45 -- Boven de waarde gaan de lampen automatisch uit.
local currentLux = dz.devices(46).lux --lux sensor
local woonkamerlampen = dz.groups("Woonkamer") --Dummy switch day/night.
local phoneLarsOn = dz.devices('Lars phone').state == 'On'
local phoneDesireeOn = dz.devices('Desiree phone').state == 'On'
if ( currentLux < lowerLux ) and ( phoneLarsOn or phoneDesireeOn ) then
woonkamerlampen.switchOn().checkFirst()
elseif currentLux > upperLux then
woonkamerlampen.switchOff().checkFirst()
end
end
}
I tought put it a extra group to it, but thats not at easy as i thougt..
what did i wrong? Because i put and to it..
Code: Select all
return
{
on =
{
timer =
{
"every 3 minutes on mon, tue, wed, thu, fri between 06:50 and 21:00",
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Auto verlichting ON',
},
execute = function(dz)
local lowerLux = 11 -- Onder welke niveau moet het script starten.
local upperLux = 45 -- Boven de waarde gaan de lampen automatisch uit.
local currentLux = dz.devices(46).lux --lux sensor
local woonkamerlampen = dz.groups("Woonkamer") --Groep schakelaar Woonkamer.
local tuin = dz.groups("Tuin") --Groep schakelaar Tuin.
local phoneLarsOn = dz.devices(150).state == 'On' --Dummy Telefoon Lars
local phoneDesireeOn = dz.devices(151).state == 'On' --Dummy Telefoon Dees
if ( currentLux < lowerLux ) and ( phoneLarsOn or phoneDesireeOn ) then
woonkamerlampen.switchOn().checkFirst() and tuin.switchOn().checkFirst()
elseif currentLux > upperLux then
woonkamerlampen.switchOff().checkFirst()
end
end
}
Re: add dummy to automatic script [Solved]
Posted: Friday 18 September 2020 21:26
by waaren
Larsoss wrote: Friday 18 September 2020 20:29
I tought put it a extra group to it, but thats not at easy as i thougt..
what did i wrong? Because i put and to it..
You don't use the and. Just another line with the new command will do.
Code: Select all
return
{
on =
{
timer =
{
"every 3 minutes on mon, tue, wed, thu, fri between 06:50 and 21:00",
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Auto verlichting ON',
},
execute = function(dz)
local lowerLux = 11 -- Onder welke niveau moet het script starten.
local upperLux = 45 -- Boven de waarde gaan de lampen automatisch uit.
local currentLux = dz.devices(46).lux --lux sensor
local woonkamerlampen = dz.groups("Woonkamer") --Groep schakelaar Woonkamer.
local tuin = dz.groups("Tuin") --Groep schakelaar Tuin.
local phoneLarsOn = dz.devices(150).state == 'On' --Dummy Telefoon Lars
local phoneDesireeOn = dz.devices(151).state == 'On' --Dummy Telefoon Dees
if ( currentLux < lowerLux ) and ( phoneLarsOn or phoneDesireeOn ) then
woonkamerlampen.switchOn().checkFirst()
tuin.switchOn().checkFirst()
elseif currentLux > upperLux then
woonkamerlampen.switchOff().checkFirst()
end
end
}