Page 1 of 1

Splitting up P1 meter [Solved]

Posted: Tuesday 04 June 2019 11:12
by gielie
Hi,

Im looking for a way to split up my P1 meter in used and recieved (from solar).
This is the output from the P1 device.

Code: Select all

{
   "ActTime" : 1559633492,
   "AstrTwilightEnd" : "00:00",
   "AstrTwilightStart" : "00:00",
   "CivTwilightEnd" : "22:46",
   "CivTwilightStart" : "04:33",
   "DayLength" : "16:36",
   "NautTwilightEnd" : "00:02",
   "NautTwilightStart" : "03:16",
   "ServerTime" : "2019-06-04 09:31:32",
   "SunAtSouth" : "13:39",
   "Sunrise" : "05:21",
   "Sunset" : "21:57",
   "app_version" : "4.10854",
   "result" : [
      {
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "Counter" : "11640.097",
         "CounterDeliv" : "159.898",
         "CounterDelivToday" : "0.024 kWh",
         "CounterToday" : "3.398 kWh",
         "CustomImage" : 0,
         "Data" : "5951794;5688303;41891;118007;297;0;",
         "Description" : "",
         "Favorite" : 0,
         "HardwareID" : 14,
         "HardwareName" : "Toon2",
         "HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
         "HardwareTypeVal" : 15,
         "HaveTimeout" : false,
         "ID" : "1459F",
         "LastUpdate" : "2019-06-04 09:31:01",
         "Name" : "Stroom 2",
         "Notifications" : "false",
         "PlanID" : "0",
         "PlanIDs" : [ 0 ],
         "Protected" : false,
         "ShowNotifications" : true,
         "SignalLevel" : "-",
         "SubType" : "Energy",
         "SwitchTypeVal" : 0,
         "Timers" : "false",
         "Type" : "P1 Smart Meter",
         "TypeImg" : "counter",
         "Unit" : 1,
         "Usage" : "297 Watt",
         "UsageDeliv" : "0 Watt",
         "Used" : 1,
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "1359"
      }
   ],
   "status" : "OK",
   "title" : "Devices"
}
i tried some dzvents script but i cant get to work, so the idea is to create 2 dummy meters with the data from the P1 splitted into used and recieve.
Any help is much appreciated.

Re: Splitting up P1 meter

Posted: Tuesday 04 June 2019 12:19
by freijn
Not sure what version you are running, this is standard output in my version 4.10717.

Re: Splitting up P1 meter  [Solved]

Posted: Tuesday 04 June 2019 12:49
by waaren
gielie wrote: Tuesday 04 June 2019 11:12 I'm looking for a way to split up my P1 meter in used and received (from solar).
i tried some dzvents script but i cant get to work, so the idea is to create 2 dummy meters with the data from the P1 splitted into used and recieve.
Any help is much appreciated.
In it's most simple form

Code: Select all

return
{
    on = { devices = { 'Power' }}, -- 'name' or id  of your P1 device 
    logging = {level = domoticz.LOG_ERROR, marker = P1Splitter },
    
    execute = function(dz,item)
        
        local p1Delivery = dz.devices(2085) -- 'name' or id of your virtual P1 for delivery to the grid
        local p1Usage = dz.devices('Usage') -- 'name' or id of your virtual P1 for usage

        p1Delivery.updateP1(item.return1, item.return2, 0, 0,  item.usageDelivered, 0)
        p1Usage.updateP1(item.usage1, item.usage2, 0, 0, item.usage, 0)
    end
}

Re: Splitting up P1 meter

Posted: Tuesday 11 June 2019 14:00
by gielie
waaren wrote: Tuesday 04 June 2019 12:49
gielie wrote: Tuesday 04 June 2019 11:12 I'm looking for a way to split up my P1 meter in used and received (from solar).
i tried some dzvents script but i cant get to work, so the idea is to create 2 dummy meters with the data from the P1 splitted into used and recieve.
Any help is much appreciated.
In it's most simple form

Code: Select all

return
{
    on = { devices = { 'Power' }}, -- 'name' or id  of your P1 device 
    logging = {level = domoticz.LOG_ERROR, marker = P1Splitter },
    
    execute = function(dz,item)
        
        local p1Delivery = dz.devices(2085) -- 'name' or id of your virtual P1 for delivery to the grid
        local p1Usage = dz.devices('Usage') -- 'name' or id of your virtual P1 for usage

        p1Delivery.updateP1(item.return1, item.return2, 0, 0,  item.usageDelivered, 0)
        p1Usage.updateP1(item.usage1, item.usage2, 0, 0, item.usage, 0)
    end
}
Tnks a lott, this works like a charm and i learned some dzvents scripting.

Re: Splitting up P1 meter [Solved]

Posted: Thursday 13 June 2019 20:00
by marigo
What kind of virtual device did you added to your configuration? I have now added the virtual "slimme meter elektra" and used this script, but I get an error. I want only to make usage of the current delivery

Code: Select all

2019-06-13 19:48:39.163 Status: dzVents: Info: Handling events for: "P1 power usage", value: "9184621;10783590;400724;816877;0;30"
2019-06-13 19:48:39.163 Status: dzVents: Error (2.4.19): An error occured when calling event handler delivery
2019-06-13 19:48:39.164 Status: dzVents: Error (2.4.19): .../domoticz/scripts/dzVents/generated_scripts/delivery.lua:11: attempt to call field 'updateP1' (a nil value)
I am new to dzvents but I think I am missing something simple.
I have used only the delivery lines of the script:

Code: Select all

return
{
    on = { devices = { 'P1 power usage' }}, -- 'name' or id  of your P1 device 
    logging = {level = domoticz.LOG_ERROR, marker = P1Splitter },
    
    execute = function(dz,item)
        
        local p1Delivery = dz.devices(82475) -- 'name' or id of your virtual P1 for delivery to the grid
        p1Delivery.updateP1(item.return1, item.return2, 0, 0,  item.usageDelivered, 0)
        
    end
}
Can someone see what's wrong here?

Re: Splitting up P1 meter [Solved]

Posted: Friday 14 June 2019 2:44
by waaren
marigo wrote: Thursday 13 June 2019 20:00 What kind of virtual device did you added to your configuration? I have now added the virtual "slimme meter elektra" and used this script, but I get an error. I want only to make usage of the current delivery
The P1 device you defined should work. Can you please double check the device idx. the number you used (82475) seems very high.

Re: Splitting up P1 meter [Solved]

Posted: Friday 14 June 2019 4:18
by marigo
Changed the id to idx, but the log tells me it can't understand the "updatep1" parameter.

Re: Splitting up P1 meter [Solved]

Posted: Friday 14 June 2019 8:43
by waaren
After changing "name of your target device" to the actual name you have for your target device (keep the quotes), can you please run this one and report back the results from the logfile ? That might help in finding the problem.

Code: Select all

return
{
    on = { devices = { 'P1 power usage' }}, -- 'name' or id  of your P1 device 
    logging = {level = domoticz.LOG_ERROR, marker = P1Splitter },
    
    execute = function(dz,item)
        
        local p1Delivery = dz.devices("name of your target device") 
        p1Delivery.dump()
        p1Delivery.updateP1(item.return1, item.return2, 0, 0,  item.usageDelivered, 0)
        
    end
}

Re: Splitting up P1 meter [Solved]

Posted: Friday 14 June 2019 9:39
by marigo
That's odd. This seems to work immediately. Now the dummy gets updated with the power delivery from the root "P1 power usage".

Great, thank you very much.

The script seems to be triggerd every 10 seconds. I have comment out the .dump. It was filling up my logfile.

Re: Splitting up P1 meter [Solved]

Posted: Friday 14 June 2019 10:00
by waaren
marigo wrote: Friday 14 June 2019 9:39 That's odd. This seems to work immediately. Now the dummy gets updated with the power delivery from the root "P1 power usage".
👍 Great ! Likely that the device number was wrong or entered using quotes ?
The script seems to be triggerd every 10 seconds. I have comment out the .dump. It was filling up my logfile.
Good; this was only needed during debug to identify what device was referenced.

Re: Splitting up P1 meter [Solved]

Posted: Saturday 15 June 2019 8:21
by marigo
I have now entered only the idx (without qoutes) instead of the name of the virtual device and it is also working.
In the first place I had entered the "ID" of the virtual device. (some hex number)

It's working perfectly.
Thanks.

Re: Splitting up P1 meter [Solved]

Posted: Friday 06 October 2023 19:13
by marktn
Hi,

I have 2 device that i like to split to a separate device, a P1 meter and one of the solar panels.

The P1 device, is a Toon thermostaat,
CounterDelivToday "2.592 kWh"
CounterToday "7.710 kWh"

Solar Panels,
CounterToday "10.669 kWh"

How to do that?

regards,
Mark

Re: Splitting up P1 meter [Solved]

Posted: Friday 06 October 2023 20:50
by waltervl
marktn wrote: Friday 06 October 2023 19:13 Hi,

I have 2 device that i like to split to a separate device, a P1 meter and one of the solar panels.

The P1 device, is a Toon thermostaat,
CounterDelivToday "2.592 kWh"
CounterToday "7.710 kWh"

Solar Panels,
CounterToday "10.669 kWh"

How to do that?

regards,
Mark
What do exactly want to achieve?
Because a P1 device already shows returned energy to the grid.
And your solar panels already show the produced energy.

Re: Splitting up P1 meter [Solved]

Posted: Friday 06 October 2023 21:49
by marktn
I want it separate in my dashboard, if possible.

Re: Splitting up P1 meter [Solved]

Posted: Friday 06 October 2023 22:48
by waltervl
For the P1 splitting usage and delivery the script and instructions are in this topic.
For the solar production you just put it on your dashboard. Or am I missing something here?

Re: Splitting up P1 meter [Solved]

Posted: Saturday 07 October 2023 14:50
by marktn
waltervl wrote: Friday 06 October 2023 22:48 For the P1 splitting usage and delivery the script and instructions are in this topic.
For the solar production you just put it on your dashboard. Or am I missing something here?
I don't have any expierence with dzevents... sorry. The most is done in node red.
For the Solar i need to make a seperate script.
return
{
on = { devices = { 'Toon Stroomverbruik' }}, -- 'name' or id of your P1 device
logging = {level = domoticz.LOG_ERROR, marker = P1Splitter },

execute = function(dz,item)

local CounterDelivToday = dz.devices('Toon stroomverbruik vandaag') -- 'name' or id of your virtual P1 for delivery to the grid
local CounterToday = dz.devices('Toon teruglevering vandaag') -- 'name' or id of your virtual P1 for usage

CounterDelivToday.updateP1(item.return1, item.return2, 0, 0, item.usageDelivered, 0)
CounterToday.updateP1(item.usage1, item.usage2, 0, 0, item.usage, 0)
end
}
that gives this error,
2023-10-07 14:44:48.233 Error: dzVents: Error: (3.1.8) Method updateP1 is not available for device "Toon stroomverbruik vandaag" (deviceType=General, deviceSubType=Managed Counter). If you believe this is not correct, please report.

Re: Splitting up P1 meter [Solved]

Posted: Saturday 07 October 2023 16:43
by waltervl
You probably can do this too in node red....but I have 0 experience with this.

Edit: you have made new counter devices instead of P1 devices.

Re: Splitting up P1 meter [Solved]

Posted: Tuesday 10 October 2023 19:19
by PierreT
@marktn

Necroposting is a really bad habit, especially if you are raising a problem in a topic that is already marked as solved.

On your issue, I really have no clue what you are aiming to accomplish. Only thing that seems interesting is to create a virtual counter that shows net usage, i.e. usage P1 + the difference between solar input and P1 return. However, as far as I understand your script you are attempting to insert a multi-value into a singular meter. That doesn't work for obvious reasons, you need to extract the one value you require from the multi-value (there are actually two - one for each tariff - that you'll need to add together) and push that to your virtual device.

Re: Splitting up P1 meter [Solved]

Posted: Tuesday 10 October 2023 20:08
by RonkA
Is this what you want?

Code: Select all

return {
    logging = {
        level = domoticz.LOG_ERROR,
        marker = "P1Splitter"
    },

    on = {
        devices = {
            'Toon Stroomverbruik'
        }
    },

    execute = function(dz, item)
        local Verbruik = dz.devices('Toon Stroomverbruik').counterToday
        local Teruglevering = dz.devices('Toon stroomverbruik').counterDeliveredToday

        dz.devices('Toon stroomverbruik vandaag').updateCounter(Verbruik)
        dz.devices('Toon teruglevering vandaag').updateCounter(Teruglevering)
    }
}