Hcroij wrote: Thursday 31 October 2019 10:45
As you can see i am not very familiar with the forum,
You can copy / paste text in your post. Select it and press the </> button at the top of the edit window. That will place the text / code in a code window.
dzVents script to Parse P1 Smart Meter Electricity value into separate Meter Readings.
You will have to add two virtual (incremental counter) devices like the ones you already added and replace the xxx in below script with the idx or 'names' of these new devices and copy / paste this script to replace your current script.
That should do it
Code: Select all
-- dzVents script to Parse P1 Smart Meter Electricity value into separate Meter Readings.
local fetchIntervalMins = 5 -- (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.9'
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 = 211 -- Electra, P1 Smart Meter device
local idxu1 = 214 -- Meter Usage low, Virtual device, counter incremental
local idxu2 = 215 -- Meter Usage High, Virtual device, counter incremental
local idxr1 = 216 -- Meter Return Low, Virtual device, counter incremental
local idxr2 = 217 -- Meter Return High, Virtual device, counter incremental
local idxcons = 218 -- Meter Actual Usage, Virtual device, counter incremental
local idxprod = 219 -- Meter Actual Production, Virtual device, counter incremental
local idxuTotal = xxx -- Meter Usage low, Virtual device, counter incremental
local idxrTotal = xxx -- Meter returnlow, 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(idxcons,SMdata.usage)
updateCounter(idxprod,SMdata.usageDelivered)
updateCounter(idxuTotal,( SMdata.usage1 + SMdata.usage2 ))
updateCounter(idxrTotal,( SMdata.return1 + SMdata.return2 ))
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki