Error: EventSystem

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
ajseesink
Posts: 9
Joined: Monday 24 December 2018 11:29
Target OS: -
Domoticz version:
Contact:

Error: EventSystem

Post by ajseesink »

HI,

I've searched for several examples for timers and tried to create one of my own. Second I'm not a programmer my self, so apologize in front.
What i try to do?

I have created a dummy switch 'Knob1'. As soon as I manually push this button, the timer should activate with a max of 10 minutes.

However whenever I push the switch to on or off I get the following error: "Error: EventSystem: in /users/domoticz/domoticz/dzVents/runtime/dzVents.lua: /users/domoticz/domoticz/dzVents/runtime/EventHelpers.lua:157: attempt to index a boolean value (local 'def')"

I have no idea what causes this error and how to solve it. Anyone who can help me with a solution? Thanks.

Here is the script I have created.

local switchName = 'Knob1' -- dummy switch
local timerName = 'MyTimer'
local timerDuration = 10 -- in minutes

local function startTimer(domoticz, duration)
local endTime = os.time() + (duration * 60)
domoticz.devices(timerName).switchOn()
domoticz.data.timerEnd = endTime
end

local function stopTimer(domoticz)
domoticz.devices(timerName).switchOff()
domoticz.data.timerEnd = nil
end

return {
on = {
devices = {
switchName
}
},
data = {
timerEnd = false
},
execute = function(domoticz, device)
if (device.state == 'On') then
domoticz.log(switchName .. ' is turned on', domoticz.LOG_INFO)
startTimer(domoticz, timerDuration)
elseif (device.state == 'Off') then
domoticz.log(switchName .. ' is turned off', domoticz.LOG_INFO)
stopTimer(domoticz)
end
end,
onTick = function(domoticz)
if (domoticz.data.timerEnd and os.time() >= domoticz.data.timerEnd) then
stopTimer(domoticz)
end
end
}
Kedi
Posts: 577
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Error: EventSystem

Post by Kedi »

In data.timerEnd you mix 'boolean' and 'Time' and 'nil'
Beter to use a timestring and work from there.
Logic will get you from A to B. Imagination will take you everywhere.
ajseesink
Posts: 9
Joined: Monday 24 December 2018 11:29
Target OS: -
Domoticz version:
Contact:

Re: Error: EventSystem

Post by ajseesink »

Thanks. Lets see what I can make of it. :)
User avatar
boum
Posts: 135
Joined: Friday 18 January 2019 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Error: EventSystem

Post by boum »

smells like AI generated script (this on tick function popping out of thin air, not existing in sources, forum or wiki…).
To get the wanted behavior, you'll need a timer trigger too. Search in the forum, there are a lot of existing script doing nearly the same thing (amazingly).
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest