Writing historic value in Managed Counter
Posted: Thursday 21 January 2021 9:27
Hi,
I'm trying to get an overview of how my yearly power (and gas) consumption changes over time. I know now we're working from home most of the time my power and gas consumption will be higher, and I want to see how much it changes.
I do have a script (Thanks @waaren, https://domoticz.com/forum/viewtopic.php?t=30376) which calculates the consumption over the last year (value(current) - value(today - 1 year)) and I now write that in a managed counter. That works just fine. But if I want to see how it evolves over time, I should also get these values into the history log.
parts of my code:
Possible options I see now:
1. Use a custom sensor to register the values. That will keep a history log of all values and will also calculate the daily and monthly values. However, I don't need a value every 5 minutes (or every time I calculate it), I only need a daily value over time.
2. Store the value directly into the history log, which for me sounds ideal. I've found a way to do this using a JSON call:
source: https://www.domoticz.com/wiki/Domoticz_ ... ed_counter
But as I'm using a dzVents script, I'd rather have a dzVents code to do this.
Any way to directly store a historic value into a managed counter using a dzVents command?
Many thanks to you all!
L
I'm trying to get an overview of how my yearly power (and gas) consumption changes over time. I know now we're working from home most of the time my power and gas consumption will be higher, and I want to see how much it changes.
I do have a script (Thanks @waaren, https://domoticz.com/forum/viewtopic.php?t=30376) which calculates the consumption over the last year (value(current) - value(today - 1 year)) and I now write that in a managed counter. That works just fine. But if I want to see how it evolves over time, I should also get these values into the history log.
parts of my code:
Code: Select all
local powerYearConsumption = dz.devices('Power Year consumption') -- Counter device showing power Consumption
powerTotal = (powerToday - powerLastYear)
powerYearConsumption.updateCounter(powerTotal)
1. Use a custom sensor to register the values. That will keep a history log of all values and will also calculate the daily and monthly values. However, I don't need a value every 5 minutes (or every time I calculate it), I only need a daily value over time.
2. Store the value directly into the history log, which for me sounds ideal. I've found a way to do this using a JSON call:
Code: Select all
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=COUNTER;USAGE;DATE
But as I'm using a dzVents script, I'd rather have a dzVents code to do this.
Any way to directly store a historic value into a managed counter using a dzVents command?
Many thanks to you all!
L