Page 1 of 1

dzVents WActual Nil issue

Posted: Monday 17 July 2017 11:14
by heggink
All, I must be thick but I cannot get this power usage actual to work. I have a device (Fridge) of type Usage subtype Electric where I am trying to print its value:

return {
active = true,
on = {
devices = {
'Fridge'
}
},
execute = function(domoticz, dev)
pow = dev.WActual
print('Dev power says ' .. pow)
end
}

Domoticz complains about concatenating a string and a nil value (pow). What am I doing wrong here?

Re: dzVents WActual Nil issue

Posted: Monday 17 July 2017 12:01
by mivo
Hi,

try to convert pow value (numeric) to string before print, for example:

Code: Select all

print('Dev power says ' .. tostring(pow))

Re: dzVents WActual Nil issue

Posted: Monday 17 July 2017 12:19
by dannybloe
Yes, you have to convert it to a string otherwise lua will complain. Interesting thing here though is why it is nil. You can turn debug logging on and inspect the log. You can also inspect the file domoticzData.lua that will be created in debug mode in /path/to/domoitcz/scripts/dzVents. Or you can do dev.dump() to dump all device attributes to the log.

Re: dzVents WActual Nil issue

Posted: Monday 17 July 2017 12:40
by heggink
Found it: it should be WhActual with an h after the W. I followed the wiki so is there a typo? WActual: Number. Current Watt usage.

Re: dzVents WActual Nil issue

Posted: Monday 17 July 2017 12:43
by dannybloe
Yup. That's likely a typo.

Re: dzVents WActual Nil issue

Posted: Monday 17 July 2017 13:02
by heggink
Yay for the dump() function. That's how I noticed the correct name.

Re: dzVents WActual Nil issue

Posted: Monday 17 July 2017 13:05
by dannybloe
I fixed the typo in the docs.