This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Reset counter object each month
#1
Hi,

I have iEM 3150 Power Meter running and are continuously counting my power consumption. I have mapped the power consumption to an KNX object  (1/1/1) so it shows me the total power consumption. However, this counter is not possible to reset.

I would like an object let say (2/2/2) that starts each month showing 0 as consumption and as the month progresses it increases. Then, the first day of each month, it starts all over again. This way I am able to track my consumption during the month and se how it progresses.

BR
Mr.D
Reply
#2
This is how i would do it

Add this as a event script to your total power consumption object.
Code:
kwhtot = event.getvalue()
kwhstart = 'kwh_usage_month_start'
kwhoutput = '2/2/2'

if storage.get(kwhstart) == nil then
 storage.set(kwhstart, kwhtot)
end

grp.write(kwhoutput, kwhtot - storage.get(kwhstart))

And this one as scheduled script with cron time 0 0 1 * * ,this would run 1 day every month.
Code:
storage.set('kwh_usage_month_start', nil)
grp.write('2/2/2', 0)

Mvh  Wink

Best regards, Jørn.
Reply
#3
(13.01.2018, 22:19)Jørn Wrote: This is how i would do it

Add this as a event script to your total power consumption object.
Code:
kwhtot = event.getvalue()
kwhstart = 'kwh_usage_month_start'
kwhoutput = '2/2/2'

if storage.get(kwhstart) == nil then
 storage.set(kwhstart, kwhtot)
end

grp.write(kwhoutput, kwhtot - storage.get(kwhstart))

And this one as scheduled script with cron time 0 0 1 * * ,this would run 1 day every month.
Code:
storage.set('kwh_usage_month_start', nil)
grp.write('2/2/2', 0)

Mvh  Wink

Is it possible to add to this script another object '3/3/3' that registers the last maximum value of the object '2/2/2'? so we can visualize the last consumption of the previous month.
Reply
#4
Hi,

possible to use different variants, as use trends:

https://forum.logicmachine.net/showthrea...umentation

but I think for you easiest way is create scheduled scripts, and write to the different groups data of power consumption at 0:00 every 1st day for every month (you will have 12 scheduled scripts). So you will see consumption for starting of month:

Consumpted_Energy = grp.getvalue('33/5/30') -- Group of your Energy meter with consumed energy
grp.write('33/7/13', Consumpted_Energy) -- April. There will be saved data of consumed energy for 0:00 of 1st April

The same for May and so on..:

Consumpted_Energy = grp.getvalue('33/5/30') -- Group of your Energy meter with consumed energy
grp.write('33/7/14', Consumpted_Energy) -- May. There will be saved data of consumed energy for 0:00 of 1st May

For previous month just EnergyPrevious = grp.getvalue('33/7/14') - grp.getvalue('33/7/13') -- For April. You should think also about other month..

Just easy calculations Smile Of course such way you can show consumption for every day/week... etc. For me I show consumption from month start:

(Add this to event script for group where is recorded your consumed energy. So all recalculations will be done automatically when data upgrades (in example 33/5/30)).
MonthConsumed = grp.getvalue('33/5/30') - grp.getvalue('33/7/13' -- Smile

Also there you can add cost of energy:
EnergyCost = 0.16 -- (EuroCents per kWh) your cost

MonthEnergyConsumedCost = MonthConsumed * EnergyCost

grp.write('33/5/50', MonthEnergyConsumedCost) -- group you will store cost of consumed energy

This is just description of easy steps, let's try to play with..

Alex
Reply
#5
Add this at the start of scheduled reset script (before 2/2/2 value is set to 0):
Code:
grp.write('3/3/3', grp.getvalue('2/2/2'))
Reply
#6
(26.04.2020, 09:54)admin Wrote: Add this at the start of scheduled reset script (before 2/2/2 value is set to 0):
Code:
grp.write('3/3/3', grp.getvalue('2/2/2'))

Thank you very much Admin, it works.

In my opinion after the reset, this script is missing a counter status send. The monthly meter needs a first value to start the account. If it is not sent, a small value is lost in consumption.

After the reset, I added this script.

Code:
grp.write('1/1/1', grp.getvalue('1/1/1'))
Reply


Forum Jump: