return {
on = {
devices = {
'IKEA - Sensor Hall',
}
},
execute = function(dz, item)
local function logWrite(str,level)
dz.log(tostring(str),level or dz.LOG_MODULE_EXEC_INFO)
end
local lampgroup = devices(203)
local lamparray = { 172, 180, 182, 186 }
if (time.isDayTime) then
for device in lamparray do
device.dimto(60)
end
else
for device in lamparray do
device.dimto(100)
end
end
}
I need to add if ON and if OFF as well.
Raspberry PI 4 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
return
{
on =
{
devices =
{
'IKEA - Sensor Hall',
},
},
execute = function(dz, item)
local function logWrite(str,level)
dz.log(tostring(str),level or dz.LOG_MODULE_EXEC_INFO)
end
local lampgroup = dz.devices(203)
local lamparray = { 172, 180, 182, 186 }
local dimLevel = 100
if dz.time.isDayTime then
dimLevel = 60
end
for _, idx in ipairs(lamparray) do
dz.devices(idx).dimTo(dimLevel)
end
end
}
return
{
on =
{
devices =
{
'IKEA - Sensor Hall',
},
},
execute = function(dz, item)
local function logWrite(str,level)
dz.log(tostring(str),level or dz.LOG_MODULE_EXEC_INFO)
end
local lampgroup = dz.devices(203)
local lamparray = { 172, 180, 182, 186 }
local dimLevel = 100
if dz.time.isDayTime then
dimLevel = 60
end
for _, idx in ipairs(lamparray) do
dz.devices(idx).dimTto(dimLevel)
end
end
}
Thanks
I added a ON and OFF if statement as well.
No errors so I hope it will work.
return
{
on =
{
devices =
{
'IKEA - Sensor Hall',
},
},
execute = function(dz, device)
local function logWrite(str,level)
dz.log(tostring(str),level or dz.LOG_MODULE_EXEC_INFO)
end
local lampgroup = dz.devices(203)
local lamparray = { 172, 180, 182, 186 }
local dimLevel = 100
if dz.time.isDayTime then
dimLevel = 60
end
if device.state == 'ON' then
for _, idx in ipairs(lamparray) do
dz.devices(idx).dimTo(dimLevel)
end
else
for _, idx in ipairs(lamparray) do
dz.devices(idx).switchOff()
end
end
end
}
Raspberry PI 4 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
Varazir wrote: Thursday 02 July 2020 16:00
No errors so I hope it will work.
Probably not because state 'ON' is not likely to happen. (most devices report either 'On' or 'Off')
because dimTo(0) is an implicit switchOff() you could do
return
{
on =
{
devices =
{
'IKEA - Sensor Hall',
},
},
execute = function(dz, device)
local function logWrite(str,level)
dz.log(tostring(str),level or dz.LOG_MODULE_EXEC_INFO)
end
local lampgroup = dz.devices(203)
local lamparray = { 172, 180, 182, 186 }
local dimLevel = 100
if device.state ~= 'On' then
dimLevel = 0
elseif dz.time.isDayTime then
dimLevel = 60
end
for _, idx in ipairs(lamparray) do
dz.devices(idx).dimTo(dimLevel)
end
end
}
Varazir wrote: Thursday 02 July 2020 16:00
No errors so I hope it will work.
Probably not because state 'ON' is not likely to happen. (most devices report either 'On' or 'Off')
because dimTo(0) is an implicit switchOff() you could do
return
{
on =
{
devices =
{
'IKEA - Sensor Hall',
},
},
execute = function(dz, device)
local function logWrite(str,level)
dz.log(tostring(str),level or dz.LOG_MODULE_EXEC_INFO)
end
local lampgroup = dz.devices(203)
local lamparray = { 172, 180, 182, 186 }
local dimLevel = 100
if device.state ~= 'On' then
dimLevel = 0
elseif dz.time.isDayTime then
dimLevel = 60
end
for _, idx in ipairs(lamparray) do
dz.devices(idx).dimTo(dimLevel)
end
end
}