homeassistant-eloverblik
homeassistant-eloverblik copied to clipboard
Feature: Add sensor for hourly data
There are sensors right now for the last days usage, and the last 24 hours (individual sensors). Maybe add one that shows for the current hour (~24 hours ago, whatever delay Eloverblik has), which is updated hourly?
I will consider adding such a sensor.
Can a template sensor not be used as a workaround?
I suppose a very long template could make do, or one fetching by name (where name includes current hour).... and then a cron/automation to update it each hour?
I got this which is working except that the real datetime is hidden in an attribute and I've not found any graph that can display the data based of the attributes
sensor:
- platform: template
sensors:
preceding_day_energy_usage:
unit_of_measurement: "kWh"
friendly_name: Eloverblik Energy
entity_id: group.eloverblik_energy
value_template: >-
{% set hour = now().hour %}
{% set sensor = ['sensor.eloverblik_energy', hour, hour+1] | join('_') %}
{{ states(sensor) }}
attribute_templates:
metering_start: >-
{% set hour = now().hour %}
{% set sensor = ['sensor.eloverblik_energy', hour, hour+1] | join('_') %}
{% set datetimestr = [state_attr(sensor, 'Metering date'),'T', hour] | join('') %}
{{ strptime(datetimestr, '%Y-%m-%dT%H') }}
metering_end: >-
{% set hour = now().hour %}
{% set sensor = ['sensor.eloverblik_energy', hour, hour+1] | join('_') %}
{% set datetimestr = [state_attr(sensor, 'Metering date'),'T', hour, ':59', ':59'] | join('') %}
{{ strptime(datetimestr, '%Y-%m-%dT%H:%M:%S') }}
group:
eloverblik_energy:
entities:
- sensor.eloverblik_energy_0_1
- sensor.eloverblik_energy_1_2
- sensor.eloverblik_energy_2_3
- sensor.eloverblik_energy_3_4
- sensor.eloverblik_energy_4_5
- sensor.eloverblik_energy_5_6
- sensor.eloverblik_energy_6_7
- sensor.eloverblik_energy_7_8
- sensor.eloverblik_energy_8_9
- sensor.eloverblik_energy_9_10
- sensor.eloverblik_energy_10_11
- sensor.eloverblik_energy_11_12
- sensor.eloverblik_energy_12_13
- sensor.eloverblik_energy_13_14
- sensor.eloverblik_energy_14_15
- sensor.eloverblik_energy_15_16
- sensor.eloverblik_energy_16_17
- sensor.eloverblik_energy_17_18
- sensor.eloverblik_energy_18_19
- sensor.eloverblik_energy_19_20
- sensor.eloverblik_energy_20_21
- sensor.eloverblik_energy_21_22
- sensor.eloverblik_energy_22_23
- sensor.eloverblik_energy_23_24
automation:
- alias: "Opdater Eloverblik sensor"
id: update_eloverblik_sensor
trigger:
- platform: time_pattern
minutes: '/60'
action:
- service: homeassistant.update_entity
entity_id: sensor.preceding_day_energy_usage
So, I am a NooB here... but I am trying to get the data from the sensors to show in Grafana, but that dosn't work because there is no time on the sensor, only a date... so i cannot compare my energy consumption whit the hourly energy prices - does this solve this problem and add's a time attribute to the sensor?
Hi @slimcdk
Nice work.
How do you compensate for the value of sensor.preceding_day_energy_usage is two days old in your view graph?
The meterdate is the 12-09-2022 but the value will be logged in the history for sensor.preceding_day_energy_usage for today the 14-09-2022.
So if look at the graph in some days it will show the value metered the 12-09 on the graph as 14-09.
That is unfortunately a downside of HA. HA only works with realtime data as there is no option to manipulate the timestamp of data. Timestamps in attributes can however be used to display the correct date on graphs (ex Apexchart) but can not be used in the energy logging.
@slimcdk Thanks for pointing me to Apexcharts. Its awesome.
But i can´t figure out to replace the attribute data,
`type: custom:apexcharts-card graph_span: 24h now: show: true label: nu header: title: El forbrug pr time show: true show_states: true series:
- entity: sensor.preceding_day_energy_usage type: column name: Forbrug float_precision: 2 group_by: func: avg duration: 60min`
Where it would be best to replace the data in the legend with:
{{ state_attr('sensor.preceding_day_energy_usage', 'metering_start')}}
Or replace "name: xxxx" with that attribute.
How did you solve it?
There hasn't been any activity on this issue recently. Issue will be marked as stale and closed after 7 days without any activity.