rs443
December 28, 2022, 4:10pm
1
I used the energy dashboard for some time now so I collected data for a year.
Is it possible to create a sensor to compare the energy usage this month to the same month last year?
For example, this december I have used 1000kWh until today,1-28 dec.
Last year I used 2000kWh from 1-28 dec.
This means i used -50% less energy.
Is this possible to create a sensor like that?
I have 14 months energy data and 10 days history data.
sassetto
(Sassetto)
December 10, 2024, 11:28am
2
Very interesting, do you know if anything has been done?
rs443:
I used the energy dashboard for some time now so I collected data for a year.
ZYN Rewards
Is it possible to create a sensor to compare the energy usage this month to the same month last year?
For example, this december I have used 1000kWh until today,1-28 dec.
Last year I used 2000kWh from 1-28 dec.
This means i used -50% less energy.
Is this possible to create a sensor like that?
I have 14 months energy data and 10 days history data.
To compare energy usage, extract data from your energy dashboard. Use spreadsheet software or programming languages like Python to analyze and visualize the data. If your dashboard integrates with a home automation system, you might be able to create custom sensors for comparison. Ensure data accuracy and consider normalization for better analysis.
rs443
December 11, 2024, 4:10pm
4
I ended up exporting the daily energy usage to a textfile:
automation:
- alias: Slimmelezer daily export
initial_state: 'on'
trigger:
- platform: time
at: '23:59:55'
action:
- service: notify.send_message
target:
entity_id: notify.slimmelezer_daily
data:
message: "{{ states('sensor.slimmelezer_daily_energy_utility') |round(1) }}"
Setting up sensors to calculate energy usage this month and the same month last year:
command_line:
- sensor:
name: slimmelezer_month
# Todays day of the month
command: grep -v "//" /config/slimmelezer/slimmelezer_daily.log | tail -n $(($(date +%e) - 1)) | awk -F '|' '{sum += int(100 * $1) / 100} END {printf "%.0f\n", sum}'
unit_of_measurement: "kWh"
scan_interval: 600
- sensor:
name: slimmelezer_lastyearmonth
# The same month last year
command: grep -v "//" /config/slimmelezer/slimmelezer_daily.log | tail -n $(($(date +%e) - 1 + 365)) | head -n $(($(date +%e) - 1)) | awk -F '|' '{sum += int(100 * $1) / 100} END {printf "%.0f\n", sum}'
unit_of_measurement: "kWh"
scan_interval: 600
Custom sensor to compare the two, plus a forecast.
sensor:
- platform: template
sensors:
slimmelezer_stats:
value_template: "{{ states('sensor.slimmelezer_daily_energy_utility')}}"
attribute_templates:
compare_yearmonth: "{{ (100*((states('sensor.slimmelezer_month')|int / states('sensor.slimmelezer_lastyearmonth')|int)-1))|round(1) }}"
forecast_1m: "{{ (states('sensor.slimmelezer_month')|int / (now().day-1) * (31 if now().month == 12 else (now().replace(month=now().month+1, day=1) - timedelta(days=1)).day))|int }}"
Not pretty but it works flawlessly. The textfile needs to have at least 13 months of data.