P1 USB smart meter - Actual tariff

Moderator: leecollings

Post Reply
sjoerd1953
Posts: 11
Joined: Monday 09 January 2017 9:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Swolgen
Contact:

P1 USB smart meter - Actual tariff

Post by sjoerd1953 »

I have a smart meter for a few weeks now. It is connected to a Raspberry Pi running Domoticz. Everything works fine but the only information I am missing is the actual tariff (high or low). This information is available in the telegram as item 0-0:96.14.0(0001) or 0-0:96.14.0(0002). Domoticz obviously uses this setting when creating the 24h graph but I can't find it anywhere in the database. Does someone know how to access this information?
Sjoerd van Staveren

Domoticz running on a Raspberry Pi 3; Milight RGBW and Dual White bulbs; RFXcom XL;HOMEeasy switch; Flamingo switches; Sonoff switches
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: P1 USB smart meter - Actual tariff

Post by waaren »

sjoerd1953 wrote: Thursday 16 July 2020 12:02 Does someone know how to access this information?
Domoticz use this information indirectly. When the low tariff is active only the low tariff kWh counter does increase and if the high tariff is active the high kWh tariff counter increase
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
sjoerd1953
Posts: 11
Joined: Monday 09 January 2017 9:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Swolgen
Contact:

Re: P1 USB smart meter - Actual tariff

Post by sjoerd1953 »

Thank you for the reply. So Domoticz has no knowledge of the actual tariff.

As an alternative, is possible to write a script that gets this information from the original telegram as it is sent by the smart meter and put it in a virtual sensor.

I can read the the original telegram in Node-RED using the serial-in node but I can't have both systems (Domoticz and Node-RED) to use the USB port at the same time. That gives errors in one of them.
Sjoerd van Staveren

Domoticz running on a Raspberry Pi 3; Milight RGBW and Dual White bulbs; RFXcom XL;HOMEeasy switch; Flamingo switches; Sonoff switches
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: P1 USB smart meter - Actual tariff

Post by waaren »

sjoerd1953 wrote: Thursday 16 July 2020 13:21 As an alternative, is possible to write a script that gets this information from the original telegram as it is sent by the smart meter and put it in a virtual sensor.
You can try with below dzVents script

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 =
    {
        timer =
        {
            'at 06:30-07:30 every 5 minutes on mon,tue,wed,thu,fri', 
            'at 20:30-21:30 every 5 minutes on mon,tue,wed,thu,fri', -- when tariff switch is around 21:00
            'at 22:30-23:30 every 5 minutes on mon,tue,wed,thu,fri', -- when tariff switch is around 23:00
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when script is OK
        marker = 'tariff',
    },

    data =
    {
        highTariff = { initial = 0 },
        lowTariff = { initial = 0 },
    },

    execute = function(dz, item)
        local p1 = dz.devices('Power') -- change to name of smartmeter
        local tariffSensor = dz.devices('tariffSensor') -- change to name of textSensor

        dz.log(p1.usage1,dz.LOG_DEBUG)
        dz.log(p1.usage2,dz.LOG_DEBUG)
        dz.log(p1.return1,dz.LOG_DEBUG)
        dz.log(p1.return2,dz.LOG_DEBUG)

        if ( p1.usage2 + p1.return2) ~= dz.data.highTariff then
            tariffSensor.updateText('High tariff')
            dz.data.highTariff = p1.usage2 + p1.return2
        elseif ( p1.usage1 + p1.return1) ~= dz.data.lowTariff then
            tariffSensor.updateText('Low tariff')
            dz.data.lowTariff = p1.usage1 + p1.return1
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
sjoerd1953
Posts: 11
Joined: Monday 09 January 2017 9:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Swolgen
Contact:

Re: P1 USB smart meter - Actual tariff

Post by sjoerd1953 »

Thank you waaren. At the moment I am getting High tariff as a result. Now wait until 9PM tonight to see if it changes. I am not sure yet why it works but I will figure that out the next few hours :D .
Sjoerd van Staveren

Domoticz running on a Raspberry Pi 3; Milight RGBW and Dual White bulbs; RFXcom XL;HOMEeasy switch; Flamingo switches; Sonoff switches
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: P1 USB smart meter - Actual tariff

Post by waaren »

sjoerd1953 wrote: Thursday 16 July 2020 17:06 At the moment I am getting High tariff as a result. Now wait until 9PM tonight to see if it changes.
Made some required adjustments to the script in my earlier post to prevent toggling between the two tariffs :) . Please replace the previous one with the updated.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
sjoerd1953
Posts: 11
Joined: Monday 09 January 2017 9:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Swolgen
Contact:

Re: P1 USB smart meter - Actual tariff

Post by sjoerd1953 »

It didn't work yet. The values of highTariff and lowTariff stayed nill. I made some changes and now it seems to work:

Code: Select all

return
{
    on =
    {
        timer =
        {
            'every minute',
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when script is OK
        marker = 'tariff',
    },

    data =
    {
        
        highTariff = { initial = 0 },
        lowTariff = { initial = 0 }
        
    },
    

    execute = function(dz, item)
        local p1 = dz.devices('Stroom')
        local tariffSensor = dz.devices('Tarief')

        dz.log(p1.usage1,dz.LOG_DEBUG)
        dz.log(p1.return1,dz.LOG_DEBUG)
        dz.log(dz.data.lowTariff,dz.LOG_DEBUG)
        
        dz.log(p1.usage2,dz.LOG_DEBUG)
        dz.log(p1.return2,dz.LOG_DEBUG)
        dz.log(dz.data.highTariff,dz.LOG_DEBUG)

        if ( p1.usage2 + p1.return2) ~= dz.data.highTariff then
            tariffSensor.updateText('Hoog tarief')
            dz.data.highTariff = p1.usage2 + p1.return2
            dz.log(dz.data.highTariff,dz.LOG_DEBUG)
        elseif ( p1.usage1 + p1.return1) ~= dz.data.lowTariff then
            tariffSensor.updateText('Laag tarief')
            dz.data.lowTariff = p1.usage1 + p1.return1
            dz.log(dz.data.lowTariff,dz.LOG_DEBUG)
        end
    end
}
Sjoerd van Staveren

Domoticz running on a Raspberry Pi 3; Milight RGBW and Dual White bulbs; RFXcom XL;HOMEeasy switch; Flamingo switches; Sonoff switches
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: P1 USB smart meter - Actual tariff

Post by waaren »

sjoerd1953 wrote: Friday 17 July 2020 8:31 It didn't work yet. The values of highTariff and lowTariff stayed nill. I made some changes and now it seems to work:
:) Good that it is working now. Still some optimization possible by modifying the timer = section. This to ensure the script will only start around the times the tariff will switch.
like below

Code: Select all

return
{
    on =
    {
        timer =
        {
            'at 06:30-07:30 every 5 minutes on mon,tue,wed,thu,fri', 
            'at 20:30-21:30 every 5 minutes on mon,tue,wed,thu,fri', -- when tariff switch is around 21:00
            'at 22:30-23:30 every 5 minutes on mon,tue,wed,thu,fri', -- when tariff switch is around 23:00
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when script is OK
        marker = 'tariff',
    },

    data =
    {
        highTariff = { initial = 0 },
        lowTariff = { initial = 0 },
    },

    execute = function(dz, item)
        local p1 = dz.devices('Power') -- change to name of smartmeter
        local tariffSensor = dz.devices('tariffSensor') -- change to name of textSensor

        dz.log(p1.usage1,dz.LOG_DEBUG)
        dz.log(p1.usage2,dz.LOG_DEBUG)
        dz.log(p1.return1,dz.LOG_DEBUG)
        dz.log(p1.return2,dz.LOG_DEBUG)

        if ( p1.usage2 + p1.return2) ~= dz.data.highTariff then
            tariffSensor.updateText('High tariff')
            dz.data.highTariff = p1.usage2 + p1.return2
        elseif ( p1.usage1 + p1.return1) ~= dz.data.lowTariff then
            tariffSensor.updateText('Low tariff')
            dz.data.lowTariff = p1.usage1 + p1.return1
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: P1 USB smart meter - Actual tariff

Post by EddyG »

You could even narrow it down a lot more.
In my case the switch is almost exactly at 07:00 and 23:00
I can see that on Domoticz graphs, because only at those exact time I see both value.
Domoticz has a 5 min. graph.
Perhaps you could even narrow it down to only 06:55 and 07:05 and 22:55 and 23:05
@sjoerd1953 Just curious, where do you use it for?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: P1 USB smart meter - Actual tariff

Post by waaren »

EddyG wrote: Friday 17 July 2020 9:18 Perhaps you could even narrow it down to only 06:55 and 07:05 and 22:55 and 23:05
True but it also depends on the frequency of the script within those windows. In some areas of the Netherlands the evening switch time is 21:00.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
sjoerd1953
Posts: 11
Joined: Monday 09 January 2017 9:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Swolgen
Contact:

Re: P1 USB smart meter - Actual tariff

Post by sjoerd1953 »

@waaren That is correct. I live in Limburg and here the change to low tariff is at 21:00
@EddyG No particular use. I was just curious if it was possible. Nice side effect is that I got introduced to dzVents by waaren. I love the way it works :D
Sjoerd van Staveren

Domoticz running on a Raspberry Pi 3; Milight RGBW and Dual White bulbs; RFXcom XL;HOMEeasy switch; Flamingo switches; Sonoff switches
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: P1 USB smart meter - Actual tariff

Post by EdwinK »

Found this old topic.

Not sure if it is possible at all, but would it be possible that the sensor switches if/when the company sends a signal to switch from high to low? So, that it isn't depend on time, but on a signal>
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest