i receive every 10 minutes a count of impulses from my electric meter, each impulse is equal to 0.002 kW/h.
I created a imput_number.test, now i want to add every new count to imput_number.test.
I do something similar to store calculate my daily water usage and the cumulative rain total for a day and to calculate the highest wind gust of the day. all of which i accomplish by pushing the numbers I need to a new MQTT sensor via an automation that publishes the values to a specific topic matching the sensor I created.
Here is the wind gust automations which I just set up recently.
This sensor reporting every minute the amount of impulses from my electric meter. (500 Impulses = 1 Kilowatt Hour)
In my old homeautomation (iobroker) i add on every update the count of impulses to a variable EnergyTemp, an write the total amount at 23:59 to a new variable called DailyAmmount and reset the EnergyTemp.
So i got a historical daily energy graph.
Im trying to understand your idea. You create a non existant mqtt sensor an feed this with data? And which of your sensor generate the real data?
On Update the input_number.test1 is filled with the count from the mqtt topic.
The question now is, how i can count it, some thing like {{ input_number.test1 + trigger.payload}}
yes sorry you’ll need a value template to add the new count to the existing one.
I use subtraction to get my daily water meter, it uses a template sensor and a value template to compute the sensor amount.
- platform: template
sensors:
water:
value_template: '{%- if not (is_state("sensor.water_meter","unknown") or is_state("sensor.water_prior_day","unknown") )-%} {{ (((states.sensor.water_meter.state | float) - (states.sensor.water_prior_day.state | float))) | max (0) | round(2) }} {%- endif -%}'
friendly_name: "Water Today CF"
unit_of_measurement: "CF"
Sow in this example the sensor.water_meter is the incoming water meter reading. the sensor.water_prior_day is the value pushed from mqtt to the made up mqtt sensor to save the prior day’s total. The checks at the beginning just make sure the data is all there and not unkown to do the calculation.
I would assume you can do something similar but with adding instead of subtracting.