Using 'comsumed' and 'Returned' actual P1 power

Moderator: leecollings

Post Reply
User avatar
Domoberry
Posts: 121
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Using 'comsumed' and 'Returned' actual P1 power

Post by Domoberry »

Newbee here with a question on using the P1 Smart Meter (slimme meter) data in a Blockly script.

I have recently got a RPI3, installed Domoticz (latest stable) on it and added some ‘hardware’: SolarEdge (via API) solar system, a neighboring Wunderground weather station, Nefit Easy thermostat, Hue bridge and a p1 smart meter. As an experiment, I tried using Blockly to have a Hue light turn Red (=consuming power) or Green (=returning power) with brightness representing the relative amount. The Blocky script activates one of 8 ‘red’ or ‘green’ scenes with four levels of brightness. Blocky is a bunch of IF / IF ELSE based on the Device/Utility value ‘Power/Actual’. This works fine for consuming power, but less so when returning power.
By having the ‘Power/Actual’ variable writing (debug) to the log, I started to understand why it was not working as intended. I hope someone has some ideas!
1) Even though in the utility tab ‘Power’ summarizes consumption as + or -, indicating ‘consumption’ and ‘generating’, the variable ‘Power/Actual’ only provides the ‘consumed’ power; it becomes zero as soon as power is returned to the mains.
2) Looking at the output of ‘Power / Actual’ in the log, I noted it provides a string like 940351;397695;482513;1038804;0;84. The first 4 numbers provide the counter values (consumption to date / returned to date for high and low tariff). The last two numbers represent ‘actual power consumed’ (0W) and ‘actual power returned’ (84W)
3) The utility tab ‘Power’ seems to combine these last two and adds a minus in case power is returned to the grid.
4) It seems ‘Power / Actual’ is different when used in an IF statement (actual consumer power as a number) or when used in a Write-to-log debug statement (a string of 6 separated numbers)

My questions:
- How can I, in Blockly, get hold of the number shown in ‘Power’ in the Utility tab, e.g. with the sign indicating consume/return? (as that is what I wrongly assumed on my script) -or-
- Is there another way I can obtain the actual returned power in Blockly next to what ‘Power / Actual’ currently represents (actual consumed power)
- Or… should I go for a different approach if I want to Hue lamp to represent consumed/returned power?
TheBassman
Posts: 2
Joined: Saturday 10 June 2017 22:18
Target OS: Windows
Domoticz version:
Contact:

Re: Using 'comsumed' and 'Returned' actual P1 power

Post by TheBassman »

I, also have a consumption meter on my SolarEdge inverter, and would like to see the data in Domoticz. I do get it to PVOutput.org via their auto uploader.
Pulling the data from the API directly, using the currentPowerFlow option gives all the current readings in positive values (in kW), and a "Connections" array that shows the status of the PV, GRID, and LOAD. Here is a sample of the API's output:

Code: Select all

https://monitoringapi.solaredge.com/site/XXXXX/currentPowerFlow?

Code: Select all

<siteCurrentPowerFlow>
    <updateRefreshRate>5</updateRefreshRate>
    <unit>kW</unit>
    <GRID>
        <status>Active</status>
        <currentPower>2.1</currentPower>
    </GRID>
    <LOAD>
        <status>Active</status>
        <currentPower>1.93</currentPower>
    </LOAD>
    <PV>
        <status>Active</status>
        <currentPower>4.03</currentPower>
    </PV>
    <connections>
        <connection>
            <from>LOAD</from>
            <to>Grid</to>
        </connection>
        <connection>
            <from>PV</from>
            <to>Load</to>
        </connection>
    </connections>
</siteCurrentPowerFlow>
User avatar
Domoberry
Posts: 121
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Using 'comsumed' and 'Returned' actual P1 power

Post by Domoberry »

Hi TheBassman,
Tried the link as JSON command:
https://monitoringapi.solaredge.com/sit ... OUR_APIKEY
which just returned
{"siteCurrentPowerFlow":{}}
Likely due to the fact that the current generated power is 0. Some other API calls yield results as expected. Will try again tomorrow.

I do not have any additional power meter linked to the SolarEdge inverter, just what the inverter itself offers using the Web API. And the normal utility meter registering power/energy used and returned from the household.
'My' PVoutput.org is also using the Web API from SolarEdge with the auto uploader in my case.

Do I understand correctly that in your case you are also sending the power/energy you are receiving-from/sending-to the grid and that such arrives in PVoutput as well? If so, could you share how this was done?

On my question regarding the P1 Slimme Meter data, my newbee progress: I think the current P1 Slimme Meter implementation does not support 'returned' power to be used in Blockly, perhaps in an update.
I have taken some first steps in Lua and noted that with something like
print("power = " .. otherdevices['Power'])
you get all the Slimme Meter data in a string, next you need to parse it to get to the sub items, of which the last two ones are 'used' and 'returned' actual power.
User avatar
Domoberry
Posts: 121
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Using 'comsumed' and 'Returned' actual P1 power

Post by Domoberry »

Hi Gordonb3,
Fully agree that 'actual power' in W can in Domoticz practice not be related to 'energy used' for example in Ws (or kWh for that matter). It is not my objective to use 'returned actual power' to convert it into 'returned energy'. Rather, I'm trying to get some hands on with scripting (newbee...) and decided it would be fun to have my 2nd ever script that would change the brightness and color of a Hue lamp based on my smart meter indicting the actual amount of 'power used' or 'power returned'. Turned out to be bit more complex then my first 'hello world' script :-)
freijn
Posts: 536
Joined: Friday 23 December 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands Purmerend
Contact:

Re: Using 'comsumed' and 'Returned' actual P1 power

Post by freijn »

Guys,

Quick and very dirty I know,
But is this what you are looking for?

What I found:
Updates from the SolarEdge are not as many as my PowerMeter at home. So I made an script responding on the SolarEdge update.
I substract power generated from the Solar minus power returned to provider = power used in my house.

Not that accurate but a nice value to have. Please let me know if I have misunderstood or if I am on the right track :-)

Cheers,

Frank

Code: Select all

commandArray = {}


--powersensor = "Power"

--if (devicechanged[powersensor]) then
 --  print( " ####Power debug: "..devicechanged[powersensor])
   -- commandArray['Variable:LUX']=tostring(devicechanged[luxsensor])
--  var1, var2,var3,var4,var5,var6 = string.match(otherdevices_svalues['Power'], "(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*)")
--   print( " ####Power debug: "..var6)
 --  end


solarsensor = "SolarEdge kWh Meter"

if (devicechanged[solarsensor]) then
   print( " ####Solar debug: "..devicechanged[solarsensor])
   Solarvar1, var2 = string.match(otherdevices_svalues[solarsensor], "(%d+%.*%d*);(%d+%.*%d*)")
   print( " ####Solar debug: "..Solarvar1)

   powersensor = "Power"

-- if (devicechanged[powersensor]) then
   --print( " ####Power debug: "..devicechanged[powersensor])
   var1, var2,var3,var4,var5,Powervar6 = string.match(otherdevices_svalues['Power'], "(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*)")
   print( " ####Power debug: "..Powervar6)

 powercount = tonumber(Powervar6)
 solarcount = tonumber(Solarvar1)
 
 consume = solarcount - powercount
 print( " ####Consume debug: "..consume)
 

    end

return commandArray
User avatar
Domoberry
Posts: 121
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Using 'comsumed' and 'Returned' actual P1 power

Post by Domoberry »

Hi Frank,
Thanks a lot for the reply. I get what you are doing and as a newbee I learned a lot.
First off, the objective of my script is to control a Hue lamp in such a way that it shows 'red' when my house is actually consuming power and 'green' when the house is returning power to the grid. Its only use is to get some hands on with scripting.
Power using/returning is a value provided via the P1 Slimme Meter. My initial problem was that Blockly did not provide me with the 'returned actual power' (or better: I did not know how). My conclusion in the meantime is that its better to use Lua for this. So, I hacked together my first Lua lines and after several hours++ "ta-ta" it does what I want it to do. Found some limitations, but that is for version 2 :-)
What I found very interesting is the way you parsed the P1 Slimme Meter string into its separate variables on one line! I'm using several string.find commands to locate the ";" positions and then multiple string.sub to get to the values. I will use yours!

So, to summarize the 'answer' to my post:
- no, there does not seem to be a way at the moment to obtain in Blockly the 'returned actual power' from your P1 Slimme Meter. Only the 'used actual power' is readily available
- To get hold of the 'returned actual power' use Lua scripting, much more flexible

Thanks for getting a newbee started!
freijn
Posts: 536
Joined: Friday 23 December 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands Purmerend
Contact:

Re: Using 'comsumed' and 'Returned' actual P1 power

Post by freijn »

To be completely honest.... I have solar panels installed last friday and had the same objective, only NOT with a lamp but with a TEST node on my page.
Did you know you can change colour on the test node as well?
User avatar
Domoberry
Posts: 121
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Using 'comsumed' and 'Returned' actual P1 power

Post by Domoberry »

Sorry, probably stupid question, but what is a 'test node'?
freijn
Posts: 536
Joined: Friday 23 December 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands Purmerend
Contact:

Re: Using 'comsumed' and 'Returned' actual P1 power

Post by freijn »

TextNode. sorry..

So a reporting window, displaying the amnount of Watts and colour in Green or in RED
User avatar
Domoberry
Posts: 121
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Using 'comsumed' and 'Returned' actual P1 power

Post by Domoberry »

Ok, clear. Nice idea, but I would not know how to change the color of these. You can upload new icons, but that needs a restart of Domoticz...
freijn
Posts: 536
Joined: Friday 23 December 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands Purmerend
Contact:

Re: Using 'comsumed' and 'Returned' actual P1 power

Post by freijn »

Give me some time, I clean up mine and publish it here. :-)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest