Script for P1 not working good

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

Moderator: leecollings

Post Reply
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Script for P1 not working good

Post by Fredom »

Dear forum members,
Can anyone help me to solve the below problem
I found the script below on this forum
In this script, the data of P1 is divided into 6 pieces.
I only need the 6th number then.
The 6th number is the feed back I want to use with a dummy.
Unfortunately the script gives an error that I can't get out of.
The error is at the bottom of the script.
I turned off everything except what I want to use.
If this script works, I want to use it fully.

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.8'

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  = 50                                 -- 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 = 103                                -- Meter Actual Usage, Virtual device, counter incremental
        local idxprod = 947                                -- 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(idxcons,SMdata.usage)
        updateCounter(idxprod,SMdata.usageDelivered)
    end 
}

--[[
2022-12-08 22:26:00.261 Error: dzVents: Error: (3.1.8) SME 0.1.8: An error occurred when calling event handler P1 opgedeeld test 3
2022-12-08 22:26:00.261 Error: dzVents: Error: (3.1.8) SME 0.1.8: ...cripts/dzVents/generated_scripts/P1 opgedeeld test 3.lua:33: attempt to call a nil value (field 'updateCounter')
]]--
json of the P1

Code: Select all

{
	"ActTime" : 1670418525,
	"AstrTwilightEnd" : "18:35",
	"AstrTwilightStart" : "06:31",
	"CivTwilightEnd" : "17:11",
	"CivTwilightStart" : "07:55",
	"DayLength" : "07:57",
	"NautTwilightEnd" : "17:55",
	"NautTwilightStart" : "07:11",
	"ServerTime" : "2022-12-07 14:08:45",
	"SunAtSouth" : "12:33",
	"Sunrise" : "08:35",
	"Sunset" : "16:31",
	"app_version" : "2022.2",
	"result" : 
	[
		{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"Counter" : "14162.493",
			"CounterDeliv" : "1122.482",
			"CounterDelivToday" : "0.594 kWh",
			"CounterToday" : "2.094 kWh",
			"CustomImage" : 0,
			"Data" : "6815859;7346634;338996;783486;0;180",
			"Description" : "",
			"Favorite" : 1,
			"HardwareDisabled" : false,
			"HardwareID" : 3,
			"HardwareName" : "Energie meters",
			"HardwareType" : "P1 Smart Meter USB",
			"HardwareTypeVal" : 4,
			"HaveTimeout" : false,
			"ID" : "0001",
			"LastUpdate" : "2022-12-07 14:03:37",
			"Name" : "Elektriciteitmeter",
			"Notifications" : "false",
			"PlanID" : "14",
			"PlanIDs" : 
			[
				14
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"SubType" : "Energy",
			"SwitchTypeVal" : 0,
			"Timers" : "false",
			"Type" : "P1 Smart Meter",
			"TypeImg" : "counter",
			"Unit" : 1,
			"Usage" : "0 Watt",
			"UsageDeliv" : "180 Watt",     (6e number from "Data")
			"Used" : 1,
			"XOffset" : "0",
			"YOffset" : "0",
			"idx" : "50"
		}
	],
	"status" : "OK",
	"title" : "Devices"
}
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Script for P1 not working good

Post by waltervl »

I think you updated the script too much. your local updateCounter function should better not have the same name as the official dzvents upodate Counter function.
if you only need only one value it is easier to simplify your script...

PS You are aware that delivered by the smart meter is not the same as produced by your solar panels..... It is produced minus consumed so delivered to the net. Also there is a report function (button) on the P1 meter that shows exactly the P1 deliverd totals per year, month, day....

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.8'

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  = 50                                 -- Electra, P1 Smart Meter device
        local idxprod = 947                                -- Meter Actual Production, Virtual device, counter incremental
    -- Get values from device P1Data of the Smart Meter
        local SMdata = dz.devices(P1data)
    -- Update the device and Debug meassages with the accessory values from table SMdata
        dz.devices(idxprod).updateCounter(SMdata.usageDelivered)
        dz.log("Set " .. dz.devices(idxprod).name .. " to: " .. tostring(SMdata.usageDelivered),dz.LOG_DEBUG)
   
    end 
}
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Re: Script for P1 not working good

Post by Fredom »

waltervl wrote: Monday 12 December 2022 23:28 I think you updated the script too much. your local updateCounter function should better not have the same name as the official dzvents upodate Counter function.
if you only need only one value it is easier to simplify your script...

PS You are aware that delivered by the smart meter is not the same as produced by your solar panels..... It is produced minus consumed so delivered to the net. Also there is a report function (button) on the P1 meter that shows exactly the P1 deliverd totals per year, month, day....

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.8'

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  = 50                                 -- Electra, P1 Smart Meter device
        local idxprod = 947                                -- Meter Actual Production, Virtual device, counter incremental
    -- Get values from device P1Data of the Smart Meter
        local SMdata = dz.devices(P1data)
    -- Update the device and Debug meassages with the accessory values from table SMdata
        dz.devices(idxprod).updateCounter(SMdata.usageDelivered)
        dz.log("Set " .. dz.devices(idxprod).name .. " to: " .. tostring(SMdata.usageDelivered),dz.LOG_DEBUG)
   
    end 
}
Hello Walter,
Thank you for your quick response.
I'm going to try this out soon.
Your script works perfectly (see foto Teruglevering 947).
Unfortunately this is not the same value as the negative value in Electricity Meter (50) which I expected

The intention is to use this if P1 (50) indicates a negative value (Photo with negative value -180) . And that is the 6th number of Data.

PS You are aware that delivered by the smart meter is not the same as produced by your solar panels.....
It is produced minus consumed so delivered to the net. Also there is a report function (button) on the P1 meter that shows exactly the P1 deliverd totals per year, month, day....

I'm not aware of this. I am using a script that only has 4 switches. And that works perfectly happily.
Because I have had solar panels for a few months now, I also want to do a little more with them if possible.
I want to use this negative value to switch on an electric heater with switch 947 (foto elektra nieuw).

The script i am using now

Code: Select all

--[[ 
     dzVents script dzVents script time
     om P1 Smart Meter Elektriciteitswaarde te ontleden in afzonderlijke Meterstanden.
     Houd er rekening mee dat de teller van vandaag aanvankelijk tot de volgende dag bij de GUI een verkeerde waarde zal weergeven.
     Script gedownload van huizebruin.nl
	 www.huizebruin.nl/domoticz/slimme-meter-(p1)-opsplitsen-naar-4-tellers-domoticz-met-lua/
    29/08/2020-/-v1.10: verbeteringen in totaal verwerkt

   
     Te gebruiken voor domoticz versie >= V4.11305
]] --
local fetchIntervalMins =  1   -- (Geheel) Minutenfrequentie van deze scriptuitvoering 1 = elke minuut, 10 = elke 10 minuten, enz.) Moet een van (1,2,3,4,5,6,10,12,15,20,30) zijn.
local ScriptVersion = '1.10' -- domoticz > V2020.1 / dzVents >= 2.4.28
 
return {

    on =      {
                        timer = { 'every ' .. fetchIntervalMins .. ' minutes' }
              },
             
    logging = {
                         level = domoticz.LOG_DEBUG,    -- Maak commentaar op deze regel om de instelling van dzVents global logging te overschrijven
                         marker = 'Afzonderlijke Meterstanden '.. ScriptVersion
              },

    data = { lastP1 = { initial = {} }},

    execute = function(dz, item)

        -- Voeg apparaatnamen toe tussen aanhalingstekens of apparaat-idx zonder aanhalingstekens
        local P1  = dz.devices(50) -- Electra, P1 Smart Meter device (idx or "name") (required)

--[[ Voer namen / idx in voor apparaten die je wilt onder deze commentaarregels
     Deze apparaten moeten worden gemaakt als nieuwe incrementele tellers. Script kan verkeerde waarden opleveren
     bij gebruik met bestaande die al waarden bevatten
     De resterende regels kunnen worden verwijderd of becommentarieerd 
]]--
        local usageLow   = dz.devices('Verbruik Laag')       -- Metergebruik laag, virtueel apparaat, teller incrementeel
        local usageHigh  = dz.devices('Verbruik Hoog')       -- Metergebruik Hoog, Virtueel apparaat, teller incrementeel
        local returnLow  = dz.devices('Teruglevering Laag')  -- Meter Return Laag, Virtueel apparaat, teller incrementeel
        local returnHigh = dz.devices('Teruglevering Hoog')  -- Meter Return Hoog, Virtueel apparaat, teller incrementeel
        --local usageDeliv = dz.devices('Teruglevering')

        -- Onder deze regel zijn geen wijzigingen vereist ---
               lastP1 = dz.data.lastP1

        local function updateCounter(dv, value, previousValue )
            if not(dv) then return end
            if not(previousValue) then
                dz.log("Geen eerdere gegevens voor " .. dv.name .. " nog; deze run overslaan",dz.LOG_DEBUG)
                return
            end
            if (dv.counter ~=0 or dv.counter ~= nil) then
            value = value - previousValue
            end
            dv.updateCounter(value)
            dz.log("Increment " .. dv.name .. " with: " .. value,dz.LOG_DEBUG)
        end 

        -- Update the device
        updateCounter(usageLow, P1.usage1, lastP1.usage1)
        updateCounter(usageHigh, P1.usage2, lastP1.usage2)
        updateCounter(returnLow, P1.return1, lastP1.return1)
        updateCounter(returnHigh, P1.return2, lastP1.return2)
        --updateCounter(usagedeliv)

        lastP1.usage1  = P1.usage1
        lastP1.usage2  = P1.usage2
        lastP1.return1 = P1.return1
        lastP1.return2 = P1.return2
        --LastP1.usage6  = P1.usage6
     end
}
Attachments
Teruglevering (947)_20221213121425.png
Teruglevering (947)_20221213121425.png (82.46 KiB) Viewed 1243 times
Elektriciteitmeter -180 20221207140722.png
Elektriciteitmeter -180 20221207140722.png (69.01 KiB) Viewed 1243 times
Elektra nieuw.png
Elektra nieuw.png (84.79 KiB) Viewed 1243 times
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Re: Script for P1 not working good

Post by Fredom »

waltervl wrote: Monday 12 December 2022 23:28 I think you updated the script too much. your local updateCounter function should better not have the same name as the official dzvents upodate Counter function.
if you only need only one value it is easier to simplify your script...

PS You are aware that delivered by the smart meter is not the same as produced by your solar panels..... It is produced minus consumed so delivered to the net. Also there is a report function (button) on the P1 meter that shows exactly the P1 deliverd totals per year, month, day....

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.8'

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  = 50                                 -- Electra, P1 Smart Meter device
        local idxprod = 947                                -- Meter Actual Production, Virtual device, counter incremental
    -- Get values from device P1Data of the Smart Meter
        local SMdata = dz.devices(P1data)
    -- Update the device and Debug meassages with the accessory values from table SMdata
        dz.devices(idxprod).updateCounter(SMdata.usageDelivered)
        dz.log("Set " .. dz.devices(idxprod).name .. " to: " .. tostring(SMdata.usageDelivered),dz.LOG_DEBUG)
   
    end 
}
Update

Hi Walter

This was the situation this afternoon with your script.
See photo and json printout.
I want to use the negative number of Electricity (50).
In switch (947) this number should then be the same.

json

Code: Select all

{
	"ActTime" : 1670934813,
	"AstrTwilightEnd" : "18:35",
	"AstrTwilightStart" : "06:36",
	"CivTwilightEnd" : "17:11",
	"CivTwilightStart" : "08:01",
	"DayLength" : "07:49",
	"NautTwilightEnd" : "17:54",
	"NautTwilightStart" : "07:17",
	"ServerTime" : "2022-12-13 13:33:33",
	"SunAtSouth" : "12:36",
	"Sunrise" : "08:41",
	"Sunset" : "16:30",
	"app_version" : "2022.2",
	"result" : 
	[
		{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"Counter" : "14216.451",
			"CounterDeliv" : "1124.771",
			"CounterDelivToday" : "0.441 kWh",
			"CounterToday" : "2.948 kWh",
			"CustomImage" : 0,
			"Data" : "6842593;7373858;339114;785657;0;239",
			"Description" : "",
			"Favorite" : 1,
			"HardwareDisabled" : false,
			"HardwareID" : 3,
			"HardwareName" : "Energie meters",
			"HardwareType" : "P1 Smart Meter USB",
			"HardwareTypeVal" : 4,
			"HaveTimeout" : false,
			"ID" : "0001",
			"LastUpdate" : "2022-12-13 13:25:41",
			"Name" : "Elektriciteitmeter",
			"Notifications" : "false",
			"PlanID" : "14",
			"PlanIDs" : 
			[
				14
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"SubType" : "Energy",
			"SwitchTypeVal" : 0,
			"Timers" : "false",
			"Type" : "P1 Smart Meter",
			"TypeImg" : "counter",
			"Unit" : 1,
			"Usage" : "0 Watt",
			"UsageDeliv" : "239 Watt",
			"Used" : 1,
			"XOffset" : "0",
			"YOffset" : "0",
			"idx" : "50"
		}
	],
	"status" : "OK",
	"title" : "Devices"
}
Attachments
Zie json.png
Zie json.png (79.4 KiB) Viewed 1227 times
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Script for P1 not working good

Post by waltervl »

I do not think it is possible to send negative values to an Energy counter. There is currently a discussion on this on the forum.
The negative value you see on the widget electriciteitsmeter is only a display value.

What do you want to do with this new counter? Because when you click on the Log button and then on the Report button you will see all kind of nice information already prepared for you. See wiki for a screenshot of a report. https://www.domoticz.com/wiki/Dutch_DSM ... th_P1_port
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Script for P1 not working good

Post by waltervl »

See screenshot below for a report of a month in the past.
It is fake information but you can see what is reported.
Screenshot_20221213-172600.png
Screenshot_20221213-172600.png (183.71 KiB) Viewed 1220 times
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Re: Script for P1 not working good

Post by Fredom »

waltervl wrote: Tuesday 13 December 2022 17:28 See screenshot below for a report of a month in the past.
It is fake information but you can see what is reported.Screenshot_20221213-172600.png
Hi walter,
I already understood that you can't do anything with negative values ​​in this case.
I had already read this on this forum.
But in the json printout Data 6th number that is the number that is displayed on the P1 in negative.
But in the json printout this is positive and I thought something could be done with that. This 6th number stops at 0 when the value in P1 becomes positive.
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Script for P1 not working good

Post by waltervl »

Yes, it is a value given by the smart meter as such.
There are values for usage (positive) and return (positive). In the device widget the retrurn is shown as negative (just show a minus sign before it). Else they had to add the label 'return:' before it. A minus sign is smaller and understandable.

If you want to have a negative value to calculate with you can multiply it with -1.

Still the question: Why? Perhaops there are other ways to implement what you want. If we do not know what you want, in the end it is difficult to help.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Re: Script for P1 not working good

Post by Fredom »

waltervl wrote: Tuesday 13 December 2022 18:57 Yes, it is a value given by the smart meter as such.
There are values for usage (positive) and return (positive). In the device widget the retrurn is shown as negative (just show a minus sign before it). Else they had to add the label 'return:' before it. A minus sign is smaller and understandable.

If you want to have a negative value to calculate with you can multiply it with -1.

Still the question: Why? Perhaops there are other ways to implement what you want. If we do not know what you want, in the end it is difficult to help.
Hi walter,
I understand your question as my goal is to use the actual return to the net to allow an electric heater to use it.
So what was already discussed here on the forum. I had the silent hope that this way via json data would work
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Script for P1 not working good

Post by waltervl »

Ok, then run a script that if SMdata.usageDelivered is bigger than x value, switch on the electric heater. If smaller than x then switch off. X can be any value you want, even 0, but you want that bigger then the usage of the heater.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Re: Script for P1 not working good

Post by Fredom »

waltervl wrote: Tuesday 13 December 2022 20:15 Ok, then run a script that if SMdata.usageDelivered is bigger than x value, switch on the electric heater. If smaller than x then switch off. X can be any value you want, even 0, but you want that bigger then the usage of the heater.
Hi walter,
I already have the script for this working.
The problem that arises now is that SMdata.usageDelivered indicates a much larger number than what is indicated on the Electricity meter, see the photo in the previous post.
I will now have to try to get close to that negative number, otherwise I don't think it makes much sense anymore. If that doesn't work, I have to look for another solution, but then it will be a hardware solution that I prefer not to do.
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Script for P1 not working good

Post by waltervl »

You have to look at all 3 phases. To decide what kind of Delivered value you have. Do you have a single phase or 3 phase solar inverter?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Re: Script for P1 not working good

Post by Fredom »

waltervl wrote: Tuesday 13 December 2022 21:44 You have to look at all 3 phases. To decide what kind of Delivered value you have. Do you have a single phase or 3 phase solar inverter?
10 Bauer Glas-Glas 385WP - GERMAN BRAND -30 jaar product garantie
10 Enphase Micro-omvormer IQ7 plus - 25 jaar product garantie
10 Enphase IQ-kabel landscape driefase | 1.7 m tussenafstand
1 Enphase IQ-relay driefase inclusief fasekoppelaar
1 Q-Term (3 fase)
1 Solarconstruct montagesysteem
1 DC en AC bekabeling
1 Online Monitoring
1 Enphase Envoy-S Metered Multiphase (voorbereid op Enphase accu systeem)
Complete installatie en in bedrijfstellen
1 Aparte aardlekautomaat bijplaatsen
1 Werkschakelaar/ PV verdeler
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Script for P1 not working good

Post by waltervl »

So you have a 3 phase inverter.
In the screenshot I see -239 Watt delivery, Delivery on L1=0,L2=148,L3=179
So on L1 there should be usage of approx 148+179-239=88 Watt. That should be visible on the L1/3 Usage devices.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Re: Script for P1 not working good

Post by Fredom »

waltervl wrote: Tuesday 13 December 2022 22:30 So you have a 3 phase inverter.
In the screenshot I see -239 Watt delivery, Delivery on L1=0,L2=148,L3=179
So on L1 there should be usage of approx 148+179-239=88 Watt. That should be visible on the L1/3 Usage devices.
Okay and that should be the actual feed back to the net.
I'll take a look tomorrow when the sun comes out
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Re: Script for P1 not working good

Post by Fredom »

waltervl wrote: Tuesday 13 December 2022 22:30 So you have a 3 phase inverter.
In the screenshot I see -239 Watt delivery, Delivery on L1=0,L2=148,L3=179
So on L1 there should be usage of approx 148+179-239=88 Watt. That should be visible on the L1/3 Usage devices.
Hi Walter,

If I understood you correctly, then according to this afternoon's photo I would have a return to the net of 103 watts.
What I find very strange is that the electricity meter says -47 watts and that is also reflected in json, but on switch 947 you see a feed-in of 5,119 kWh, there should also be 47 watts.

json
{
"ActTime" : 1671014535,
"AstrTwilightEnd" : "18:36",
"AstrTwilightStart" : "06:37",
"CivTwilightEnd" : "17:11",
"CivTwilightStart" : "08:01",
"DayLength" : "07:49",
"NautTwilightEnd" : "17:55",
"NautTwilightStart" : "07:18",
"ServerTime" : "2022-12-14 11:42:15",
"SunAtSouth" : "12:36",
"Sunrise" : "08:42",
"Sunset" : "16:31",
"app_version" : "2022.2",
"result" :
[
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"Counter" : "14222.660",
"CounterDeliv" : "1125.021",
"CounterDelivToday" : "0.091 kWh",
"CounterToday" : "2.235 kWh",
"CustomImage" : 0,
"Data" : "6844412;7378248;339114;785907;0;47",
"Description" : "",
"Favorite" : 1,
"HardwareDisabled" : false,
"HardwareID" : 3,
"HardwareName" : "Energie meters",
"HardwareType" : "P1 Smart Meter USB",
"HardwareTypeVal" : 4,
"HaveTimeout" : false,
"ID" : "0001",
"LastUpdate" : "2022-12-14 11:34:27",
"Name" : "Elektriciteitmeter",
"Notifications" : "false",
"PlanID" : "14",
"PlanIDs" :
[
14
],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"SubType" : "Energy",
"SwitchTypeVal" : 0,
"Timers" : "false",
"Type" : "P1 Smart Meter",
"TypeImg" : "counter",
"Unit" : 1,
"Usage" : "0 Watt",
"UsageDeliv" : "47 Watt",
"Used" : 1,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "50"
}
],
"status" : "OK",
"title" : "Devices"
}
Attachments
DeepinSchermafdruk_Gebied selecteren_20221214114119.png
DeepinSchermafdruk_Gebied selecteren_20221214114119.png (81.22 KiB) Viewed 1135 times
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Script for P1 not working good

Post by waltervl »

If you go to your complete device list in Domoticz, menu setup devices, you should see 2 sets of L1-3 devices, Usage and delivery. The sum of all these 6 devices will give to nett feed back or usage to the net and should be the same as the value in the P1 meter device. The JSON is just a domoticz summary calculation of the smart meter telegram and should not differ from what you see on the device widget.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Re: Script for P1 not working good

Post by Fredom »

waltervl wrote: Thursday 15 December 2022 0:15 If you go to your complete device list in Domoticz, menu setup devices, you should see 2 sets of L1-3 devices, Usage and delivery. The sum of all these 6 devices will give to nett feed back or usage to the net and should be the same as the value in the P1 meter device. The JSON is just a domoticz summary calculation of the smart meter telegram and should not differ from what you see on the device widget.
Hi walter,
I found it all. I'll get on with this. Thank you for your help and explanation.
I also learned something new.
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest