Glow / Hildebrand Display - Local MQTT Access - Template Help

@robertalexa
Right from when I first requested help in templating the local MQTT feed your input into this topic has been invaluable. As such I, for one, would really welcome a properly maintained HACS integration.

Thanks for the kind words. I would truly like to do that too, but my spare time is really limited at the moment. Will do my best to find some time sooner rather than later

Thanks @robertalexa I will ask on his repo page and see what happens.

Look forward to any HACS install you may offer in the future because whilst I enjoy reading what has been written I’m still very much working my way through all of this and a custom repo helped a lot.

I’ve been trying to do a calculated export since my provider is one of those that doesn’t set the field in the smart meter (also the prices are way off, but that’s something I’ll take up with them sometime).

The plan was to first take negative import to create an export:

  - name: "Smart Meter Electricity: Export Power"
    unique_id: smart_meter_electricity_export_power
    device_class: power
    unit_of_measurement: "kW"
    state_class: "measurement"
    icon: mdi:flash
    state: >
      {% set value = states('sensor.smart_meter_electricity_power') | float %}
      {{ -value if value < 0 else 0 }}

Then convert this to a total in the sensors.yaml:

- platform: integration
  source: sensor.smart_meter_electricity_export_power
  name: "Smart Meter Electricity: Export (Calculated)"
  unique_id: smart_meter_electricty_export_calculated
  unit_prefix: k
  round: 2
  method: left

The problem is smart_meter_electricity_export_power never appears in the entity list, so I can’t tell if it’s working - there are no errors in the logs. The second one does appear so it has recognised the entity exists otherwise it’d fail on the source line… So there’s likely an error there but it’s not showing up anywhere.

Alas testing is somewhat unreliable as it’s winter… I might get some export tomorrow or maybe not for weeks depending on the weather.

@robertalexa I’m relatively new to HA but I’d also like to offer my thanks for what you and others have done here. I found it invaluable in bootstrapping me into getting my Glow IHD working with MQTT.

Similar to some of the other posters, I too am having funny Smart Meter Gas: Import (Today) readings, but I’m checking those out at present with a Debug entry and also a Utility Meter Helper setup. I’ll decide which way to jump in a couple of days once I collect a few days more data.

I exchanged a couple of emails with Hildebrand Support a few weeks ago over a different subject, and they hinted that they are considering releasing their own HA Integration for the Glow IHD, as they are aware there are several offerings about and support for them seems to be patchy. Whether this might be a DCC or Local MQTT integration, whether it will be HACS or their own repo, I have no idea. I did tell them that I thought the community would welcome such a move, so I hope I haven’t trodden on anyones toes!
Regards

@Tech49 Glad you found this useful. Let me know how your debugging goes and if you think i can help in any way!

As to Hildebrand doing their own integration, that would be absolutely epic on their side and I will 100% support them in that direction. As much as I am a big fan of open source and community written pieces of code, knowing that you have the same team of people that develop the physical device do the software integration as well means they can syncronise releases, there should be no unexpected changes, no fires to put out in a rush. So if they go that direction, I can only applaud the effort, of course for as long as they actually look after their product - we all know there are brands out there who did something and then it became a forgotten thing. Of course I can’t speak on behalf of the team of guys looking after the DCC integration, but i am sure they would be happy to see their original implementation be re-used for the greater benefit of the community :slight_smile:

@robertalexa Thank you for your very positive reply. It’s obvious, even to me, from reading this thread, that the way that Smart Electricity and Gas Meters seem to be rolled out here in the UK at least, is far from ideal, with each meter brand/energy supplier seemingly doing their own thing when it comes to local MQTT integrations. How Hildebrand would deal with this diversity might well be a factor in any decision they come to. But Smart Homes with reatime data are here to stay, and there’s an opportunity for someone to establish a market lead. I’ll certainly be having a conversation with Octopus as to why they didn’t offer me an IHD with CAD instead of the one that now sits in a box in the loft

I had similar issues. I now use the lifetime cumulative values from the Glow IHD as state_class : total_increasing and let the Energy Dashboard sort it out. The daily kWh readings for both electricity and gas in HA now much my IHD to a tiny fraction of a kWh, which is good enough for me.

Mine broke too, unsurprisingly. Gas consumption still worked but the fudge I built to add the standing charge broke. Poking around in Energy Dashboard only broke it more! Your post reminded me that I could restore .storage/energy from a backup so I’ve got most of it back - thanks!

2022-11-18 00:00:00.018 ERROR (MainThread) [homeassistant.helpers.event] Error while processing state change for sensor.gas_standing_charge
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 71, in convert
from_ratio = cls._UNIT_CONVERSION[from_unit]
KeyError: 'Wh'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 284, in _async_state_change_dispatcher
hass.async_run_hass_job(job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 573, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/energy/sensor.py", line 424, in async_state_changed_listener
self._update_cost()
File "/usr/src/homeassistant/homeassistant/components/energy/sensor.py", line 390, in _update_cost
converted_energy_price = converter(
File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 73, in convert
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Wh is not a recognized volume unit.
1 Like

MQTT Gas readings continued to act up, so after reading about it here, Utility Meters based off Cumulative values was the approach I also adopted. For consistency, I created Today, This Week and This Month UMs for both Gas and Electricity (see screenshot) and used the Today values in the templates.yaml entries to calculate the Gas/Elec Cost Today, which I then used in the Energy Dashboard .
As a point of interest, the Glow IHD seems to add the Gas Standing Charge just after midnight, but not clear if/when the Electricity Standing Charge is added. I assume it’s the Meters doing this not the IHD, which just displays what it’s given

That is actually super cool. I shall look into it at my end and then possibly update the guide. The more people that can use this problem free the better.

As to the standing charge, my ihd shows just the charge as soon as it gets tbe first uldate from the meter, of course with or without extra cost based on energy consumption. So your issue might be from the meter to ihd

Whoops! I posted a slightly out-of-date screenshot of the Utility Meter setup, so here’s the right one. I’m sure you would have realised, but I’ll correct it for the benefit of others

Followed the guide and code and when trying to add the Gas to the Energy dashboard I keep meeting this error. Any advice?

Read that and the next post. It is a bug in HA currently

1 Like

Hi, I was wondering if its possile to create some kind of graph that shows the updated usage (in kwh and or £) as often as it’s gathered from the IHD, every 6s or so. Looks like I’m only getting updates every 30mins for Electricity (I know this is the limitation for gas so not too bothered about that)

Thanks!

This is already happening. All the entities get the value exactly as you want it.
image

In my case it writes a new value roughly every 5 seconds

Struggling to get to the HA file: .storage/energy - is this in the file editor?

Because I do not know your setup I can’t give you precise info. Have a look at this thread. You will need a different way to access it, either SSH, terminal, VSCode (you need to remove .storage from excluded paths)

Thanks for the reply, after playing around I can see that the power and import are being provided every 6 seconds, but my cost is updating much less frequently:

I’ve got the same British Gas x L+G issue of reporting everything /1000 so added *1000 to the template (pending a meter firmware update - I’ll let everyone know if it happens after the 2 weeks I’ve been told it’ll take)

I’m using MQTT only and not the HACs repo

Any tips?

Costs are also instantaneous but rely on actual consumption for changes. It will basically update as often smart_meter_electricity_import_today does with the only caveat that the Cost Today is rounded to 2 decimals, so because the rounding might be the same value as the previous one, it may “appear” like it takes longer to update.

Your screenshot is a bit weird though, mine seems to update around 5-6 seconds. I have zoomed in a lot so you can see how often the graph is updated

Try to debug your values starting from smart_meter_electricity_import_today. If that updates slowly, then the cost will also update slowly. Then try to figure out why it updates slowly. e.g. is your mqtt connection stable, listen to the mqtt topic and see how often it updates. if that is also sporadic, then go one layer deeper into the onion :slight_smile: is the ihd dropping from your network, if that is not a problem, continuouly monitor the costs on your IHD, do they update sporadicaly.

Unfortunately the situation you are describing is not a limitation of my implementation, but rather sth at your end. Happy to try and assist you, but I might have limited feedback. The implementation works exactly as you described you want it to work :slight_smile: