whats wrong in this script?

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

Moderator: leecollings

Post Reply
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

whats wrong in this script?

Post by edwin1234 »

im a noob at scripting but this is a atempt
to add my total enphase produced energy with solaredge produced energy
but keep getting errors:
2024-04-14 08:14:00.479 Error: dzVents: Error: (3.1.7) Method updateCustomSensor is not available for device "Opbrengst" (deviceType=General, deviceSubType=kWh).

this was my atempt:

return {
on = { timer = { "every 1 minutes" }}, -- Change to your liking to 1,2,3,4,5,6,10,12,15 or 20

execute = function(dz, item)

local Opbrengst = dz.devices(1813)
local Enphase = dz.devices("Enphase Panelen - total").counterToday
local Solaredge = dz.devices("OpbrengstTotaal").counterToday

Opbrengst.updateCustomSensor(dz.utils.round(Enphase + Solaredge,2)) -- Rounded to two decimals

end
}

"Opbrengst"=dummy device
"Enphase Panelen - Total=enphase total energy device
"OpbrengstTotaal= solaredge total energy device

whats wrong?
User avatar
habahabahaba
Posts: 233
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: whats wrong in this script?

Post by habahabahaba »

if it is kWh device you should use updateElectricity(power, energy)

WiKi
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: whats wrong in this script?

Post by edwin1234 »

Thanks for your help
But where and how to place that in the script?
User avatar
habahabahaba
Posts: 233
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: whats wrong in this script?

Post by habahabahaba »

Opbrengst.updateElectricity(power, energy) instead of Opbrengst.updateCustomSensor(value)
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: whats wrong in this script?

Post by edwin1234 »

its still not working now i get this error :
atempt to call a table value
User avatar
habahabahaba
Posts: 233
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: whats wrong in this script?

Post by habahabahaba »

You have to realy know the type/subtype of your sensor (setup -> Devices page) to choose the right method of updating.
2024-04-14_14-21-28.png
2024-04-14_14-21-28.png (26.64 KiB) Viewed 1075 times
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: whats wrong in this script?

Post by edwin1234 »

Opbrengst device is type is general subtype kwh
The value in the device is correct but it needs to be kw instead of watt
Last edited by edwin1234 on Sunday 14 April 2024 17:30, edited 1 time in total.
User avatar
RonkA
Posts: 115
Joined: Tuesday 14 June 2022 12:57
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Harlingen
Contact:

Re: whats wrong in this script?

Post by RonkA »

Is this something for you?

Code: Select all

return {
on = { timer = { "every 1 minutes" }}, -- Change to your liking to 1,2,3,4,5,6,10,12,15 or 20

execute = function(dz, item)

	local Opbrengst = dz.devices(1813) -- should be a dummy type: General - kWh
	local Enphase = dz.devices("Enphase Panelen - total").counterToday
	local Solaredge = dz.devices("OpbrengstTotaal").counterToday

	local OpbrengstValue = Enphase + Solaredge
	local OpbrengstValueRound = tonumber(domoticz.utils.round(OpbrengstValue,2)) -- Rounded to two decimals
	
	domoticz.devices(Opbrengst).updateElectricity(OpbrengstValueRound, OpbrengstValue)

end
}
I cannot remember why but in a script of mine this works for me..
SolarEdge ModbusTCP - Kaku - Synology NAS - Watermeter - ESPEasy - DS18b20
Work in progress = Life in general..
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: whats wrong in this script?

Post by edwin1234 »

Thanks
I will try it
Is in your device the value in kw?

Your script doesnt work
Gives errors
User avatar
RonkA
Posts: 115
Joined: Tuesday 14 June 2022 12:57
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Harlingen
Contact:

Re: whats wrong in this script?

Post by RonkA »

No its a counter to see how much power my Quooker uses in Kw, so i divide the calculated value by 1000 to get the correct value for 'energy'
Hmm.. maybe you have to divide OpbrengstValue by 1.000.000 to get the correct 'kWh' to display..
But you will soon enough if the values are correct on your setup.

-EDIT-
my bad; The device shows watts and kWh; the energy part is in watt (like habahabahaba states)

Code: Select all

	local OpbrengstValue = Enphase + Solaredge / 1000
Last edited by RonkA on Sunday 14 April 2024 19:28, edited 1 time in total.
SolarEdge ModbusTCP - Kaku - Synology NAS - Watermeter - ESPEasy - DS18b20
Work in progress = Life in general..
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: whats wrong in this script?

Post by edwin1234 »

Ok thanks
How do you divide the value of “Opbrengst” by 1000 in the script?
User avatar
habahabahaba
Posts: 233
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: whats wrong in this script?

Post by habahabahaba »

edwin1234 wrote: Sunday 14 April 2024 17:09 Opbrengst device is type is general subtype kwh
The value in the device is correct but it needs to be kw instead of watt
this type of device shows only in Watts
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: whats wrong in this script?

Post by edwin1234 »

Thanks for your help

I did *1000 so now i have 19.500,00watt
In stead of 19,5 watt good enough for me.
User avatar
RonkA
Posts: 115
Joined: Tuesday 14 June 2022 12:57
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Harlingen
Contact:

Re: whats wrong in this script?

Post by RonkA »

set domoticz.utils.round(OpbrengstValue,2) to domoticz.utils.round(OpbrengstValue,0) to loose those extra zero's after comma
SolarEdge ModbusTCP - Kaku - Synology NAS - Watermeter - ESPEasy - DS18b20
Work in progress = Life in general..
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: whats wrong in this script?

Post by edwin1234 »

Thanks for the reply
Good suggestion i change that.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest