Glow / Hildebrand Display - Local MQTT Access - Template Help

Hildebrand have just released new firmware for their Glow consumer access device (CAD) and display which provides local MQTT access to smart meter data:
Glow — Local MQTT

As a newbie I would appreciate assistance in coding the sensors via templates (value_template) in configuration.yaml

The MQTT output from the Glow device:-

glow/F1A8D1ED18E7/SENSOR/electricitymeter
{
"electricitymeter": {
   "timestamp": "2022–06–01T16:32:16Z",
   "energy": {
     "export": {
       "cumulative": 0,
       "units": "kWh"
     },
     "import": {
       "cumulative": 201.95,
       "day": 1.05,
       "week": 0,
       "month": 0,
       "units": "kWh",
       "mpan": "9012224001407",
       "supplier": "— -",
       "price": {
         "unitrate": 0.20862,
         "standingcharge": 0.28403
       }
     }
  },
  "power": {
    "value": 0.063,
    "units": "kW"
  } 
 }
}

UPDATE 11 MAY 2026
I have cleansed this post and updated my entity setup instructions to make it a bit easier for everyone.

  • It has been a while since I looked at this and I have created these updated steps a really long time ago, but forgot to share.
  • Looking at the most recent way of me doing this, with the previous instructions, the entities unique IDs have changed, and if applied as such, it will cause a breaking change. You can deal with it in 2 ways
    • Change the entity ids in the script below to match your existing entities
    • Go ahead with the new script, migrate long term statistics to the new sensors (instructions are dependant on your DB engine), and delete the old entities from your configuration files.
    • You can find the old entity configurations at the bottom of this post if you need to compare side by side

INSTRUCTIONS

IHD
Start by setting up your MQTT details on the IHD. The settings steps can be seen in the video on this article https://medium.com/@joshua.cooper/glow-local-mqtt-f69b776b7af4

The instructions below are set for the default topic glow

Home Assistant Entities
Go to Settings -> Automations & Scenes -> Scripts -> Create script -> Create new script -> ... -> Edit in YAML

Use the following YAML file.

  • Replace ihd_id: REDACTED with your ID. You can either get it from your MQTT broker using something like MQTT Explorer, or direct from the IHD screen (Go to Wifi, note the mac address, remove the colons :)
  • Note the topic in the configuration. The new sensors are saved in homeassistant/sensor/IHD_ID and are based on data from glow/IHD_ID/
alias: Configure Glow IHD
variables:
  ihd_id: REDACTED
mode: single
icon: mdi:home-lightning-bolt-outline
sequence:
  - alias: "Electricity: Export"
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_electricity_export/config
      retain: true
      payload: |
        {
          "name":"Electricity: Export",
          "unique_id":"glow_ihd_smart_meter_electricity_export",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/electricitymeter",
          "device_class":"energy",
          "unit_of_measurement":"kWh",
          "state_class":"total_increasing",
          "value_template":"{{ "{{ value_json.electricitymeter.energy.export.cumulative }}" }}",
          "icon":"mdi:flash",
          "expire_after":"60",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Electricity: Import"
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_electricity_import/config
      retain: true
      payload: |
        {
          "name":"Electricity: Import",
          "unique_id":"glow_ihd_smart_meter_electricity_import",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/electricitymeter",
          "device_class":"energy",
          "unit_of_measurement":"kWh",
          "state_class":"total_increasing",
          "value_template":"{{ "{% if value_json.electricitymeter.energy.import.cumulative == 0 %}{{ states('sensor.smart_meter_electricity_import') }}{% else %}{{ value_json.electricitymeter.energy.import.cumulative }}{% endif %}" }}",
          "icon":"mdi:flash",
          "expire_after":"60",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Electricity: Import (Today)"
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_electricity_import_today/config
      retain: true
      payload: |
        {
          "name":"Electricity: Import (Today)",
          "unique_id":"glow_ihd_smart_meter_electricity_import_today",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/electricitymeter",
          "device_class":"energy",
          "unit_of_measurement":"kWh",
          "state_class":"total_increasing",
          "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 }}{% endif %}" }}",
          "icon":"mdi:flash",
          "expire_after":"60",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Electricity: Import (This week)"
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_electricity_import_week/config
      retain: true
      payload: |
        {
          "name":"Electricity: Import (This week)",
          "unique_id":"glow_ihd_smart_meter_electricity_import_week",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/electricitymeter",
          "device_class":"energy",
          "unit_of_measurement":"kWh",
          "state_class":"total_increasing",
          "value_template":"{{ "{{ value_json.electricitymeter.energy.import.week }}" }}",
          "icon":"mdi:flash",
          "expire_after":"60",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Electricity: Import (This month)"
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_electricity_import_month/config
      retain: true
      payload: |
        {
          "name":"Electricity: Import (This month)",
          "unique_id":"glow_ihd_smart_meter_electricity_import_month",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/electricitymeter",
          "device_class":"energy",
          "unit_of_measurement":"kWh",
          "state_class":"total_increasing",
          "value_template":"{{ "{{ value_json.electricitymeter.energy.import.month }}" }}",
          "icon":"mdi:flash",
          "expire_after":"60",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Electricity: Import Unit Rate"
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_electricity_import_unit_rate/config
      retain: true
      payload: |
        {
          "name":"Electricity: Import Unit Rate",
          "unique_id":"glow_ihd_smart_meter_electricity_import_unit_rate",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/electricitymeter",
          "device_class":"monetary",
          "unit_of_measurement":"GBP/kWh",
          "state_class":"total",
          "value_template":"{{ "{{ value_json.electricitymeter.energy.import.price.unitrate }}" }}",
          "icon":"mdi:cash",
          "expire_after":"60",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Electricity: Import Standing Charge"
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_electricity_import_standing_charge/config
      retain: true
      payload: |
        {
          "name":"Electricity: Import Standing Charge",
          "unique_id":"glow_ihd_smart_meter_electricity_import_standing_charge",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/electricitymeter",
          "device_class":"monetary",
          "unit_of_measurement":"GBP",
          "state_class":"total",
          "value_template":"{{ "{{ value_json.electricitymeter.energy.import.price.standingcharge }}" }}",
          "icon":"mdi:cash",
          "expire_after":"60",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Electricity: Power"
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_electricity_power/config
      retain: true
      payload: |
        {
          "name":"Electricity: Power",
          "unique_id":"glow_ihd_smart_meter_electricity_power",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/electricitymeter",
          "device_class":"power",
          "unit_of_measurement":"kW",
          "state_class":"measurement",
          "value_template":"{{ "{% if value_json['electricitymeter']['power']['value'] < 0 %}{{ states('sensor.smart_meter_electricity_power') }}{% else %}{{ value_json['electricitymeter']['power']['value'] }}{% endif %}" }}",
          "icon":"mdi:flash",
          "expire_after":"60",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Gas: Import"
    data:
      topic: homeassistant/sensor/{{ ihd_id }}/glow_ihd_smart_meter_gas_import/config
      retain: true
      payload: |
        {
          "name":"Gas: Import",
          "unique_id":"glow_ihd_smart_meter_gas_import",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/gasmeter",
          "device_class":"energy",
          "unit_of_measurement":"kWh",
          "state_class":"total_increasing",
          "value_template":"{{ "{% if value_json.gasmeter.energy.import.cumulative == 0 %}{{ states('sensor.smart_meter_gas_import') }}{% else %}{{ value_json.gasmeter.energy.import.cumulative }}{% endif %}" }}",
          "icon":"mdi:fire",
          "expire_after":"60",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Gas: Import (Today)"
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_gas_import_today/config
      retain: true
      payload: |
        {
          "name":"Gas: Import (Today)",
          "unique_id":"glow_ihd_smart_meter_gas_import_today",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/gasmeter",
          "device_class":"energy",
          "unit_of_measurement":"kWh",
          "state_class":"total_increasing",
          "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",
          "expire_after":"60",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Gas: Import (This week)"
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_gas_import_week/config
      retain: true
      payload: |
        {
          "name":"Gas: Import (This week)",
          "unique_id":"glow_ihd_smart_meter_gas_import_week",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/gasmeter",
          "device_class":"energy",
          "unit_of_measurement":"kWh",
          "state_class":"total_increasing",
          "value_template":"{{ "{{ value_json.gasmeter.energy.import.week }}" }}",
          "icon":"mdi:fire",
          "expire_after":"60",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Gas: Import (This month)"
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_gas_import_month/config
      retain: true
      payload: |
        {
          "name":"Gas: Import (This month)",
          "unique_id":"glow_ihd_smart_meter_gas_import_month",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/gasmeter",
          "device_class":"energy",
          "unit_of_measurement":"kWh",
          "state_class":"total_increasing",
          "value_template":"{{ "{{ value_json.gasmeter.energy.import.month }}" }}",
          "icon":"mdi:fire",
          "expire_after":"60",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Gas: Import Unit Rate"
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_gas_import_unit_rate/config
      retain: true
      payload: |
        {
          "name":"Gas: Import Unit Rate",
          "unique_id":"glow_ihd_smart_meter_gas_import_unit_rate",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/gasmeter",
          "device_class":"monetary",
          "unit_of_measurement":"GBP/kWh",
          "state_class":"total",
          "value_template":"{{ "{{ value_json.gasmeter.energy.import.price.unitrate }}" }}",
          "icon":"mdi:cash",
          "expire_after":"60",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Gas: Import Standing Charge"
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_gas_import_standing_charge/config
      retain: true
      payload: |
        {
          "name":"Gas: Import Standing Charge",
          "unique_id":"glow_ihd_smart_meter_gas_import_standing_charge",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/gasmeter",
          "device_class":"monetary",
          "unit_of_measurement":"GBP",
          "state_class":"total",
          "value_template":"{{ "{{ value_json.gasmeter.energy.import.price.standingcharge }}" }}",
          "icon":"mdi:cash",
          "expire_after":"60",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Electricity: Cost (Today)"
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_electricity_cost/config
      retain: true
      payload: |
        {
          "name":"Electricity: Cost (Today)",
          "unique_id":"glow_ihd_smart_meter_electricity_cost_today",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/electricitymeter",
          "device_class":"monetary",
          "unit_of_measurement":"GBP",
          "state_class":"total",
          "value_template":"{{ "{{ (states('sensor.glow_ihd_smart_meter_electricity_import_today') | float(0) * states('sensor.glow_ihd_smart_meter_electricity_import_unit_rate') | float(0) + states('sensor.glow_ihd_smart_meter_electricity_import_standing_charge') | float(0)) | round(2) }}" }}",
          "icon":"mdi:cash",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: "Gas: Cost (Today)"
    data:
      topic: homeassistant/sensor/{{ ihd_id }}/glow_ihd_smart_meter_gas_cost/config
      retain: true
      payload: |
        {
          "name":"Gas: Cost (Today)",
          "unique_id":"glow_ihd_smart_meter_gas_cost_today",
          "state_topic":"glow/{{ ihd_id }}/SENSOR/gasmeter",
          "device_class":"monetary",
          "unit_of_measurement":"GBP",
          "state_class":"total",
          "value_template":"{{ "{{ (states('sensor.glow_ihd_smart_meter_gas_import_today') | float(0) * states('sensor.glow_ihd_smart_meter_gas_import_unit_rate') | float(0) + states('sensor.glow_ihd_smart_meter_gas_import_standing_charge') | float(0)) | round(2) }}" }}",
          "icon":"mdi:cash",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: Software Version
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_software_version/config
      retain: true
      payload: |
        {
          "name":"Software Version",
          "unique_id":"glow_ihd_smart_meter_software_version",
          "state_topic":"glow/{{ ihd_id }}/STATE",
          "value_template":"{{ "{{ value_json.software }}" }}",
          "entity_category":"diagnostic",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: Hardware Version
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_hardware_version/config
      retain: true
      payload: |
        {
          "name":"Hardware Version",
          "unique_id":"glow_ihd_smart_meter_hardware_version",
          "state_topic":"glow/{{ ihd_id }}/STATE",
          "value_template":"{{ "{{ value_json.hardware }}" }}",
          "entity_category":"diagnostic",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: Smets Version
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_smets_version/config
      retain: true
      payload: |
        {
          "name":"Smets Version",
          "unique_id":"glow_ihd_smart_meter_smets_version",
          "state_topic":"glow/{{ ihd_id }}/STATE",
          "value_template":"{{ "{{ value_json.smetsversion }}" }}",
          "entity_category":"diagnostic",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: Zigbee Version
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_zigbee_version/config
      retain: true
      payload: |
        {
          "name":"Zigbee Version",
          "unique_id":"glow_ihd_smart_meter_zigbee_version",
          "state_topic":"glow/{{ ihd_id }}/STATE",
          "value_template":"{{ "{{ value_json.zigbee }}" }}",
          "entity_category":"diagnostic",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: Status
    data:
      topic: homeassistant/sensor/{{ ihd_id }}/glow_ihd_smart_meter_status/config
      retain: true
      payload: |
        {
          "name":"Status",
          "unique_id":"glow_ihd_smart_meter_status",
          "state_topic":"glow/{{ ihd_id }}/STATE",
          "value_template":"{{ "{{ value_json.han.status }}" }}",
          "entity_category":"diagnostic",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: WiFi Signal
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_wifi_signal/config
      retain: true
      payload: |
        {
          "name":"WiFi Signal",
          "unique_id":"glow_ihd_smart_meter_wifi_signal",
          "state_topic":"glow/{{ ihd_id }}/STATE",
          "state_class":"measurement",
          "value_template":"{{ "{{ value_json.han.rssi }}" }}",
          "entity_category":"diagnostic",
          "enabled_by_default":"false",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
  - alias: Zigbee Signal
    data:
      topic: >-
        homeassistant/sensor/{{ ihd_id
        }}/glow_ihd_smart_meter_zigbee_signal/config
      retain: true
      payload: |
        {
          "name":"Zigbee Signal",
          "unique_id":"glow_ihd_smart_meter_zigbee_signal",
          "state_topic":"glow/{{ ihd_id }}/STATE",
          "state_class":"measurement",
          "value_template":"{{ "{{ value_json.han.lqi }}" }}",
          "entity_category":"diagnostic",
          "enabled_by_default":"false",
          "device":{
            "identifiers":"{{ ihd_id }}",
            "name":"IHD Smart Meter",
            "model":"Glow",
            "manufacturer":"Hildebrand"}
        }
    action: mqtt.publish
description: ""

Save the script, then run it (... -> Run)

  • This will bring in all the relevant entities.
  • The entities are then grouped as 1 device.
  • You can keep the script for any future thinkering. If you change anything, you just need to Run the script again

Home Assistant Energy Dashboard

The entities we need to use are as follow:

NOTE: Some meters are reporting figures in MW, so the there will be a difference of a factor of 1000. If you are affected by that, here is a workaround for the cost entities:

"value_template":"{{ "{{ (states('sensor.glow_ihd_smart_meter_electricity_import_today') | float(0) * 1000 * states('sensor.glow_ihd_smart_meter_electricity_import_unit_rate') | float(0) + states('sensor.glow_ihd_smart_meter_electricity_import_standing_charge') | float(0)) | round(2) }}" }}",

Bonus Content

Did you know you can replicate the Energy dashboard in Lovelace, and then include your own other entities?

Old Configuration files
Ignore if you are a new user, only useful to existing users that need to possibly avoid a breaking change and need this for manually changing entity unique_ids.

mqtt:
  sensor:  
    - name: "Smart Meter Electricity: Export"
      unique_id: "smart_meter_electricity_export"
      state_topic: "glow/REDACTED/SENSOR/electricitymeter"
      device_class: "energy"
      unit_of_measurement: "kWh"
      state_class: "total_increasing"
      value_template: "{{ value_json['electricitymeter']['energy']['export']['cumulative'] }}"
      icon: "mdi:flash"
    - name: "Smart Meter Electricity: Import"
      unique_id: "smart_meter_electricity_import"
      state_topic: "glow/REDACTED/SENSOR/electricitymeter"
      device_class: "energy"
      unit_of_measurement: "kWh"
      state_class: "total_increasing"
      value_template: >
        {% if value_json['electricitymeter']['energy']['import']['cumulative'] == 0 %}
          {{ states('sensor.smart_meter_electricity_import') }}
        {% else %}
          {{ value_json['electricitymeter']['energy']['import']['cumulative'] }}
        {% endif %}
      icon: "mdi:flash"
    - name: "Smart Meter Electricity: Import (Today)"
      unique_id: "smart_meter_electricity_import_today"
      state_topic: "glow/REDACTED/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'] }}
        {% endif %}
      icon: "mdi:flash"
    - name: "Smart Meter Electricity: Import (This week)"
      unique_id: "smart_meter_electricity_import_week"
      state_topic: "glow/REDACTED/SENSOR/electricitymeter"
      device_class: "energy"
      unit_of_measurement: "kWh"
      state_class: "measurement"
      value_template: "{{ value_json['electricitymeter']['energy']['import']['week'] }}"
      icon: "mdi:flash"
    - name: "Smart Meter Electricity: Import (This month)"
      unique_id: "smart_meter_electricity_import_month"
      state_topic: "glow/REDACTED/SENSOR/electricitymeter"
      device_class: "energy"
      unit_of_measurement: "kWh"
      state_class: "measurement"
      value_template: "{{ value_json['electricitymeter']['energy']['import']['month'] }}"
      icon: "mdi:flash"
    - name: "Smart Meter Electricity: Import Unit Rate"
      unique_id: "smart_meter_electricity_import_unit_rate"
      state_topic: "glow/REDACTED/SENSOR/electricitymeter"
      device_class: "monetary"
      unit_of_measurement: "GBP/kWh"
      state_class: "measurement"
      value_template: "{{ value_json['electricitymeter']['energy']['import']['price']['unitrate'] }}"
      icon: "mdi:cash"
    - name: "Smart Meter Electricity: Import Standing Charge"
      unique_id: "smart_meter_electricity_import_standing_charge"
      state_topic: "glow/REDACTED/SENSOR/electricitymeter"
      device_class: "monetary"
      unit_of_measurement: "GBP"
      state_class: "measurement"
      value_template: "{{ value_json['electricitymeter']['energy']['import']['price']['standingcharge'] }}"
      icon: "mdi:cash"
    - name: "Smart Meter Electricity: Power"
      unique_id: "smart_meter_electricity_power"
      state_topic: "glow/REDACTED/SENSOR/electricitymeter"
      device_class: "power"
      unit_of_measurement: "kW"
      state_class: "measurement"
      value_template: >
        {% if value_json['electricitymeter']['power']['value'] < 0 %}
          {{ states('sensor.smart_meter_electricity_power') }}
        {% else %}
          {{ value_json['electricitymeter']['power']['value'] }}
        {% endif %}
      icon: "mdi:flash"
    - name: "Smart Meter Gas: Import"
      unique_id: "smart_meter_gas_import"
      state_topic: "glow/REDACTED/SENSOR/gasmeter"
      device_class: "energy"
      unit_of_measurement: "kWh"
      state_class: "total_increasing"
      value_template: >
        {% if value_json['gasmeter']['energy']['import']['cumulative'] == 0 %}
          {{ states('sensor.smart_meter_gas_import') }}
        {% else %}
          {{ value_json['gasmeter']['energy']['import']['cumulative'] }}
        {% endif %}
      icon: "mdi:fire"
    - name: "Smart Meter Gas: Import (Today)"
      unique_id: "smart_meter_gas_import_today"
      state_topic: "glow/REDACTED/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"
    - name: "Smart Meter Gas: Import (This week)"
      unique_id: "smart_meter_gas_import_week"
      state_topic: "glow/REDACTED/SENSOR/gasmeter"
      device_class: "energy"
      unit_of_measurement: "kWh"
      state_class: "measurement"
      value_template: "{{ value_json['gasmeter']['energy']['import']['week'] }}"
      icon: "mdi:fire"
    - name: "Smart Meter Gas: Import (This month)"
      unique_id: "smart_meter_gas_import_month"
      state_topic: "glow/REDACTED/SENSOR/gasmeter"
      device_class: "energy"
      unit_of_measurement: "kWh"
      state_class: "measurement"
      value_template: "{{ value_json['gasmeter']['energy']['import']['month'] }}"
      icon: "mdi:fire"
    - name: "Smart Meter Gas: Import Unit Rate"
      unique_id: "smart_meter_gas_import_unit_rate"
      state_topic: "glow/REDACTED/SENSOR/gasmeter"
      device_class: "monetary"
      unit_of_measurement: "GBP/kWh"
      state_class: "measurement"
      value_template: "{{ value_json['gasmeter']['energy']['import']['price']['unitrate'] }}"
      icon: "mdi:cash"
    - name: "Smart Meter Gas: Import Standing Charge"
      unique_id: "smart_meter_gas_import_standing_charge"
      state_topic: "glow/REDACTED/SENSOR/gasmeter"
      device_class: "monetary"
      unit_of_measurement: "GBP"
      state_class: "measurement"
      value_template: "{{ value_json['gasmeter']['energy']['import']['price']['standingcharge'] }}"
      icon: "mdi:cash"
template:
  sensor:
    # Energy Costs
    - name: "Smart Meter Electricity: Cost (Today)"
      unique_id: smart_meter_electricity_cost_today
      device_class: monetary
      unit_of_measurement: "GBP"
      state_class: "total_increasing"
      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) }}"
    - name: "Smart Meter Gas: Cost (Today)"
      unique_id: smart_meter_gas_cost_today
      device_class: monetary
      unit_of_measurement: "GBP"
      state_class: "total_increasing"
      icon: mdi:cash
      state: "{{ (
          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) }}"

Update above :slight_smile:

Although I currently use a combination of EM clamps and Glow cloud, I have been waiting for their non-display device in order to get local MQTT, so I really appreciate the time and effort put in to this post and have bookmarked it as my go to as and when I can get the new interface and plan to ditch the EM clamps. :+1:

You are welcome @rossk

Just to confirm, this is using the IHD (with display) and is a brand new feature. Given this information (but i have no inside knowledge) I do not think Hildebrand will launch the non-display local mqtt only device (is there any need at this point?). My understanding was that they were building that device in house, and they didn’t think they will add local mqtt to the Display version because of the size of the firmware stack. Now given that this was overcome, maybe they won’t continue with a build for a product that would have cost the end user the same, plus with the IHD you get a display for a quick “interactive” session.

Maybe I am wrong, but with the current situation, if I had to choose between local mqtt from IHD or new device, I would personally choose the IHD, cause it is classy, but also feels “old school” - e.g. parent friendly, anyone understands it, and the mqtt is just a “geek” bonus :slight_smile:

Good to know as well, may just order the CAD then now that it has local MQTT as that was the only reason I was hanging fire on it.

@robertalexa
That’s awesome Robert :clap:
Many thanks for the templates and for documenting the process so clearly.
That’s exactly what I was looking for :+1:

This is awesome - especially when I just bought the unit to realise the integration had been archived!

Ok really stupid question - when you say ‘Create the following entities in Home Assistant.’ How do I do this? Have tried creating through UI, but it doesn’t recognise the YAML code in card configuration. Do I create this in configuration.yaml?

Sorry for the silly question!

This is great work and helped me fix my older “remote” MQTT sensors. The only issue I have is that the cumulative gas reading is in kWh and not m3 therefore the current meter reading, which I record weekly in a meter app, is wrong. It could be converted but would never exactly match the live meter reading. I have to keep the remote mqtt sensor just for this reading for now, unless Hildebrand add that to their local mqtt feed.

@alphabeta279 Generally I create all my entities via the configuration.yaml, I think some of the entity types can nowadays be created via the UI, but meh.

If you do not have any other template or mqtt entities created previously, you can just copy that in as is. Otherwise, you will need to merge with your existing ones, so only copy the individual entities in your existing setup e.g.

    - name: "Smart Meter Electricity: Export"
      unique_id: "smart_meter_electricity_export"
      state_topic: "glow/REDACTED/SENSOR/electricitymeter"
      device_class: "energy"
      unit_of_measurement: "kWh"
      state_class: "total_increasing"
      value_template: "{{ value_json['electricitymeter']['energy']['export']['cumulative'] }}"
      icon: "mdi:flash"

@BertrumUK Hey Neil, unfortunately this is a limitation of the MQTT feed, I have exposed exactly what the feed makes available.

However, you can still do that, with a bit of research from your supplier bill. You could create extra template entities that convert from the local mqtt ones into m3.

The formula is m3 × Calorific Value × 1.02264 ÷ 3.6 = kWh and you can get the calorific value specific to your supply from your bill. As a proof of concept, you can try to use the Import entity value (cumulative = current meter reading), convert it to m3 and compare to the reading on your meter. Hope this helps you achieve your desired result. Happy to help if you need me

I’ve posted the request on their forum page, will give your formula a go in NR and compare it to the live readings I have.

Great work on your post BTW :grinning:

Just updated my post in an attempt to avoid a possible issue with the Cumulative Import. Explanation can be found in the post at the top. Code is already updated.

Another update to the post fixing the device class for smart_meter_electricity_power and smart_meter_gas_power. More details in the post

Perfect - thank you, will give it a shot tonight then, should be relatively simple (apart from my lifelong mission to slap the person who invented yaml, hate the daft indents with a passion!)

I’d really like to get the IHD to take advantage of the local MQTT, however before I take the plunge I wondered whether the MQTT feed includes the running cost in £ for the day? I am on the octopus Smart EV tariff where the kwh rate changes at night, so if this isn’t included in the feed, how would I calculate the running cost? Cheers.

I am experiencing occasional (approx 1 - 2 per day) huge negative spikes in the local MQTT electricity power readings. Since I don’t have solar Jane from Hildebrand thinks the readings might be the result of a sporadic issue with my electricity meter (SMETS1). I will chase the energy supplier (ScottishPower) but I suspect that they won’t be interested unless it starts to impact their ability to remotely read the meter.

Unfortunately because of the magnitude these negative spikes are completely masking all the other readings:
Screenshot 2022-06-09 145642
Interestingly the negative spikes appear to be all the same value (-8,388.61 kW).

Naturally it would be best to resolve the spurious readings ‘at source’ but in the meantime I would appreciate any thoughts on how to avoid logging them in HA?

Hey @JohnWH

Have a look at the entities above, in particular the Import ones, and notice how I have done a template to avoid saving the value if it is == to 0.

I would suggest you do sth similar for the power entities. So if the value is less than 0 than use the previous value instead. It is a bit hacky, but it will keep you much closer to the truth than your current ituation. Here is the value_template for the power entity:

value_template: >
  {% if value_json['electricitymeter']['power']['value'] < 0 %}
    {{ states('sensor.smart_meter_electricity_power') }}
  {% else %}
    {{ value_json['electricitymeter']['power']['value'] }}
  {% endif %}

@saltinesurfer the IHD does not provide a running cost in the feed, this is something i had to calculate manually via the template entities from the unit rates, standing charge and unit total. I do not have a dual tariff, and I can’t guarantee the IHD will provide that. Best bet is to email Hildebrand, Jane is lovely and she will be able to advise. If the IHD provides extra information for people on dual tariff, then I am sure we can make it work somehow. e.g. if we know the unit price, and the time interval, we can achieve that (i think). Might actually be able to do that manually as a test by hardcoding the the unit prices. Unfortunately I am due to going away for the next 4 weeks, so I won’t be around to help.

@robertalexa im not getting any data in HA? but im also getting an error in my energy dashboard settings

ELEC: Last Reset missing - the following entities have state class ‘measurement’ but ‘last_reset’ is missing: sensor.smart_meter_electricity_import_today

GAS: Last Reset missing - the following entities have state class ‘measurement’ but ‘last_reset’ is missing: sensor.smart_meter_gas_import_today

Are the entities that you have created been populated with values (the entities, not the Energy dashboard).

If not, start by checking that your IHD is sending data to MQTT and the topic it is doing it on. By default on the IHD the topic is glow. You can see that in the entities as well. If you have changed that, make sure to update the topics for the entities.

Also, make sure you have replaced the word REDACTED with the actual Device ID for your IHD.

Let me know how that goes.

PS: there is a tool called MQTT Explorer that you can use to check what topics and messages are received by your MQTT server. This way you can confirm seeing traffic and on what topics.

Hi @robertalexa
That’s an excellent suggestion.

I’ve substituted the code (above) into my configuration file. Minor point if anyone else uses it - the 5th line should read ‘electricitymeter’ not ‘electricity’

As a newbie (especially to templating) your help has been so invaluable - thank you very much!
Safe travels.