Filled the script with comments to see in the log what happens, slightly 0 or 1 is never true.
Code: Select all
2019-08-23 19:53:00.332 Status: dzVents: Info: ------ Start internal script: DZ Kueche RGBW: Device: "Kue PIR Sensor (Aeotech C5)", Index: 1950
2019-08-23 19:53:00.335 Status: dzVents: Bewegung erkannt
2019-08-23 19:53:00.335 Status: dzVents: Abschaltbefehl einleiten
2019-08-23 19:53:00.336 Status: dzVents: Info: ------ Finished DZ Kueche RGBW
2019-08-23 19:53:00.337 Status: EventSystem: Script event triggered: /home/domoticz/domoticz/dzVents/runtime/dzVents.luaCode: Select all
execute = function(domoticz, item)
local LOG_LEVEL = domoticz.LOG_DEBUG -- Script default log level.
local hell = 15 -- lux level for darkness
local motion = item.active
local dark = domoticz.devices('Kue PIR Lux').lux <= hell
local light = domoticz.devices('Kue LED RGB')
local pir = domoticz.devices('Kue PIR Sensor')
local color = domoticz.devices('Kue RGBW Color')
local nachtlicht = domoticz.variables("Nachtlicht").state
local log = domoticz.log
if motion and dark then
print('Bewegung erkannt')
if nachtlicht == "0" then
print('Taglicht einschalten')
light.dimTo(90)
color.setHex(0xF5,0xFF,0xFA)
elseif nachtlicht == "1" then
print('Nachtlicht einschalten')
light.dimTo(50)
color.setHex(0xFF,0xDE,0xAD)
end
print('Abschaltbefehl einleiten')
light.switchOff().afterSec(300)
end
end
}