Witam, mam problem ze skryptem. Załącza światła prawidłowo, ale niestety nie wyłącza ich. Jak rozdzielę go na dwa osobne skrypty, czyli poniżej Lux i powyżej Lux, wtedy wyłącza.
return {
on = {
timer = { 'at 6:30-7:10',
'at 16:30-23:30' }
},
logging =
{
level = domoticz.LOG_INFO,ERROR,
},
execute = function(dz, device)
local Light = dz.groups('OutsideLight' )
local Lux = dz.devices('Luxmeter')
local LUX = Lux.lux
if (LUX <= 5) then
if (Light.state == 'Off') then
Light.switchOn()
elseif (LUX >= 5) then
if (Light.state == 'On') then
Light.switchOff()
end
end
end
end
}
@pit_h zobacz to
return {
on = {
timer = { 'at 6:30-7:10', 'at 16:30-23:30' }
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to LOG_ERROR when tested and OK
marker = 'Grupa oświetlenie +lux',
},
execute = function(dz,item)
local group = dz.groups('Grupa_lampy')
local Lux = dz.devices('Czujnik lux')
local LUX = Lux.lux
if group.state == 'Off' and LUX <= 5 then
group.switchOn()
elseif group.state == 'On' and LUX > 5 then
group.switchOff()
end
end
}
@isom Dziękuję, jak do tej pory światło się nie załączyło (lux powyżej 5), czyli działa narazie zgodnie z założeniami.
Światła włączyły się prawidłowo, jeszcze raz dziękuję. A czy jest może możliwość wyłączenia świateł na koniec timera, żeby wszystko było w jednym skrypcie? W tej chwili mam drugi skrypt do wyłączania świateł.
@isom Jeszcze jedna sprawa. Czy można dodać do skryptu opcję wyłączania świateł na koniec, czyli o 23:30 i 7:10 (jeśli są włączone), bo teraz mam to w osobnym skrypcie. No i czy prawidłowo będzie wyglądać skrypt nie pod grupę, a pod konkretną lampę:
return {
on = {
timer = { 'at 6:30-7:10', 'at 16:30-23:30' }
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to LOG_ERROR when tested and OK
marker = 'Oświetlenie +lux',
},
execute = function(dz,item)
local Light = dz.devices('Nazwa_Lampy')
local Lux = dz.devices('Czujnik lux')
local LUX = Lux.lux
if Light.state == 'Off' and LUX <= 5 then
Light.switchOn()
elseif Light.state == 'On' and LUX > 5 then
Light.switchOff()
end
end
}
@pit_h skrypt pod lampę jest OK . Jak chcesz dodać sztywną godzinę wyłączenia to trzeba trochę przebudować skrypt . Masz tu przykład gdzie połączyłem lampę , grupę i wyłączenie na sztywno o wyznaczonej godzinie . Wystarczy dołożyć godziny popołudniowo - wieczorne i drugą godzinę wyłączenia
return
{
on =
{ timer = {'between 6:30 and 7:10','at 7:11'},
devices = {'Czujnik Lux'}
},
execute = function(dz, item)
local lampa = dz.devices('Nazwa lampy')
local grupa = dz.groups(' Nazwa Grupy')
local Lux = dz.devices('Czujnik Lux')
local LUX = Lux.lux
if dz.time.matchesRule('between 6:30 and 7:10') and LUX < 5 then
lampa.switchOn().checkFirst()
grupa.switchOn().checkFirst()
end
if dz.time.matchesRule('between 6:30 and 7:10') and LUX > 5 then
lampa.switchOff().checkFirst()
grupa.switchOff().checkFirst()
end
if dz.time.matchesRule('at 7:11') then
lampa.switchOff().checkFirst()
grupa.switchOff().checkFirst()
end
end
}
@isom Dziękuję za pomoc. Czyli skrypt dla jednej lampy i dwóch czasów powinien wyglądać tak:
return
{
on =
{ timer = {'between 6:30 and 7:09','at 7:10','between 16:30 and 23:29','at 23:30'},
devices = {'Luxmeter'}
},
execute = function(dz, item)
local lampa = dz.devices('Elewacja')
-- local grupa = dz.groups(' Nazwa Grupy')
local Lux = dz.devices('Luxmeter')
local LUX = Lux.lux
if dz.time.matchesRule('between 6:30 and 7:09','between 16:30 and 23:29') and LUX < 2 then
lampa.switchOn().checkFirst()
-- grupa.switchOn().checkFirst()
end
if dz.time.matchesRule('between 6:30 and 7:09','between 16:30 and 23:29') and LUX > 2 then
lampa.switchOff().checkFirst()
-- grupa.switchOff().checkFirst()
end
if dz.time.matchesRule('at 7:10','at 23:30') then
lampa.switchOff().checkFirst()
-- grupa.switchOff().checkFirst()
end
end
}
czy tak:
return
{
on =
{ timer = {'between 6:30 and 7:09','at 7:10','between 16:30 and 23:29','at 23:30'},
devices = {'Luxmeter'}
},
execute = function(dz, item)
local lampa = dz.devices('Elewacja')
-- local grupa = dz.groups(' Nazwa Grupy')
local Lux = dz.devices('Luxmeter')
local LUX = Lux.lux
if dz.time.matchesRule('between 6:30 and 7:09') and LUX < 2 then
lampa.switchOn().checkFirst()
-- grupa.switchOn().checkFirst()
end
if dz.time.matchesRule('between 6:30 and 7:09') and LUX > 2 then
lampa.switchOff().checkFirst()
-- grupa.switchOff().checkFirst()
end
if dz.time.matchesRule('at 7:10') then
lampa.switchOff().checkFirst()
-- grupa.switchOff().checkFirst()
end
if dz.time.matchesRule('between 16:30 and 23:29') and LUX < 2 then
lampa.switchOn().checkFirst()
-- grupa.switchOn().checkFirst()
end
if dz.time.matchesRule('between 16:30 and 23:29') and LUX > 2 then
lampa.switchOff().checkFirst()
-- grupa.switchOff().checkFirst()
end
if dz.time.matchesRule('at 23:30') then
lampa.switchOff().checkFirst()
-- grupa.switchOff().checkFirst()
end
end
}
Zdecydowanie wersja 2
Ok. Dzięki wielkie.

