Hello,
Please excuse me if I am posting in the wrong group/category or if I am posing a question that has already been answered. However, despite searching through the forum and experimenting with what I have found, I still need some help.
Home Assistant is running nicely on a Rasperry Pi 4 Model B (4GB) in my basement which is connected via Ethernet to my home LAN. Each of my two smart electricity meters–one for “high tariff” and one for “low tariff”–is fitted with a Tasmota/Wi-Fi enabled infra-red reading head. The IR heads provide current or actual power usage [W] and accumulated energy consumption [kWh] in the form of MQTT telegrams to HA via my wireless LAN.
Using one or more useful guides, I have adapted /config/configuration.yaml as shown below:
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
template:
- sensor:
- name: "HT Consumption"
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
state: >
{% if states('sensor.electricity_ht_energy_in_kwh') == 'unavailable' or states('sensor.electricity_ht_energy_in_kwh') < '1' %}
{{ states('sensor.ht_consumption') }}
{% else %}
{{ states('sensor.electricity_ht_energy_in_kwh') }}
{% endif %}
- sensor:
- name: "NT Consumption"
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
state: >
{% if states('sensor.electricity_nt_energy_in_kwh') == 'unavailable' or states('sensor.electricity_nt_energy_in_kwh') < '1' %}
{{ states('sensor.nt_consumption') }}
{% else %}
{{ states('sensor.electricity_nt_energy_in_kwh') }}
{% endif %}
- sensor:
- name: "HT Power"
unit_of_measurement: W
state_class: measurement
device_class: power
state: >
{% if states('sensor.electricity_ht_power_now_w') == 'unavailable' or states('sensor.electricity_ht_power_now_w') < '1' %}
{{ states('sensor.ht_power') }}
{% else %}
{{ states('sensor.electricity_ht_power_in_w') }}
{% endif %}
- sensor:
- name: "NT Power"
unit_of_measurement: W
state_class: measurement
device_class: power
state: >
{% if states('sensor.electricity_nt_power_now_w') == 'unavailable' or states('sensor.electricity_nt_power_now_w') < '1' %}
{{ states('sensor.nt_power') }}
{% else %}
{{ states('sensor.electricity_nt_power_in_w') }}
{% endif %}
- sensor:
- platform: integration
source: sensor.electricity_nt_power_now_w
name: nt_energy_consumed
unit_prefix: k
round: 2
- sensor:
- platform: integration
source: sensor.electricity_ht_power_now_w
name: ht_energy_consumed
unit_prefix: k
round: 2
I am not sure if all of the code is needed and therefore any redaction hints would be appreciated.
The script has enabled the Energy dashboard to “recognise” the meters and I have thus successfully collected electrical energy consumption data for a number of days.
In addition to the energy consumption per day, I would also like to see the energy consumption per hour. However, as my “metering system” is reporting with a granularity of 1 kWh, the histogram is limited to this resolution as shown below:
Presumably instead of using energy consumption in kWh, I need to work with W or kW and perform some form of integration. However, I am struggling (more to the point, failing) to prepare the appropriate script and/or integration so that I may visualise the data in the Energy dashboard.
All and any help, suggestions and pointers would be very much appreciated.
Thanks in advance,
Cystrinity