Page 1 of 4
Script to parse Electricity from P1 Smart Meter reading
Posted: Tuesday 13 February 2018 14:47
by McMelloW
The P1 Smart Meter with an USB connection cable hardware, creates a device with 6 different meter reading. Usage Low; Usage High; production Low; Production High; Consumption and Production. I wanted to see the readings in 6 different devices.
There is a lua-script that does this trick, but was not really happy with it. So, I decided to wrote a new one in dzVents. In fact, a script in dzVents is much more simple to write then Lua. Six vitual devices type Counter Incremental are created for the different values
The script is very straight forward. The values are fetchted from the P1 Smart Meter device (P1data) and put in a table (SMdata) in a fixed order. Then just update the devices with the accessory values from the table. That's all you have to do.
Code: Select all
--[[ dzVents script to Parse P1 Smart Meter Electricity value into seperated Meter Readings.
]]-- The following need updated for your environment get the 'Idx' or 'Name' of the Device tab.
local fetchIntervalMins = 1 -- (Integer) (Minutes, Range 5-60) How often SE file is fetched
local P1data = 33 -- Electra, P1 Smart Meter device
local idxu1 = 42 -- Meter Usage low, Virtual device, counter incremental
local idxu2 = 43 -- Meter Usage High, Virtual device, counter incremental
local idxr1 = 44 -- Meter Return Low, Virtual device, counter incremental
local idxr2 = 45 -- Meter Return High, Virtual device, counter incremental
local idxcons = 74 -- Meter Actual Usage, Virtual device, counter incremental
local idxprod = 75 -- Meter Actual Production, Virtual device, counter incremental
local ScriptVersion = '0.1.5'
return {
active = true,
logging = {
-- level = domoticz.LOG_DEBUG, -- Uncomment this line to override the dzVents global logging setting
marker = 'SME '.. ScriptVersion
},
on = {
timer = { 'every minute' }
},
execute = function(domoticz, device)
-- Get values from device P1Data of the Smart Meter
local SMdata = domoticz.devices(P1data).rawData
-- Update the device and Debug meassages with the accessory values from table SMdata
domoticz.devices(idxu1).updateCounter(SMdata[1])
domoticz.log('Gebruik laag = '.. SMdata[1], domoticz.LOG_DEBUG)
domoticz.devices(idxu2).updateCounter(SMdata[2])
domoticz.log('Gebruik hoog = '.. SMdata[2], domoticz.LOG_DEBUG)
domoticz.devices(idxr1).updateCounter(SMdata[3])
domoticz.log('Levering laag = '.. SMdata[3], domoticz.LOG_DEBUG)
domoticz.devices(idxr2).updateCounter(SMdata[4])
domoticz.log('Levering hoog = '.. SMdata[4], domoticz.LOG_DEBUG)
domoticz.devices(idxcons).updateCounter(SMdata[5])
domoticz.log('Actuele verbruik = '.. SMdata[5], domoticz.LOG_DEBUG)
domoticz.devices(idxprod).updateCounter(SMdata[6])
domoticz.log('Actuele levering = '.. SMdata[6], domoticz.LOG_DEBUG)
end -- execute
}
Comments and improvements are welcome
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Monday 01 October 2018 19:49
by Gravityz
thanks for this(and unbelievable nobody thanked you for this)
i only use it to see the low and high actual meter values of the meter.
total production is already in the real P1 meter device
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Tuesday 02 October 2018 22:58
by McMelloW
Thanks very much.
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Sunday 16 December 2018 10:41
by rwitkamp
Thanks McMelloW (Dank je wel!) for this script!
I'm migrating from Homeseer to Domoticz and reading P1 data was my first attempt to make things work. Your script helped me out and gave me a good idea of what Domitcz is capable off. I only cannot see why the variable local fetchIntervalMins = 1 is doing in this script. I cannot see it being used only than declare it and set the value to 1.
Regards,
Ron Witkamp
Soest
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Sunday 16 December 2018 12:51
by waaren
rwitkamp wrote: ↑Sunday 16 December 2018 10:41
Thanks McMelloW (Dank je wel!) for this script!
I'm migrating from Homeseer to Domoticz and reading P1 data was my first attempt to make things work. Your script helped me out and gave me a good idea of what Domitcz is capable off. I only cannot see why the variable local
fetchIntervalMins = 1 is doing in this script. I cannot see it being used only than declare it and set the value to 1.
Regards,
Ron Witkamp
Soest
Probably a left over from the original Lua script. For recent dzVents versions the script can be changed to use native dzVents attributes (without the need for using rawData.)
Code: Select all
-- dzVents script to Parse P1 Smart Meter Electricity value into separate Meter Readings.
local fetchIntervalMins = 1 -- (Integer) Minutes frequence of this script execution 1 = every minute, 10 = every 10 minutes, etc ) must be one of (1,2,3,4,5,6,10,12,15,20,30)
local ScriptVersion = '0.1.7'
return {
on = {
timer = { 'every ' .. fetchIntervalMins .. ' minutes' }
},
logging = {
level = domoticz.LOG_DEBUG, -- Uncomment this line to override the dzVents global logging setting
marker = 'SME '.. ScriptVersion
},
execute = function(dz, item)
-- The following need updated for your environment get the 'Idx' or 'Name' of the Device tab.
local P1data = 33 -- Electra, P1 Smart Meter device
local idxu1 = 42 -- Meter Usage low, Virtual device, counter incremental
local idxu2 = 43 -- Meter Usage High, Virtual device, counter incremental
local idxr1 = 44 -- Meter Return Low, Virtual device, counter incremental
local idxr2 = 45 -- Meter Return High, Virtual device, counter incremental
local idxcons = 74 -- Meter Actual Usage, Virtual device, counter incremental
local idxprod = 75 -- Meter Actual Production, Virtual device, counter incremental
-- Get values from device P1Data of the Smart Meter
local SMdata = dz.devices(P1data)
local function updateCounter(idx,value)
dz.devices(idx).updateCounter(value)
dz.log("Set " .. dz.devices(idx).name .. " to: ",dz.LOG_DEBUG)
end
-- Update the device and Debug meassages with the accessory values from table SMdata
updateCounter(idxu1,SMdata.usage1)
updateCounter(idxu2,SMdata.usage2)
updateCounter(idxr1,SMdata.return1)
updateCounter(idxr2,SMdata.return2)
updateCounter(idcons,SMdata.usage)
updateCounter(idprod,SMdata.usageDelivered)
end
}
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Sunday 16 December 2018 17:16
by Gravityz
tried the new script but it is generating an error
Status: dzVents: Error (2.4.8): SME 0.1.7: ...ar/scripts/dzVents/generated_scripts/dzV-P1 meter v2.lua:34: attempt to index local 'idx' (a number value)
when i comment out the dz.log line the error is gone.
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Sunday 16 December 2018 19:16
by waaren
Gravityz wrote: ↑Sunday 16 December 2018 17:16
tried the new script but it is generating an error
Status: dzVents: Error (2.4.8): SME 0.1.7: ...ar/scripts/dzVents/generated_scripts/dzV-P1 meter v2.lua:34: attempt to index local 'idx' (a number value)
when i comment out the dz.log line the error is gone.
Thx, corrected in my previous post
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Thursday 27 December 2018 16:00
by DoMoAD
Thanks (dankjewel) Works great. I've used the RFXMeter counter as a dummydevice. It gives me two numbers. DATA is the actual number on the meter and in the right upper corner i've got a 0 (zero) or the number corresponding with data. It means that i've got two values and in dashticz i need value two.
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Saturday 09 March 2019 11:57
by manjh
I defined dummy devices to receive the four main individual values, updated the idx's in the script, and ran it.
As a result I get this:
Code: Select all
2019-03-09 11:54:00.475 Status: dzVents: Info: SME 0.1.7: ------ Start internal script: P1_conversion_time:, trigger: every 1 minutes
2019-03-09 11:54:00.494 Status: dzVents: Debug: SME 0.1.7: Processing device-adapter for Power: P1 smart meter energy device adapter
2019-03-09 11:54:00.496 Status: dzVents: Debug: SME 0.1.7: Processing device-adapter for P1 afname laag: kWh device adapter
2019-03-09 11:54:00.496 Status: dzVents: Error (2.4.6): SME 0.1.7: Method updateCounter is not available for device "P1 afname laag" (deviceType=General, deviceSubType=kWh). If you believe this is not correct, please report.
2019-03-09 11:54:00.496 Status: dzVents: Debug: SME 0.1.7: Set P1 afname laag to:
2019-03-09 11:54:00.497 Status: dzVents: Debug: SME 0.1.7: Processing device-adapter for P1 afname hoog: kWh device adapter
2019-03-09 11:54:00.497 Status: dzVents: Error (2.4.6): SME 0.1.7: Method updateCounter is not available for device "P1 afname hoog" (deviceType=General, deviceSubType=kWh). If you believe this is not correct, please report.
2019-03-09 11:54:00.497 Status: dzVents: Debug: SME 0.1.7: Set P1 afname hoog to:
2019-03-09 11:54:00.498 Status: dzVents: Debug: SME 0.1.7: Processing device-adapter for P1 levering laag: kWh device adapter
2019-03-09 11:54:00.498 Status: dzVents: Error (2.4.6): SME 0.1.7: Method updateCounter is not available for device "P1 levering laag" (deviceType=General, deviceSubType=kWh). If you believe this is not correct, please report.
2019-03-09 11:54:00.498 Status: dzVents: Debug: SME 0.1.7: Set P1 levering laag to:
2019-03-09 11:54:00.499 Status: dzVents: Debug: SME 0.1.7: Processing device-adapter for P1 levering hoog: kWh device adapter
2019-03-09 11:54:00.499 Status: dzVents: Error (2.4.6): SME 0.1.7: Method updateCounter is not available for device "P1 levering hoog" (deviceType=General, deviceSubType=kWh). If you believe this is not correct, please report.
2019-03-09 11:54:00.499 Status: dzVents: Debug: SME 0.1.7: Set P1 levering hoog to:
2019-03-09 11:54:00.499 Status: dzVents: Info: SME 0.1.7: ------ Finished P1_conversion_time
Probably a user error on my part, but I don't see it... who can help me find what's wrong?
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Saturday 09 March 2019 12:37
by waaren
manjh wrote: ↑Saturday 09 March 2019 11:57
I defined dummy devices to receive the four main individual values, updated the idx's in the script, and ran it.
Probably a user error on my part, but I don't see it... who can help me find what's wrong?
You defined the virtual devices as KwH but as the comment states; they should be defined as counter incremental.
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Sunday 10 March 2019 12:38
by manjh
I decided to take a different route. My objective originally was to be able to take up the meter readings periodically, both in my home and in my vacation house (both have smart meters, and both have Domoticz running on a Raspberry-Pi).
So instead of storing the parsed value into a dummy device, I write them out to a file.
For anyone looking for a similar solution, here's the script that does this.
Remarks: since I use the mounted NAS frequently, I stored the path in a user variable.
A similar script will pick up the reading from the remote meter in the futre (still need to install the cable).
As soon as I have some more time, I will work on a program to read the values in the file. For now I just store the raw data.
Code: Select all
-- dzVents script to get P1 meter values and write them into a file on NAS
local fetchIntervalMins = 30
local ScriptVersion = '0.1.7'
return {
on = {
timer = { 'every ' .. fetchIntervalMins .. ' minutes' }
},
-- logging = {
-- level = domoticz.LOG_DEBUG, -- Uncomment this line to override the dzVents global logging setting
-- marker = 'SME '.. ScriptVersion
-- },
execute = function(dz, item)
-- The following need updated for your environment get the 'Idx' or 'Name' of the Device tab.
local P1_data = 849 -- idx of smart meter device
local Gas_data = 850 -- idx of gas meter
-- prepare header for output record
local Rec_Hdr = "Utrecht "..os.date("%Y.%m.%d %H:%M")
-- Get values from device P1Data of the smart meters:
-- SMdata.usage1
-- SMdata.usage2
-- SMdata.return1
-- SMdata.return2
-- SMdata.usage
-- SMdata.usageDelivered
-- GASdata.counter
-- GASdata.counterToday
local SMdata = dz.devices(P1_data)
local GASdata = dz.devices(Gas_data)
-- build an output record from the SMdata table
out_data = Rec_Hdr.." "..
SMdata.usage1 .." "..
SMdata.usage2.." "..
SMdata.return1.." "..
SMdata.return2.." "..
SMdata.usage.." "..
SMdata.usageDelivered.." "..
GASdata.counter.." "..
GASdata.counterToday
file_name = dz.variables('NAS_Path').value .. "Meterstanden Utrecht.txt"
file = io.open(file_name, "a")
file:write(out_data.."\n")
file:close()
end
}
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Sunday 10 March 2019 12:42
by manjh
waaren wrote: ↑Saturday 09 March 2019 12:37
manjh wrote: ↑Saturday 09 March 2019 11:57
I defined dummy devices to receive the four main individual values, updated the idx's in the script, and ran it.
Probably a user error on my part, but I don't see it... who can help me find what's wrong?
You defined the virtual devices as KwH but as the comment states; they should be defined as counter incremental.
Got it. And (as usual) this helps me understand some things a bit better. I stumbled across your deepdump code, and it helped me understand the structure of the data. It also helped my find the attributes for the gas meter that I needed...
DeepDump is going into my "standard toolbox"...
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Tuesday 12 March 2019 17:53
by HenkSynology
Hi McMelloW,
Thanks for the script. Leuk dat je het wilt delen.
I am a newbie, i have a Synology NAS server and install Domoticz.
That was no problem.
I buy a smart P1 cable and install it, that was no problem.
Its running and see the logging
I copy the script and put it in Event / dzVents, its running.
I see it in the log
Now I not now what i must do??
I try in hardware to make a dummy/Create Virtual Sensors , that no work
Scripts is running i see it in the log.
I see no Device for parse electricity only the device Power and Gas
can evryone help mee
Greeting from Netherlands Henk
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Wednesday 13 March 2019 12:57
by manjh
HenkSynology wrote: ↑Tuesday 12 March 2019 17:53
Hi McMelloW,
Thanks for the script. Leuk dat je het wilt delen.
I am a newbie, i have a Synology NAS server and install Domoticz.
That was no problem.
I buy a smart P1 cable and install it, that was no problem.
Its running and see the logging
I copy the script and put it in Event / dzVents, its running.
I see it in the log
Now I not now what i must do??
I try in hardware to make a dummy/Create Virtual Sensors , that no work
Scripts is running i see it in the log.
I see no Device for parse electricity only the device Power and Gas
can evryone help mee
Greeting from Netherlands Henk
Henk,
can you explain what your ultimate goal is with these readings?
See my post a few back. I was trying the script to store into dummy devices, and made a mistake in defining. Before I realized that, I went back to the drawing board to chack what is was that I wanted.
My goal was not to store the values in a dummy device, I wanted to take meter readings at regular intervals, and store them on my NAS. For that it is not necessary to use dummy devices. So I took the parsing part from McMellow's script, added some code to put the values into a readable record, and write that directly to my NAS. That works just fine for me.
Since you mention you have a NAS attached, is this what you want?
If so, feel free to take my script and adjust it to your needs. You may need to change the idx of power and gas meter, and of course the path to the mounted NAS. Should work!
If you run Domoticz on the NAS itself, the path should not be difficult at all...
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Wednesday 13 March 2019 17:31
by HenkSynology
Hello Hans,
I have 16 solar panels with a SMA 3-phase power flow.
Now when i need power i must pay 0,21 euro/kW, when i put power into the network i get also 0,21 euro/kW
But 2020/2021 change something in the Netherlands
When I need power i must pay 0,21 euro/kW, when i put power into the network i get 0,07 euro/kW
I don't like that
here is a bad rainy day for the solar panels.
you see in the afternoon that I deliver back to the net (the green line)
I want to store the energy I return in a large water tank.
or let my freezer cool extra.
or charge a battery.
I need to extract the smart P1 meter,
I don't understand how to proceed
I made virtuel dummys
2019-03-13 17:30:00.409 Status: dzVents: Info: SME 0.1.5: ------ Start internal script: P1_extract:, trigger: every minute
2019-03-13 17:30:00.461 Status: dzVents: Error (2.4.6): SME 0.1.5: Method updateCounter is not available for device "idxu1" (deviceType=Usage, deviceSubType=Electric). If you believe this is not correct, please report.
what im doing wrong ??
greetings Henk
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Wednesday 13 March 2019 17:33
by HenkSynology
2019-03-13 17:31:21.072 (P1data) P1 Smart Meter (Power)
2019-03-13 17:31:30.841 (P1data) P1 Smart Meter (Power)
2019-03-13 17:31:40.908 (P1data) P1 Smart Meter (Power)
2019-03-13 17:31:51.009 (P1data) P1 Smart Meter (Power)
2019-03-13 17:32:00.425 Status: dzVents: Info: SME 0.1.5: ------ Start internal script: P1_extract:, trigger: every minute
2019-03-13 17:32:00.479 Status: dzVents: Error (2.4.6): SME 0.1.5: Method updateCounter is not available for device "idxu1" (deviceType=Usage, deviceSubType=Electric). If you believe this is not correct, please report.
2019-03-13 17:32:00.481 Status: dzVents: Error (2.4.6): SME 0.1.5: Method updateCounter is not available for device "idxu2" (deviceType=Usage, deviceSubType=Electric). If you believe this is not correct, please report.
2019-03-13 17:32:00.483 Status: dzVents: Error (2.4.6): SME 0.1.5: Method updateCounter is not available for device "idxr1" (deviceType=Usage, deviceSubType=Electric). If you believe this is not correct, please report.
2019-03-13 17:32:00.486 Status: dzVents: Error (2.4.6): SME 0.1.5: Method updateCounter is not available for device "idxr2" (deviceType=Usage, deviceSubType=Electric). If you believe this is not correct, please report.
2019-03-13 17:32:00.489 Status: dzVents: Error (2.4.6): SME 0.1.5: Method updateCounter is not available for device "idxcons" (deviceType=Usage, deviceSubType=Electric). If you believe this is not correct, please report.
2019-03-13 17:32:00.491 Status: dzVents: Error (2.4.6): SME 0.1.5: Method updateCounter is not available for device "idxprod" (deviceType=Usage, deviceSubType=Electric). If you believe this is not correct, please report.
2019-03-13 17:32:00.491 Status: dzVents: Info: SME 0.1.5: ------ Finished P1_extract
2019-03-13 17:32:01.123 (P1data) P1 Smart Meter (Power)
2019-03-13 17:32:11.255 (P1data) P1 Smart Meter (Power)
2019-03-13 17:32:21.395 (P1data) P1 Smart Meter (Power)
2019-03-13 17:32:31.510 (P1data) P1 Smart Meter (Power)
2019-03-13 17:32:41.642 (P1data) P1 Smart Meter (Power)
2019-03-13 17:32:51.764 (P1data) P1 Smart Meter (Power)
2019-03-13 17:33:00.567 Status: dzVents: Info: SME 0.1.5: ------ Start internal script: P1_extract:, trigger: every minute
2019-03-13 17:33:00.620 Status: dzVents: Error (2.4.6): SME 0.1.5: Method updateCounter is not available for device "idxu1" (deviceType=Usage, deviceSubType=Electric). If you believe this is not correct, please report.
2019-03-13 17:33:00.622 Status: dzVents: Error (2.4.6): SME 0.1.5: Method updateCounter is not available for device "idxu2" (deviceType=Usage, deviceSubType=Electric). If you believe this is not correct, please report.
2019-03-13 17:33:00.625 Status: dzVents: Error (2.4.6): SME 0.1.5: Method updateCounter is not available for device "idxr1" (deviceType=Usage, deviceSubType=Electric). If you believe this is not correct, please report.
2019-03-13 17:33:00.627 Status: dzVents: Error (2.4.6): SME 0.1.5: Method updateCounter is not available for device "idxr2" (deviceType=Usage, deviceSubType=Electric). If you believe this is not correct, please report.
2019-03-13 17:33:00.629 Status: dzVents: Error (2.4.6): SME 0.1.5: Method updateCounter is not available for device "idxcons" (deviceType=Usage, deviceSubType=Electric). If you believe this is not correct, please report.
2019-03-13 17:33:00.632 Status: dzVents: Error (2.4.6): SME 0.1.5: Method updateCounter is not available for device "idxprod" (deviceType=Usage, deviceSubType=Electric). If you believe this is not correct, please report.
2019-03-13 17:33:00.633 Status: dzVents: Info: SME 0.1.5: ------ Finished P1_extract
2019-03-13 17:33:01.881 (P1data) P1 Smart Meter (Power)
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Friday 15 March 2019 9:52
by HenkSynology
I have solved the problem
I must have made the dummie "counter incremental" and not dummy "usage"
Evrything works great now
McMelloW thannks for the script, im very happy
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Thursday 13 June 2019 14:52
by competer
I get this error:
2019-06-13 14:50:02.825 Error: EventSystem: Lua script P1 Meter did not return a commandArray
What is going wrong?
Code: Select all
-- dzVents script to Parse P1 Smart Meter Electricity value into separate Meter Readings.
local fetchIntervalMins = 1 -- (Integer) Minutes frequence of this script execution 1 = every minute, 10 = every 10 minutes, etc ) must be one of (1,2,3,4,5,6,10,12,15,20,30)
local ScriptVersion = '0.1.7'
return {
on = {
timer = { 'every ' .. fetchIntervalMins .. ' minutes' }
},
logging = {
-- level = domoticz.LOG_DEBUG, -- Uncomment this line to override the dzVents global logging setting
marker = 'SME '.. ScriptVersion
},
execute = function(dz, item)
-- The following need updated for your environment get the 'Idx' or 'Name' of the Device tab.
local P1data = 11 -- Electra, P1 Smart Meter device
local idxu1 = 101 -- Meter Usage low, Virtual device, counter incremental
local idxu2 = 102 -- Meter Usage High, Virtual device, counter incremental
local idxr1 = 103 -- Meter Return Low, Virtual device, counter incremental
local idxr2 = 104 -- Meter Return High, Virtual device, counter incremental
local idxcons = 105 -- Meter Actual Usage, Virtual device, counter incremental
local idxprod = 106 -- Meter Actual Production, Virtual device, counter incremental
-- Get values from device P1Data of the Smart Meter
local SMdata = dz.devices(P1data)
local function updateCounter(idx,value)
dz.devices(idx).updateCounter(value)
dz.log("Set " .. dz.devices(idx).name .. " to: ",dz.LOG_DEBUG)
end
-- Update the device and Debug meassages with the accessory values from table SMdata
updateCounter(idxu1,SMdata.usage1)
updateCounter(idxu2,SMdata.usage2)
updateCounter(idxr1,SMdata.return1)
updateCounter(idxr2,SMdata.return2)
updateCounter(idcons,SMdata.usage)
updateCounter(idprod,SMdata.usageDelivered)
end
}
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Thursday 13 June 2019 17:52
by waaren
competer wrote: ↑Thursday 13 June 2019 14:52
I get this error: 2019-06-13 14:50:02.825 Error: EventSystem: Lua script P1 Meter did not return a commandArray
You saved the script as Lua but it is a dzVents script.
Re: Script to parse Electricity form P1 Smart Meter reading
Posted: Friday 21 June 2019 9:40
by competer
I migrated my domoticz from Synology to a Rapsberry Pi model 3 B+
This is the code i use:
Code: Select all
-- dzVents script to Parse P1 Smart Meter Electricity value into separate Meter Readings.
local fetchIntervalMins = 1 -- (Integer) Minutes frequence of this script execution 1 = every minute, 10 = every 10 minutes, etc ) must be one of (1,2,3,4,5,6,10,12,15,20,30)
local ScriptVersion = '0.1.7'
return {
on = {
timer = { 'every ' .. fetchIntervalMins .. ' minutes' }
},
logging = {
level = domoticz.LOG_DEBUG, -- Uncomment this line to override the dzVents global logging setting
marker = 'SME '.. ScriptVersion
},
execute = function(dz, item)
-- The following need updated for your environment get the 'Idx' or 'Name' of the Device tab.
local P1data = 93 -- Electra, P1 Smart Meter device
local idxu1 = 43 -- Meter Usage low, Virtual device, counter incremental
local idxu2 = 44 -- Meter Usage High, Virtual device, counter incremental
local idxr1 = 45 -- Meter Return Low, Virtual device, counter incremental
local idxr2 = 46 -- Meter Return High, Virtual device, counter incremental
local idxcons = 47 -- Meter Actual Usage, Virtual device, counter incremental
local idxprod = 48 -- Meter Actual Production, Virtual device, counter incremental
-- Get values from device P1Data of the Smart Meter
local SMdata = dz.devices(P1data)
local function updateCounter(idx,value)
dz.devices(idx).updateCounter(value)
dz.log("Set " .. dz.devices(idx).name .. " to: ",dz.LOG_DEBUG)
end
-- Update the device and Debug meassages with the accessory values from table SMdata
updateCounter(idxu1,SMdata.usage1)
updateCounter(idxu2,SMdata.usage2)
updateCounter(idxr1,SMdata.return1)
updateCounter(idxr2,SMdata.return2)
updateCounter(idcons,SMdata.usage)
updateCounter(idprod,SMdata.usageDelivered)
end
}
Toon divices
I get this error in the log
Code: Select all
2019-06-21 09:31:00.436 Error: dzVents: Error: (2.4.23) SME 0.1.7: There is no device with that name or id: 93
2019-06-21 09:31:00.436 Error: dzVents: Error: (2.4.23) SME 0.1.7: An error occurred when calling event handler P1 Meter
2019-06-21 09:31:00.436 Error: dzVents: Error: (2.4.23) SME 0.1.7: .../domoticz/scripts/dzVents/generated_scripts/P1 Meter.lua:38: attempt to index local 'SMdata' (a nil value)
Whos can help resolving this