It is well worth the effort. There is no need to go too complicated with javascript etc with it, just basic automations are easy once you get the hang of them, and once you get 1 working it is easy to copy/paste a new automation.
Anyone having issues with the energy dashboard? It’s showing the wrong numbers for me. I followed the post from Robert A above and everything else is sound.
Here’s a screenshot of everything:
The costs in the energy dashboard are nearly twice as much as what’s reported via the actual sensor. Energy usage data is close but also wrong in the dashboard. I guess with the energy usage sensor it’s using the main import sensors not the daily usage ones so I understand if the maths is a bit off there, but the price shouldn’t be
You need to use the import (daily) and not the total usage on the dashboard.
The sources and the readings on the panel below have a bit of difference as the sources will update at the full hour.
ok interesting thanks, will give that a go for a bit and see how it reports
Hey @robertalexa the setup has been working fine for months, then suddenly stopped in the early hours of the morning.
I’ve added your latest mqtt & template definitions, updated the REDACTED bits with those that match my system to see if some config had become corrupt.
I’ve done a config check in Dev tools and all passes, but on restart of HA I see a few errors in the logs relating to the template definition (see below) Any idea what’s causing this?
Source: helpers/template_entity.py:364
First occurred: 8:08:27 PM (2 occurrences)
Last logged: 8:08:27 PM
TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ ( states('sensor.smart_meter_electricity_import_today') | float * states('sensor.smart_meter_electricity_import_unit_rate') | float + states('sensor.smart_meter_electricity_import_standing_charge') | float ) | round(2) }}' but no default was specified') while processing template 'Template("{{ ( states('sensor.smart_meter_electricity_import_today') | float * states('sensor.smart_meter_electricity_import_unit_rate') | float + states('sensor.smart_meter_electricity_import_standing_charge') | float ) | round(2) }}")' for attribute '_attr_native_value' in entity 'sensor.smart_meter_electricity_cost_today'
TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ ( states('sensor.smart_meter_gas_import_today') | float * states('sensor.smart_meter_gas_import_unit_rate') | float + states('sensor.smart_meter_gas_import_standing_charge') | float ) | round(2) }}' but no default was specified') while processing template 'Template("{{ ( states('sensor.smart_meter_gas_import_today') | float * states('sensor.smart_meter_gas_import_unit_rate') | float + states('sensor.smart_meter_gas_import_standing_charge') | float ) | round(2) }}")' for attribute '_attr_native_value' in entity 'sensor.smart_meter_gas_cost_today'
Think I’ve fixed it. It looks like MQTT integration from Glow had fallen over for some reason
@robertalexa just setup my new IHD with MQTT and followed your guide and everything worked first time! Thanks very much for creating such an easy way to set this up. Much appreciated.
I am also having a similar issue but I think the cause is different. My issue is that gas usage being recorded per day isnt being zero’d properly at the start of each day. I am unsure if this is an issue with MQTT data being sent from the CAD Display or with the template sensor.
Below is the entity graph for gas use over the last few days, as you can see the value drops but then immediately returns to yesterdays highest reading, this then sorts itself out by about 6-7am but by that point the usage is already skewed as it is taking wrong information to start the calculations off with.
Has anyone else encountered this? Electricity usage seems fine. Ultimately the usage data is right its just that the daily reset doesn’t happen properly.
The mqtt sensor is exactly as provided above:
unique_id: "smart_meter_gas_import_today"
state_topic: "glow/XXXXXXXXXXX/SENSOR/gasmeter"
device_class: "energy"
unit_of_measurement: "kWh"
state_class: "measurement"
value_template: >
{% if value_json['gasmeter']['energy']['import']['day'] == 0
and now() > now().replace(hour=0).replace(minute=1).replace(second=0).replace(microsecond=0) %}
{{ states('sensor.smart_meter_gas_import_today') }}
{% else %}
{{ value_json['gasmeter']['energy']['import']['day'] }}
{% endif %}
icon: "mdi:fire"
I have just done a more thorough look of the posts in this thread (there are a lot) and noticed that this was discovered tail end of last year. I have now implemented this additional sensor to see how it works as listed in this post. I will report back if this resolves my issue. Great work everyone, loving all this local data!
I’ve managed to calculate costs for my peak/off-peak Intelligent Octopus electricity supply, with the help of this guide: https://community.home-assistant.io/t/simulating-different-tou-electricity-plans-with-utility-meter-automations-and-templates/494374.
First I created a daily utility meter with named “peak” and “off-peak” tariffs based on today’s import from MQTT, named “Electricity Used”.
Then, I created an automation to set the tariff to either “peak” or “off-peak”, using the binary sensor from the IO HACS integration (alternatively, I could have based it on the time):
alias: Update Octopus Tariffs
description: ""
trigger:
- type: turned_on
platform: device
device_id: XXX
entity_id: binary_sensor.octopus_intelligent_slot
domain: binary_sensor
variables:
tariff: off-peak
- type: turned_off
platform: device
device_id: XXX
entity_id: binary_sensor.octopus_intelligent_slot
domain: binary_sensor
variables:
tariff: peak
condition: []
action:
- service: select.select_option
data:
option: "{{ tariff }}"
target:
entity_id: select.electricity_used
mode: single
This creates and fills two daily “buckets” for peak and off-peak energy used.
Finally, I used a template sensor to calculate the daily cost:
template:
- sensor:
- name: Daily Electricity cost
state_class: total_increasing
device_class: monetary
unit_of_measurement: GBP
icon: mdi:currency-gbp
state: >
{% set peak_cost = states('sensor.electricity_used_peak')|float * 0.429 %}
{% set off_peak_cost = states('sensor.electricity_used_off_peak')|float * 0.10 %}
{{ (peak_cost + off_peak_cost + 0.5109) | round(2) }}
I could have fetched the current rates and daily charge from the octo API, but they’re just hardcoded for the moment.
Hopefully this is useful to someone else.
Tim
Hi, I know this is an ages old message, but I did the multiplication in the import today (same thing for month and week), not the cost, so that figure is also correct.
For example :-
- name: "Smart Meter Electricity: Import (Today)"
unique_id: "smart_meter_electricity_import_today"
state_topic: "glow/441793525B28/SENSOR/electricitymeter"
device_class: "energy"
unit_of_measurement: "kWh"
state_class: "measurement"
value_template: >
{% if value_json['electricitymeter']['energy']['import']['day'] == 0
and now() > now().replace(hour=0).replace(minute=1).replace(second=0).replace(microsecond=0) %}
{{ states('sensor.smart_meter_electricity_import_today') }}
{% else %}
{{ (value_json['electricitymeter']['energy']['import']['day'] * 1000) }}
{% endif %}
icon: "mdi:flash"
Awesome work!
Tip: If you want all the MQTT data to show up under a single device (so all the entities are “related”), you can append the following to the MQTT configuration for each sensor:
device:
identifiers: REDACTED
manufacturer: GLOW
name: Glow IHD
model: Display and CAD SMETS2
so, for the live consumption data:
- state_topic: "glow/REDACTED/SENSOR/electricitymeter"
name: GLOW Electricity current consumption
unique_id: glow_elec_current_consumption
device_class: power
state_class: measurement
icon: mdi:meter-electric
expire_after: 120
value_template: "{{ value_json.electricitymeter.power.value }}"
unit_of_measurement: kW
availability:
topic: "glow/REDACTED/STATE"
value_template: "{{ value_json.han.status }}"
payload_available: joined
device:
identifiers: REDACTED
manufacturer: GLOW
name: Glow IHD
model: Display and CAD SMETS2
have also added availability checking and an expire after in case the device disconnects
Anyone else have issues creating the dashboard in Lovelace ? I get the error No card type found
amazing blueprint!
any chance you could edit it and create a device for the smart monitor itself to display the signal strength etc?
{
"software": "v1.8.13",
"timestamp": "2023-03-27T11:13:28Z",
"hardware": "GLOW-IHD-01-1v4-SMETS2",
"wifistamac": "4417935049C8",
"ethmac": "4417935049CB",
"smetsversion": "SMETS2",
"eui": "70:B3:D5:21:E0:00:E4:73",
"zigbee": "1.2.5",
"han": {
"rssi": -55,
"status": "joined",
"lqi": 180
}
}
EDIT: managed to work it out myself!
I have edited it to include RSSI, LQI and Status. Actually turns out my IHD dropped offline a week or so ago and I never noticed so this is pretty useful as I can ping myself a message if that happens again. (Energy graph currently showing I have used 300 kWh today…)
I will refine it at some point as it has LQI as being measured in db and the RSSI and LQI values should probably both be in diagnostic section
cheers thank you! just one spelling mistake line 336 Staus
should be Status
hehe
Thanks for the awesome work on this, I just deployed the blueprint to my instance last night. I have one slight issue, I only receive the “unavailable” state the the 2 cost sensors
> sensor.smart_meter_electricity_import_today_cost
> sensor.smart_meter_gas_import_today_cost
Are you able to provide any trouble shooting steps to get this working?
Hey - has anyone worked out how to create a sensor that can calculate the electric cost from the MQTT data when you have solar panels?
Have tried the below but because the solar panels also push power back to the grid, when the MQTT sensor has negative values (e.g. -400w) it subtracts from the sensor.
Need an ‘if negative value ignore’ logic in there but can’t work out how to add that?
- sensor:
- name: "Local Smart Meter Electricity: Current Cost"
unique_id: smart_meter_electricity_current_cost
device_class: monetary
unit_of_measurement: "GBP"
state_class: "total_increasing"
icon: mdi:cash
state: "{{ (
states('sensor.smart_meter_electricity_power') | float
/ 1000
* states('input_number.octopus_go') | float
) | round(2) }}"
maybe I should RTFM before posting
To follow up on this, I managed to resolve the warnings in the log by changing the state class to total
and explicitly setting the last_reset
to fix the negative cost values:
template:
sensor:
- name: "Smart Meter Electricity: Cost (Today)"
unique_id: smart_meter_electricity_cost_today
device_class: "monetary"
state_class: "total" # requires "last_reset" for use to track costs in energy dashboard
unit_of_measurement: "GBP"
icon: mdi:cash
state: "{{ (
states('sensor.smart_meter_electricity_import_today') | float
* states('sensor.smart_meter_electricity_import_unit_rate') | float
+ states('sensor.smart_meter_electricity_import_standing_charge') | float
) | round(2) }}"
attributes:
last_reset: "{{ today_at('00:00') }}" # required for use as "total" in energy dashboard
On why total
is the right “state class” (rather than total_increasing
), see the related discussion here: