EventHelpers.lua:454: attempt to concatenate a nil value (field 'hardwareName')
Posted: Tuesday 29 July 2025 10:17
Hi everyone,
Recently started using Domoticz (2025.1 on Docker) and I have been working on a plugin.
So far so good, but I ran into a situation and I am wondering what the problem is.
Tried to search the forum/internet, but to no avail.
I created a small proof of concept to highlight the problem:
Take the BaseTemplate.py from examples and add a device in onStart
The above runs with no problem. When I add the hardware, the device shows up and generates no error in the log.
Also no problem when setting a new value using the device via the user interface.
Next step.
Create an internal dzVents (device) script and only change the device name accordingly.
Remove the device via the user interface and update hardware.
Now I get the following error.
Another example, this time with a switch and some code to catch the onCommand when the switch button is pushed.
No problem running this when hardware is updated and the button is pushed.
Again create an internal dzVents (device) script and change the device name accordingly.
Remove the device via the user interface and update hardware.
And voila, the same error.
Current situation in Eventhelpers.lua (line 454)
Which is easily enough patched to surpress the error. But are there any other consequences?
So finally my question: what is causing this error?
Am I doing something wrong, is it a bug in Domoticz?
Thanks for your help.
Recently started using Domoticz (2025.1 on Docker) and I have been working on a plugin.
So far so good, but I ran into a situation and I am wondering what the problem is.
Tried to search the forum/internet, but to no avail.
I created a small proof of concept to highlight the problem:
Take the BaseTemplate.py from examples and add a device in onStart
Code: Select all
def onStart(self):
Domoticz.Log("onStart called")
if Parameters["Mode6"] != "0":
Domoticz.Debugging(int(Parameters["Mode6"]))
DumpConfigToLog()
if (not "Dev1" in Devices):
Domoticz.Unit(Name="Dev1", DeviceID="Dev1", Unit=1, Used=1, TypeName="Set Point", Options={'ValueStep':'1','ValueMin':'1','ValueMax':'100000','ValueUnit':'km'}).Create()
Devices["Dev1"].Units[1].sValue = "4"
Devices["Dev1"].Units[1].Update(Log=True)
Also no problem when setting a new value using the device via the user interface.
Next step.
Create an internal dzVents (device) script and only change the device name accordingly.
Code: Select all
return {
on = {
devices = {
'Dev1'
}
},
logging = {
level = domoticz.LOG_DEBUG,
marker = 'template',
},
execute = function(domoticz, device)
domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
end
}
Now I get the following error.
Code: Select all
2025-07-29 08:55:59.326 Status: Test: Initialized version 1.0.0, author 'gizmocuz'
2025-07-29 08:55:59.327 Test: onStart called
2025-07-29 08:55:59.383 dzVents: Handling events for: "Dev1", value: "nil"
2025-07-29 08:55:59.383 Error: EventSystem: in /opt/domoticz/dzVents/runtime/dzVents.lua: /opt/domoticz/dzVents/runtime/EventHelpers.lua:454: attempt to concatenate a nil value (field 'hardwareName')
Code: Select all
def onStart(self):
Domoticz.Log("onStart called")
if Parameters["Mode6"] != "0":
Domoticz.Debugging(int(Parameters["Mode6"]))
DumpConfigToLog()
if not "Dev2" in Devices:
Domoticz.Unit(Name="Dev2", DeviceID="Dev2", Unit=1, TypeName="On/Off", Used=1).Create()
def onCommand(self, DeviceID, Unit, Command, Level, Color):
if DeviceID == "Dev2" and Command == "On":
Devices["Dev2"].Units[Unit].nValue = 1
Devices["Dev2"].Units[Unit].Update(Log=True)
Domoticz.Log("onCommand called for Device " + str(DeviceID) + " Unit " + str(Unit) + ": Parameter '" + str(Command) + "', Level: " + str(Level))
Again create an internal dzVents (device) script and change the device name accordingly.
Code: Select all
return {
on = {
devices = {
'Dev2'
}
},
logging = {
level = domoticz.LOG_DEBUG,
marker = 'template',
},
execute = function(domoticz, device)
domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
end
}
And voila, the same error.
Code: Select all
2025-07-29 08:51:09.053 Test: onCommand called for Device Dev2 Unit 1: Parameter 'On', Level: 0
2025-07-29 08:51:09.104 Test: onHeartbeat called
2025-07-29 08:51:09.193 dzVents: Handling events for: "Dev2", value: "nil"
2025-07-29 08:51:09.193 Error: EventSystem: in /opt/domoticz/dzVents/runtime/dzVents.lua: /opt/domoticz/dzVents/runtime/EventHelpers.lua:454: attempt to concatenate a nil value (field 'hardwareName')
Code: Select all
if (baseType == domoticz.BASETYPE_DEVICE) then
moduleLabelInfo = ' Device: "' .. subject.name .. ' (' .. subject.hardwareName .. ')", Index: ' .. tostring(subject.id)
Code: Select all
if (baseType == domoticz.BASETYPE_DEVICE) then
moduleLabelInfo = ' Device: "' .. subject.name .. ' (' .. tostring(subject.hardwareName) .. ')", Index: ' .. tostring(subject.id)
Am I doing something wrong, is it a bug in Domoticz?
Thanks for your help.