Dutch Smart meter additional plug in

update: new updated files attached (3rd update) after a few hickups

I have made an additional plugin working beside the Dutch Smart Meter as written by bfromdruten.

It will take the data from the plugin, i.e. Low, High and Gas readings.

It takes every minute the values and check’s the time;

if the time is: just after midnight or begin of the month at midnight, or 1 jan just after midnight is it will safe the data
for the last 7 days, last 5 month and for the last 3 years the data is shown and the consumption is presented.

the database will be created in time, so the values are not know yet, to put all the data required i made a scene called reset and in the LUUP i have copied the reset luup in to here and run it

the “this device” in resetluup and I_dutchSmartMeterCounter.xml are the new device
the “LowMeter” & “HighMeter” & "GasMeter"in I_duchSmartMeterCounter.xml are the devices created by the DutchSmartMeter by bfromdruten
(ImportRate1 & ImportRate2 & dutchSmartMeter:1)

If somebody can add an grapical page to the D_dutchSmartMeterCounter.json I would appriciated it, cause that is way over my head

I will attach the luup reset next message

Regards
Huib

attached the luup reset file: see above

rgds
Huib

Huib, do I need to first deinstall the one from bfromdruten.

No it is running next to the other
Make sure that you enter the ID of the devices correctly

Tomorow i will update the files for my last version

Rgds
Huib

Maybe you can add some screenshots, or for me as newbie a bit more info how to…

Do I need to update the device ID’s in the XML?

@ScreamHouse;
In the I_ file you have to change the device numbers to your numbers;

Look in the ImportRate1 for the devicenummer for the LowMeter
Look in the ImportRate2 for the devicenummer for the HighMeter
Look in the dutchSmartMeter:1 for the devicenummer for the Gasmeter

Instalation of the plugin as indicated in
http://wiki.micasaverde.com/index.php/Install_LUUP_Plugins

Trust it will show it self

Almost there…I see a lot of fields in the new device, but when I run a scene with your luupcode it is not filling the values.
In the I.xml i have changed the device ID’s as well as the this device ID in the reset luup to my newly created device.

@Screamhouse;

if you got a table with a lot of “0” and only the text Today and Yesterday than you got it
Time will fill the data
Every day at midnight a new set of data is taken en filled in
The same on the right side, but than monthly

have it running for a night and look tomorrow if the data from midnight is in the list

rgds
Huib

Huib, i was expecting that the tabke would be filled if i manually run the scene.
I did not schedule the scene yet. Rgs screamhouse

@Screamhouse,

Trust that after running the additional plug for a couple of days the daily consumptions are being collected automatically

if you still want an email at a certain moment in time you can make a scene which runs every … and sent you an email with the data as you want

rgds
huib

I have updated the files at the beginning.
Now i have changed the timing function to reduce the load to the veralite

rgds
Huib

Huib, it now collects data really nicely, any suggestion how i can mail the weekly usage to myself?

Rg Koen

@screamhouse

to send the readings by mail i have done the following;

1 made a scene and with the time i trigger one a month (or one every monday or so) to trigger a luup

local smtp = require("socket.smtp")

        local SMTP_SERVER = "xxx.xxxx.xx"
        local SMTP_PORT = "25"
        local USER_SENDING = "<xxx@xxx.xx>"
        local USER_RECEIVING = "<xxxx@xxx.xx>"

        local METER_DEV_ID = 27
        local METER1_DEV_ID = 34
        local METER2_DEV_ID = 35

local gas= luup.variable_get("urn:brutgrink-com:serviceId:dutchSmartMeter", "Gas",  METER_DEV_ID ) or "0"
local kwh1= luup.variable_get("urn:micasaverde-com:serviceId:EnergyMetering1", "KWH",  METER1_DEV_ID ) or "0"
local kwh2= luup.variable_get("urn:micasaverde-com:serviceId:EnergyMetering1", "KWH",  METER2_DEV_ID ) or "0"

        local from = USER_SENDING
        local rcpt = {USER_RECEIVING}

        local mesgt = {
            headers = {
                to = USER_RECEIVING,
                subject = "Meterstanden"
            },
            body = "Meterstanden van :\nGas\t\t\t= " .. gas .. "\nLaag\t\t\t= " .. kwh1 .. "\nHoog\t\t\t= " .. kwh2
            }

        local r, e = smtp.send{
            from = from,
            rcpt = rcpt,
            source = smtp.message(mesgt),
            server = SMTP_SERVER,
            port = SMTP_PORT,
          }

        if (e) then
            luup.log("Error " ..  e)
        end

the ID are the same as in the addtional plug in
you have to change the xxx@xxx.xx to your adress@whatever.com
the server is your own outgoing server (same as in your email account) mail@xxxx. or pop@knp or so

Be advise to update the files of the additional plug in, due to a different interval timing protocol ,
the provious was having some hick ups

rgds

Huib

Huib, thx i am using that one already. What i am after without any programming skills is to receive the usage (sunday - last sunday). So if last sunday my gas meter was 150m3 and this sundsy 220m3, i want to receive the value 70m3.

Reg koen

try the following luup

local smtp = require("socket.smtp")

        local SMTP_SERVER = "xxx.xxxx.xx"
        local SMTP_PORT = "25"
        local USER_SENDING = "<xxx@xxx.xx>"
        local USER_RECEIVING = "<xxxx@xxx.xx>"

        local METER_DEV_ID = 27
        local METER1_DEV_ID = 34
        local METER2_DEV_ID = 35

		local ADD_Plugin = 120    -- put the id of the additional plugin
		
local gas= luup.variable_get("urn:brutgrink-com:serviceId:dutchSmartMeter", "Gas",  METER_DEV_ID ) or "0"
local kwh1= luup.variable_get("urn:micasaverde-com:serviceId:EnergyMetering1", "KWH",  METER1_DEV_ID ) or "0"
local kwh2= luup.variable_get("urn:micasaverde-com:serviceId:EnergyMetering1", "KWH",  METER2_DEV_ID ) or "0"

local last_gas = luup.variable_get("urn:Kuiper-com:serviceId:dutchSmartMeterCounter", "TodayGas_6",  ADD_Plugin ) or "0"
local last_kwh1= luup.variable_get("urn:Kuiper-com:serviceId:dutchSmartMeterCounter", "TodayLow_6",  ADD_Plugin ) or "0"
local last_kwh2= luup.variable_get("urn:Kuiper-com:serviceId:dutchSmartMeterCounter", "TodayHigh_6", Add_Plugin ) or "0"

local gas = gas - last_gas
local kwh1 = kwh1 - last_kwh1
local kwh2 = kwh2 - last_kwh2

        local from = USER_SENDING
        local rcpt = {USER_RECEIVING}

        local mesgt = {
            headers = {
                to = USER_RECEIVING,
                subject = "Meterstanden"
            },
            body = "Verbruik standen van :\nGas\t\t\t= " .. gas .. "\nLaag\t\t\t= " .. kwh1 .. "\nHoog\t\t\t= " .. kwh2
            }

        local r, e = smtp.send{
            from = from,
            rcpt = rcpt,
            source = smtp.message(mesgt),
            server = SMTP_SERVER,
            port = SMTP_PORT,
          }

        if (e) then
            luup.log("Error " ..  e)
        end

i did not yet tried it but if you look at the script it must work
do change the ID of the different plugins

rdgs

Huib

Great!!!

One small thing: it works for Gas and Low Electricity. For High Electricity I only get the total usage.

(If you could add Year to date as well, it would be great, I did try myself, but messed it up)

@screamhouse

i do not see any error in the script
the only thing i can think of is that in the line
local last_kwh2= luup.variable_get(“urn:Kuiper-com:serviceId:dutchSmartMeterCounter”, “TodayHigh_6”, Add_Plugin ) or “0”
some thing is not correct and the value of “0” is taken

further the value _6 has to be _7 to take the reading from one week a go

what do you mean of (If you could add Year to date as well, it would be great, I did try myself, but messed it up)

pls advise

rgds
huib

Huib,

I think because I run it in a weekend the High tarif is 0 is the reason. Let me run it during the week.

What I would like to have send as well is the year consumption in a same mail. This way I know when I get the mail how much my total consumption was up till now. Just a nice to have, really happy with the plugin as is

Huib, after installing the new files, the data does not get updated, since last week no data was written to the database anymore at 0:00

@screamhouse,

please find attached a print screen of today
i still get the data in place

be advised that the trigger is 00:00:00 every day, so at the first line only the date seems to change

please advise

regards
huib