For sure I'm doing something wrong, but cannot find it
Code: Select all
cat test_nightTime.lua
local SCRIPT_NAME = 'testing_NightTime'
return {
active = true,
on = {
timer = { 'every minute' },
devices = {
['nightTime'] = {'between 22:31 and 07:59'},
},
},
logging =
{
level = domoticz.LOG_INFO, -- change to LOG_ERROR when all OK
marker = SCRIPT_NAME,
},
execute = function(domoticz, nightTime, item, timer)
local time_window = domoticz.devices( 'nightTime' ).state
domoticz.log('system: '..domoticz.time.rawTime)
domoticz.log('Domoticz: '..domoticz.settings.domoticzVersion)
domoticz.log('domoticzvents: '..domoticz.settings.dzVentsVersion)
domoticz.log( ' --------the trigger---------' )
domoticz.log(item.name .. ' seconds ago ' ..item.lastUpdate.raw )
domoticz.log( ' nightTime ' ..time_window )
end
}
Nov 06 17:57:00 pi3 domoticz[17721]: 2022-11-06 17:57:00.417 Status: dzVents: Info: testing_NightTime: ------ Start external script: test_nightTime.lua:, trigger: "every minute"
Nov 06 17:57:00 pi3 domoticz[17721]: 2022-11-06 17:57:00.418 Error: dzVents: Error: (3.1.8) testing_NightTime: There is no device with that name or id: nightTime
Nov 06 17:57:00 pi3 domoticz[17721]: 2022-11-06 17:57:00.419 Error: dzVents: Error: (3.1.8) testing_NightTime: An error occurred when calling event handler test_nightTime
Nov 06 17:57:00 pi3 domoticz[17721]: 2022-11-06 17:57:00.419 Error: dzVents: Error: (3.1.8) testing_NightTime: /var/lib/domoticz/scripts/dzVents/scripts/test_nightTime.lua:19: attempt to index a nil value