Glow / Hildebrand Display - Local MQTT Access - Template Help

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) }}"