Splitting up P1 meter [Solved]  [Solved]

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

Moderator: leecollings

Post Reply
User avatar
gielie
Posts: 290
Joined: Tuesday 12 January 2016 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Splitting up P1 meter [Solved]

Post 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.
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
freijn
Posts: 536
Joined: Friday 23 December 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands Purmerend
Contact:

Re: Splitting up P1 meter

Post by freijn »

Not sure what version you are running, this is standard output in my version 4.10717.
Attachments
Capture.JPG
Capture.JPG (72.58 KiB) Viewed 6607 times
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Splitting up P1 meter  [Solved]

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
gielie
Posts: 290
Joined: Tuesday 12 January 2016 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Splitting up P1 meter

Post 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.
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
marigo
Posts: 30
Joined: Sunday 31 May 2015 11:04
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands, Veenendaal
Contact:

Re: Splitting up P1 meter [Solved]

Post 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?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Splitting up P1 meter [Solved]

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
marigo
Posts: 30
Joined: Sunday 31 May 2015 11:04
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands, Veenendaal
Contact:

Re: Splitting up P1 meter [Solved]

Post by marigo »

Changed the id to idx, but the log tells me it can't understand the "updatep1" parameter.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Splitting up P1 meter [Solved]

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
marigo
Posts: 30
Joined: Sunday 31 May 2015 11:04
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands, Veenendaal
Contact:

Re: Splitting up P1 meter [Solved]

Post 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.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Splitting up P1 meter [Solved]

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
marigo
Posts: 30
Joined: Sunday 31 May 2015 11:04
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands, Veenendaal
Contact:

Re: Splitting up P1 meter [Solved]

Post 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.
marktn
Posts: 232
Joined: Tuesday 21 April 2015 21:39
Target OS: Windows
Domoticz version:
Contact:

Re: Splitting up P1 meter [Solved]

Post 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
Domoticz latest stable, Intel NUC, Proxmox, Zigate, RFLink, Kaku switches, Ikea lights, Xiaomi sensors, Honeywell smoke detectors, Yeelight, Shelly, Slave Domoticz PI 3B+, Node-Red, Espeasy.
User avatar
waltervl
Posts: 5721
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Splitting up P1 meter [Solved]

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
marktn
Posts: 232
Joined: Tuesday 21 April 2015 21:39
Target OS: Windows
Domoticz version:
Contact:

Re: Splitting up P1 meter [Solved]

Post by marktn »

I want it separate in my dashboard, if possible.
Domoticz latest stable, Intel NUC, Proxmox, Zigate, RFLink, Kaku switches, Ikea lights, Xiaomi sensors, Honeywell smoke detectors, Yeelight, Shelly, Slave Domoticz PI 3B+, Node-Red, Espeasy.
User avatar
waltervl
Posts: 5721
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Splitting up P1 meter [Solved]

Post 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?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
marktn
Posts: 232
Joined: Tuesday 21 April 2015 21:39
Target OS: Windows
Domoticz version:
Contact:

Re: Splitting up P1 meter [Solved]

Post 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.
Attachments
firefox_2023-10-07_14-48-58.jpg
firefox_2023-10-07_14-48-58.jpg (288.67 KiB) Viewed 3087 times
Domoticz latest stable, Intel NUC, Proxmox, Zigate, RFLink, Kaku switches, Ikea lights, Xiaomi sensors, Honeywell smoke detectors, Yeelight, Shelly, Slave Domoticz PI 3B+, Node-Red, Espeasy.
User avatar
waltervl
Posts: 5721
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Splitting up P1 meter [Solved]

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
PierreT
Posts: 51
Joined: Wednesday 03 May 2023 10:12
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Splitting up P1 meter [Solved]

Post 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.
User avatar
RonkA
Posts: 100
Joined: Tuesday 14 June 2022 12:57
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Harlingen
Contact:

Re: Splitting up P1 meter [Solved]

Post 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)
    }
}
SolarEdge ModbusTCP - Kaku - Synology NAS - Watermeter - ESPEasy - DS18b20
Work in progress = Life in general..
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest