Create possibility to store negative numbers in managed counters
Posted: Monday 29 March 2021 12:27
Hello,
I am using Domoticz for years now in combination with several extensions like HUE, RFXComm.
Recently I added solar panels and am building a system to track nett energy use. Visualizations through Grafana.
Daily at midnight I calculate my nett energy use (in euro) based on power device (T1+T2-R1-R2) Total consumption - total delivered.
This value can become negative because I deliver more to energy grid than I use from energy grid.
When storing this negative result in a managed counter it stores as zero (unsigned values).
There are some suggestions to use a senso but then the avagare, min and max values become confusing. Plus if I only store one valy just before midnight (23:59) the sensor is using this value for the next hour offsetting the min/max for next day. Based on which value is greater yesterday or taday the actuall correct value is min or max value. So this approach leads to ambiguous results and real value cannot be determined. Plus totals are not calculated.
What I would like to propose is possibility to offset the zero point for a managed counter. Move the zero value up by a certain value so that negative values can be stored. In setting besides divider and counter offset a zero offset value (or max negative value offset) should be introduced.
If this is set to 100 then that would mean that a zero value is stored as 100 in database. 25 stored as 125 and -50 as 50. This would allow a managed counter to store negative values (up to defined max value). Displaying these values need work and also the calculation of consumption would require work. But it would allow using negative values without changing the overall architecture and database schema.
If I missed an other possiblity to allow for negative values in managed counters I would really like to test that. Using sensors is maybe a workaround but does not work properly because the last value is used for next hour.
What also is needed for this approach is the possibility to provide negative values in updateHistory (dzvents calls) to 'manage' the counter.
regards,
Andre
I am using Domoticz for years now in combination with several extensions like HUE, RFXComm.
Recently I added solar panels and am building a system to track nett energy use. Visualizations through Grafana.
Daily at midnight I calculate my nett energy use (in euro) based on power device (T1+T2-R1-R2) Total consumption - total delivered.
This value can become negative because I deliver more to energy grid than I use from energy grid.
When storing this negative result in a managed counter it stores as zero (unsigned values).
There are some suggestions to use a senso but then the avagare, min and max values become confusing. Plus if I only store one valy just before midnight (23:59) the sensor is using this value for the next hour offsetting the min/max for next day. Based on which value is greater yesterday or taday the actuall correct value is min or max value. So this approach leads to ambiguous results and real value cannot be determined. Plus totals are not calculated.
What I would like to propose is possibility to offset the zero point for a managed counter. Move the zero value up by a certain value so that negative values can be stored. In setting besides divider and counter offset a zero offset value (or max negative value offset) should be introduced.
If this is set to 100 then that would mean that a zero value is stored as 100 in database. 25 stored as 125 and -50 as 50. This would allow a managed counter to store negative values (up to defined max value). Displaying these values need work and also the calculation of consumption would require work. But it would allow using negative values without changing the overall architecture and database schema.
If I missed an other possiblity to allow for negative values in managed counters I would really like to test that. Using sensors is maybe a workaround but does not work properly because the last value is used for next hour.
What also is needed for this approach is the possibility to provide negative values in updateHistory (dzvents calls) to 'manage' the counter.
regards,
Andre