No Ampere graph with P1 Smart Meter (connected to Soconia T211 3 phase - Belgium)

Moderator: leecollings

Post Reply
giton
Posts: 14
Joined: Tuesday 23 June 2020 22:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

No Ampere graph with P1 Smart Meter (connected to Soconia T211 3 phase - Belgium)

Post by giton »

I’m running Domoticz V2020.2 (c)2012-2020 GizMoCuz Build Hash: b63341bc0, Date: 2020-04-26 13:47:55

P1 Smart Meter USB generates KWh graphs but no Ampere graphs.
Data are effectivelly sent from my Soconia T211 (3 phase) to my PI:
# cat /dev/ttyUSB0
/FLU5\253769484_A

0-0:96.1.4(50213)
0-0:96.1.1(3153414733313030303733363338)
0-0:1.0.0(200807223430S)
1-0:1.8.1(000008.815*kWh)
1-0:1.8.2(000016.367*kWh)
1-0:2.8.1(000114.368*kWh)
1-0:2.8.2(000000.177*kWh)
0-0:96.14.0(0002)
1-0:1.7.0(00.433*kW)
1-0:2.7.0(00.000*kW)
1-0:32.7.0(229.5*V)
1-0:52.7.0(231.0*V)
1-0:72.7.0(228.6*V)
1-0:31.7.0(000*A)
1-0:51.7.0(001*A)
1-0:71.7.0(000*A)
0-0:96.3.10(1)
0-0:17.0.0(999.9*kW)
1-0:31.4.0(999*A)
0-0:96.13.0()
!5AEF

USB port is defined like this:
# stty -F /dev/ttyUSB0
speed 115200 baud; line = 0;
min = 1; time = 0;
-brkint -icrnl -imaxbel
-opost
-isig -icanon -iexten -echo

In Domoticz I only see those repeated logs:

2020-08-07 22:38:51.069 (Compteur electrique) P1 Smart Meter (Power)
2020-08-07 22:38:51.073 (Compteur electrique) General/Voltage (Voltage L1)
2020-08-07 22:38:51.076 (Compteur electrique) General/Voltage (Voltage L2)
2020-08-07 22:38:51.079 (Compteur electrique) General/Voltage (Voltage L3)
...

No Ampere data seem to be integrated within Domoticz DB.

Any help would be appreciated.

I need those graphs to avoid to extract data to XLS and do some calculation to get instantaneous Ampere value.

Sum of Ampere for each phase would also interest me if available.

Just seen too: I also do not see 3 phases but only 2 (see attachment)
Attachments
Domoticz - graph - T211.png
Domoticz - graph - T211.png (232.45 KiB) Viewed 1693 times
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: No Ampere graph with P1 Smart Meter (connected to Soconia T211 3 phase - Belgium)

Post by waaren »

giton wrote: Friday 07 August 2020 22:58 P1 Smart Meter USB generates KWh graphs but no Ampere graphs.
No Ampere data seem to be integrated within Domoticz DB.
Is indeed not integrated. As amperage is a function of Watt and Voltage it would be quite easy to create virtual sensors and use a script to calculate an approximate amperage ( Watt / 230 ) and populate the sensors with the result.
See below for an example using dzVents
Sum of Ampere for each phase would also interest me if available.
Assume you mean the total of the combined phases?
Just seen too: I also do not see 3 phases but only 2 (see attachment)
What you see here are not the phases but the total of the phases split in high tariff / low tariff.

When not yet familiar with dzVents please start with reading Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."

Code: Select all

return  
{
    on = 
    { 
        devices = {'Usage L1'}, -- set device trigger 
    }, 

    logging = 
    {   
        level = domoticz.LOG_DEBUG,
        marker = 'Amperage', 
    },

    execute = function(dz)
       
        -- Change below between the quotes to names reflecting the devicenames in your system

        local l1Usage = dz.devices('Usage L1').actualWatt
        local l2Usage = dz.devices('Usage L2').actualWatt
        local l3Usage = dz.devices('Usage L3').actualWatt
       
        local l1Amperage = dz.devices('Amperage L1') -- define as virtual sensor (ampere 1 phase)    
        local l2Amperage = dz.devices('Amperage L2') -- define as virtual sensor (ampere 1 phase) 
        local l3Amperage = dz.devices('Amperage L3') -- define as virtual sensor (ampere 1 phase) 
        local totalAmperage = dz.devices('Amperage L1-L3') -- define as virtual sensor (ampere 3 phase)

        -- No changes required below this line

        local voltage = 230

        local l1Current = dz.utils.round(l1Usage / voltage, 1)
        local l2Current = dz.utils.round(l2Usage / voltage, 1)
        local l3Current = dz.utils.round(l3Usage / voltage, 1)

        l1Amperage.updateCurrent(l1Current)
        l2Amperage.updateCurrent(l2Current)
        l3Amperage.updateCurrent(l3Current)
        totalAmperage.updateCurrent(l1Current, l2Current, l3Current)

    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
FireWizard
Posts: 1863
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: No Ampere graph with P1 Smart Meter (connected to Soconia T211 3 phase - Belgium)

Post by FireWizard »

Hi,

You wrote:
Just seen too: I also do not see 3 phases but only 2 (see attachment)
See: https://www.domoticz.com/forum/viewtopi ... rt#p213901
No Ampere data seem to be integrated within Domoticz DB.
Ampere values in the P1 Smart meter are rounded to A (and not mA) and are therefore not accurate enough to be considered as reliable values.
Therefore they are not included in Domoticz.

If you want them you can calculate these, but I wonder if you are able to do so.

In your protocol, you are missing some necessary values, the Consumed or Delivered Power for each phase.
1-0:21.7.0(00.094*kW)
1-0:41.7.0(00.040*kW)
1-0:61.7.0(00.000*kW)
1-0:22.7.0(00.000*kW)
1-0:42.7.0(00.000*kW)
1-0:62.7.0(00.000*kW)
In order to calculate you need to divide the Power for each phase by the Voltage for each phase.

The Belgium specifications differ from the Dutch specifications.
See Annex A in: https://onedrive.live.com/view.aspx?res ... pDlhjeOr7A

Regards
giton
Posts: 14
Joined: Tuesday 23 June 2020 22:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: No Ampere graph with P1 Smart Meter (connected to Soconia T211 3 phase - Belgium)

Post by giton »

waaren wrote: Saturday 08 August 2020 11:56
giton wrote: Friday 07 August 2020 22:58 P1 Smart Meter USB generates KWh graphs but no Ampere graphs.
No Ampere data seem to be integrated within Domoticz DB.
Is indeed not integrated. As amperage is a function of Watt and Voltage it would be quite easy to create virtual sensors and use a script to calculate an approximate amperage ( Watt / 230 ) and populate the sensors with the result.
See below for an example using dzVents
Sum of Ampere for each phase would also interest me if available.
Assume you mean the total of the combined phases?
Just seen too: I also do not see 3 phases but only 2 (see attachment)
What you see here are not the phases but the total of the phases split in high tariff / low tariff.

When not yet familiar with dzVents please start with reading Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."

Code: Select all

return  
{
    on = 
    { 
        devices = {'Usage L1'}, -- set device trigger 
    }, 

    logging = 
    {   
        level = domoticz.LOG_DEBUG,
        marker = 'Amperage', 
    },

    execute = function(dz)
       
        -- Change below between the quotes to names reflecting the devicenames in your system

        local l1Usage = dz.devices('Usage L1').actualWatt
        local l2Usage = dz.devices('Usage L2').actualWatt
        local l3Usage = dz.devices('Usage L3').actualWatt
       
        local l1Amperage = dz.devices('Amperage L1') -- define as virtual sensor (ampere 1 phase)    
        local l2Amperage = dz.devices('Amperage L2') -- define as virtual sensor (ampere 1 phase) 
        local l3Amperage = dz.devices('Amperage L3') -- define as virtual sensor (ampere 1 phase) 
        local totalAmperage = dz.devices('Amperage L1-L3') -- define as virtual sensor (ampere 3 phase)

        -- No changes required below this line

        local voltage = 230

        local l1Current = dz.utils.round(l1Usage / voltage, 1)
        local l2Current = dz.utils.round(l2Usage / voltage, 1)
        local l3Current = dz.utils.round(l3Usage / voltage, 1)

        l1Amperage.updateCurrent(l1Current)
        l2Amperage.updateCurrent(l2Current)
        l3Amperage.updateCurrent(l3Current)
        totalAmperage.updateCurrent(l1Current, l2Current, l3Current)

    end
}

'Usage L1' cannot be used in the script as not a device; see screenshot for the list of all devices linked to that HW:

Here the message I receive:
2020-08-08 17:37:12.010 Error: dzVents: Error: (3.0.2) Amperage: There is no device with that name or id: Usage L1
2020-08-08 17:37:12.010 Error: dzVents: Error: (3.0.2) Amperage: An error occurred when calling event handler Ampere
2020-08-08 17:37:12.010 Error: dzVents: Error: (3.0.2) Amperage: /home/pi/domoticz/scripts/dzVents/scripts/Ampere.lua:28: attempt to index a nil value
Attachments
Domoticz - devices.png
Domoticz - devices.png (82.27 KiB) Viewed 1662 times
User avatar
FireWizard
Posts: 1863
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: No Ampere graph with P1 Smart Meter (connected to Soconia T211 3 phase - Belgium)

Post by FireWizard »

Hi

@giton,

As already said in my post above, the necessary values for Watt are not included in the protocol of the Smart meter and so the essential devices are not created.
Your Smart meter uses the absulute bare minimum of information. See the provided link.

You will only have device 25, 26, 27 and 28.
The other devices are created by @waarens dzVents script, but cannot be controlled as the necessary data is missing

So you don't have Usage L1, Usage L2 or Usage L3.
The only way, you possible can get this data, is by installing your own device, e.g https://m.banggood.com/buy/3-phase-powe ... ygQAvD_BwE, but check first that such a device is supported by Domoticz.

The cause that it will not work, is that essential data is missing.

Regards
giton
Posts: 14
Joined: Tuesday 23 June 2020 22:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: No Ampere graph with P1 Smart Meter (connected to Soconia T211 3 phase - Belgium)

Post by giton »

Ok, please find here below the full picture of what I'm looking for

Domoticz - schema.png
Domoticz - schema.png (70.15 KiB) Viewed 1617 times
The objective is so to sum Ampers for Flow 1 and Flow 2 in my schema (see orange bullets)

My observations are:
- SBFSpot can only be triggered every minutes @the best
- SBFSpot Ampers are not precise enough (numbers without comma)
- SMA-modbus trigger cannot be < 1 min.

Solution seems to become possible using: P1 Smart Meter USB & Modbus RTU / ASCII / TCP/IP - READ v2020.2F as:
- Triggering is possible per second.
- Total ampers for each Hardware seems accurate.

But I still have to do some calculation to get total Ampers (1+2); as you can see here below, I should add the last 2 values from device 'compteur - power' (as the last one is send to energy provider and the one before is what I consume) and from device 'Sun power' as being what I produce with my solar pannels; the total divided by 230v should give me the Ampers going through my switchboard (see schema at upper). To this, I have to add the max amper that could be required for my heat pump and here it is.
Domoticz - devices - value.jpeg
Domoticz - devices - value.jpeg (216.98 KiB) Viewed 1617 times
But here it seems that I could face another problem is that the data in domoticz per second are stored in DeviceStatus table but are erased by the next data received (1s later); some data looks to be stored then to other table but only sample data and unfortunately 1 record per 5 minutes per device.

So, is Domoticz really the tool to use to do what I want to achieve ?
Can domoticz store all my data (every second) or at least store the max Amper value I get (even the max per 5 minutes timeframe would be ok) as my target is to know the max Amper I need ?


Here the full view of my devices
Domoticz - devices.jpeg
Domoticz - devices.jpeg (218.65 KiB) Viewed 1617 times
giton
Posts: 14
Joined: Tuesday 23 June 2020 22:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: No Ampere graph with P1 Smart Meter (connected to Soconia T211 3 phase - Belgium)

Post by giton »

To get Amper consumed per second I have create lua script 'Ampere.lua' in /home/pi/domoticz/scripts/dzVents/scripts:
(depending on what you are looking for, you can adapt it accordingly)

Code: Select all

return
{
    on = { devices = { 'compteur - power' }}, -- 'name' or id  of your P1 device 
    logging = {level = domoticz.LOG_ERROR, marker = TotalAmperage },
    
    execute = function(dz,item)
        
	local l1Amperage = dz.devices(50) -- define as virtual sensor (ampere 1 phase)    
	local l1AmperageIN = dz.devices(51) -- define as virtual sensor (ampere 1 phase)    
	local l1AmperageOUT = dz.devices(52) -- define as virtual sensor (ampere 1 phase)    
	local voltage = 230
        local l1CurrentAmperageIN = item.usage / voltage
        local l1CurrentAmperageOUT = item.usageDelivered / voltage
        local l1CurrentAmperageTotal = (item.usageDelivered - item.usage) / voltage


	l1AmperageIN.updateCurrent(l1CurrentAmperageIN)
	l1AmperageOUT.updateCurrent(l1CurrentAmperageOUT)
	l1Amperage.updateCurrent(l1CurrentAmperageTotal)
    end
}
I still have to look how to store data per second instead of 5 minutes or find a way to store the maximum ampere value in order to determine the Amper required by my Electricity Meter to cover my current needs and installation of a new heat pump.
giton
Posts: 14
Joined: Tuesday 23 June 2020 22:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: No Ampere graph with P1 Smart Meter (connected to Soconia T211 3 phase - Belgium)

Post by giton »

To store the maximum Ampere I have created a user variable called 'AmpereMax' ( Setup > More options < User variables --> type is 'Float') and added the following lines at the end of the lua script:

Code: Select all

	local AmpereMaxVariable = domoticz.variables('AmpereMax').value -- change to name of your variable 
	if (l1CurrentAmperageIN > AmpereMaxVariable) then
		domoticz.variables('AmpereMax').set(l1CurrentAmperageOUT)
	end
giton
Posts: 14
Joined: Tuesday 23 June 2020 22:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: No Ampere graph with P1 Smart Meter (connected to Soconia T211 3 phase - Belgium)

Post by giton »

Here the complete script to publish AmperMax value in a dashboard based on virtual device (idx 54).
In my schema here upper, only Ampers from flow 2 (in orange bullet with number 2) has to be considered (=incoming Ampers). Outgoing Ampers (generated by my solar energy system and sent to external energy provider as not consumed directly) have not to be considered to size the electricity max Ampers, today @25A).

Code: Select all

return
{
    on = { devices = { 'compteur - power' }}, -- 'name' or id  of your P1 device 
    logging = {level = domoticz.LOG_ERROR, marker = TotalAmperage },
    
    execute = function(dz,item)
        
	local l1Amperage = dz.devices(50) -- define as virtual sensor (ampere 1 phase)    
	local l1AmperageIN = dz.devices(51) -- define as virtual sensor (ampere 1 phase)    
	local l1AmperageOUT = dz.devices(52) -- define as virtual sensor (ampere 1 phase)    
	local l1AmperageMAX = dz.devices(54) -- define as virtual sensor (ampere 1 phase)    
	local voltage = 230
        local l1CurrentAmperageIN = dz.utils.round(item.usage / voltage,2)
        local l1CurrentAmperageOUT = dz.utils.round(item.usageDelivered / voltage,2)
        local l1CurrentAmperageTotal = dz.utils.round((item.usage - item.usageDelivered) / voltage,2)
	local AmpereMaxVariable = dz.variables('AmpereMax').value -- change to name of your variable 
	if (l1CurrentAmperageIN > AmpereMaxVariable) then
		dz.variables('AmpereMax').set(l1CurrentAmperageIN)
		l1AmperageMAX.updateCurrent(l1CurrentAmperageIN)
	end

	l1AmperageIN.updateCurrent(l1CurrentAmperageIN)
	l1AmperageOUT.updateCurrent(l1CurrentAmperageOUT)
	l1Amperage.updateCurrent(l1CurrentAmperageTotal)
    end
}
reneklomp
Posts: 30
Joined: Monday 20 February 2017 23:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: No Ampere graph with P1 Smart Meter (connected to Soconia T211 3 phase - Belgium)

Post by reneklomp »

Code: Select all

return  
{
    on = 
    { 
        devices = {'Usage L1'}, -- set device trigger 
    }, 

    logging = 
    {   
        level = domoticz.LOG_DEBUG,
        marker = 'Amperage', 
    },

    execute = function(dz)
       
        -- Change below between the quotes to names reflecting the devicenames in your system

        local l1Usage = dz.devices('Usage L1').actualWatt
        local l2Usage = dz.devices('Usage L2').actualWatt
        local l3Usage = dz.devices('Usage L3').actualWatt
       
        local l1Amperage = dz.devices('Amperage L1') -- define as virtual sensor (ampere 1 phase)    
        local l2Amperage = dz.devices('Amperage L2') -- define as virtual sensor (ampere 1 phase) 
        local l3Amperage = dz.devices('Amperage L3') -- define as virtual sensor (ampere 1 phase) 
        local totalAmperage = dz.devices('Amperage L1-L3') -- define as virtual sensor (ampere 3 phase)

        -- No changes required below this line

        local voltage = 230

        local l1Current = dz.utils.round(l1Usage / voltage, 1)
        local l2Current = dz.utils.round(l2Usage / voltage, 1)
        local l3Current = dz.utils.round(l3Usage / voltage, 1)

        l1Amperage.updateCurrent(l1Current)
        l2Amperage.updateCurrent(l2Current)
        l3Amperage.updateCurrent(l3Current)
        totalAmperage.updateCurrent(l1Current, l2Current, l3Current)

    end
}
Is there a specific reason you're using voltage=230 when you also have the actual values available in the feed from P1 port? So instead you could be using l1Voltage = dz.devices('Voltage L1').voltage etc.? Sometimes my voltages are 240 or even higher so could be more accurate. I know you round at 1 decimal still but it is as easy as setting it to a constant 230V. But then maybe I am missing something here.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest