Re: Light on at different dim level depending on daytime, with auto off
Posted: Thursday 30 January 2020 16:16
Open source Home Automation System
https://forum.domoticz.com/
Change this line to
Code: Select all
if item.state ~= 'On' and override.state ~= 'Off' then
Okay, wil try after work. Thanks Waarenwaaren wrote: ↑Thursday 30 January 2020 23:39Change this line toCode: Select all
if item.state ~= 'On' and override.state ~= 'Off' then
Please show your version and the log it produces. From you description I do not understand what is happening so please elaborate.
Code: Select all
return {
on = {
devices = {234, 236}, -- Change out PIR
},
execute = function(dz, devices)
local Light = dz.devices('Overloop licht') -- Change out light
local ms = dz.devices(234) -- MS Trap 1
local ms2 = dz.devices(236) -- MS Overloop
local luxSensor = dz.devices(192) -- MS6 Lux
local dimTimeTable = { -- [ 'timeSlot' ] = dimValue
['at 00:01-07:00'] = 2,
['at 07:01-12:00'] = 20,
['at 12:01-19:45'] = 60,
['at 22:00-24:00'] = 2,
}
if ((ms.state ~= 'On' and ms2.state ~= 'On' and dz.time.matchesRule('at 22:00-19:45')) or (luxSensor.lux > 20)) then
Light.switchOff()
dz.log(Light.name .. ' switched Off')
else
for timeSlot, dimValue in pairs (dimTimeTable) do
if dz.time.matchesRule(timeSlot) and (luxSensor.lux < 20) then
Light.dimTo(dimValue)
dz.log(Light.name .. ' switched On (dimlevel: ' .. dimValue .. ')')
return false
end
end
end
end
}
Code: Select all
2020-11-05 13:22:44.110 Status: dzVents: Info: Handling events for: "MS trap 1", value: "On"
2020-11-05 13:22:44.111 Status: dzVents: Info: ------ Start internal script: Lamp overloop: Device: "MS trap 1 (deCONZ)", Index: 234
2020-11-05 13:22:44.115 Status: dzVents: Info: Overloop licht switched On (dimlevel: 60)
2020-11-05 13:22:44.116 Status: dzVents: Info: ------ Finished Lamp overloop
2020-11-05 13:22:44.117 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
You could try this but I am not not sure if it solves your issue.nitpicker wrote: ↑Thursday 05 November 2020 13:29 The script switches the Hue lamp on and then it dims to the value I want.
But at night, the value is super small, but the light is first bright and then it dims to the low value. Can the light switch on with the low value without first shining bright?
Code: Select all
return {
on = {
devices = {234, 236}, -- Change out PIR
},
execute = function(dz, devices)
local Light = dz.devices('Overloop licht') -- Change out light
local ms = dz.devices(234) -- Motion Sensor Trap 1
local ms2 = dz.devices(236) -- Motion Sensor Overloop
local luxSensor = dz.devices(192) -- MS6 Lux
local dimTimeTable = { -- [ 'timeSlot' ] = dimValue
['at 00:01-07:00'] = 2,
['at 07:01-12:00'] = 20,
['at 12:01-19:45'] = 60,
['at 22:00-24:00'] = 2,
}
if ((ms.state ~= 'On' and ms2.state ~= 'On' and dz.time.matchesRule('at 22:00-19:45')) or (luxSensor.lux > 20)) then
Light.dimTo(2)
Light.switchOff().afterSec(1)
dz.log(Light.name .. ' switched Off')
else
for timeSlot, dimValue in pairs (dimTimeTable) do
if dz.time.matchesRule(timeSlot) and (luxSensor.lux < 20) then
Light.dimTo(dimValue)
dz.log(Light.name .. ' switched On (dimlevel: ' .. dimValue .. ')')
end
end
end
end
}