Hi,
I am using NodeRed in combination with HomeAssistant.
So far, everything is working as expected - but right now, I am struggling with creating some kind of datalogger like behave.
Home Assistant
In HomeAssistant, I have some "measurement" sensors.
These sensors are counting for example the energy usage over a specific period of time (daily, weekly, monthly and yearly).
Everytime, when such a period is over, the sensor will reset to zero - and start a fresh cycle.
So far - so good, this is what I do expect.
Now, I am searching for a way to save the last sensor value before a new cycle is starting - to get some kind of datalogger.
for example, these are two of these sensors:
solaredge_weekly_kwh_consumption 7.616
state_class: total_increasing
source: sensor.solaredge_consumption_energy_kwh
status: collecting
last_period: 2.947
meter_period: weekly
cron pattern: 0 0 * * 1
last_reset: 2022-08-21T22:00:00.038337+00:00
unit_of_measurement: kWh
device_class: energy
icon: mdi:counter
friendly_name: solaredge_weekly_kwh_consumption
solaredge_monthly_kwh_consumption 10.563
state_class: total_increasing
source: sensor.solaredge_consumption_energy_kwh
status: collecting
last_period: 0
meter_period: monthly
cron pattern: 0 0 1 * *
last_reset: 2022-08-21T11:22:27.310930+00:00
unit_of_measurement: kWh
device_class: energy
icon: mdi:counter
friendly_name: solaredge_monthly_kwh_consumption
Now, whenever the sensor "monthly_kwh_consumption" will reset to 0.00 - I would like to store its last value, together with the information of the month, example "August 2022 - VALUE"
either in a file, or in a Database table - or whatever else could be used...
With this information, I would like to create a dashboard in NodeRed, providing a statistics and history table with all these information.
Unfortunately, I don't know how I could acheive that the sensors value will be saved before it will be reseted.
And I don't know exactly, when HomeAssistant does reset the sensor (I only have the attributes & Information: "last reset" and "last_period" which does (as far as I understand) includes the sensors value from the last measurement period.