Glow / Hildebrand Display - Local MQTT Access - Template Help

Hi James,

Many thanks to you and Robert for all the hard work on this.

I’m on Octopus Go i.e. two separate time based tariffs + standing charge.

If I set the energy dashboard to use an entity tracking total costs and use Smart Meter Electricity: Cost (Today) my electricity costs are overestimated as at the 04:30 switch over the peak rate is applied to electricity that I used during the 00:30 to 04:30 off peak period.

I can sort of get around this by using Smart Meter Electricity: Import Unit Rate as an entity with current price but this then doesn’t include the standing charge so I end up with an underestimate……

Any chance that a variable tariff option could be added to the HACS integration?

1 Like

Hey,

Thanks for this as it almost perfectly helped get me set up. I’ve successfully completed the first part and now have mqtt set up and the Smart Meter readings coming through for my electricity (I don’t have gas on smart meter at the moment). However, when I copy through the second template to get my electricity cost as well i get the following error when checking my configuration.yaml file in developer settings:

Error loading /config/configuration.yaml: while parsing a block collection
in "/config/sensor.yaml", line 3, column 5
expected <block end>, but found '?'
in "/config/sensor.yaml", line 4, column 5`

I have added this to a separate sensor.yaml to my configuration.yaml with only this included but the same happens if I add the lines to the bottom of my configuration.yaml file. If I remove if, my configuration.yaml file validates in developer settings properly.

I was wondering if anyone else has seen anything similar and could point me to a fix. I’m very new to HA and I’m mostly following instructions rather than knowing exactly what each line of code is doing.

1 Like

Hi, not sure if this issue has already been mentioned, but I noticed a problem when trying to get electricity cost working in the Energy Panel.

I’m using @robertalexa 's custom component, and I’m tracking cost using the “Smart Meter Electricity: Cost (Today)” entity as instructed. The cost it showing as “£0.00”, though. I’ve had a look at the MQTT payload using MQTT Explorer - it is updating regularly and shows the following:

{
  "electricitymeter": {
    "timestamp": "2022-08-30T10:53:29Z",
    "energy": {
      "export": {
        "cumulative": 0,
        "units": "kWh"
      },
      "import": {
        "cumulative": 3066.055,
        "day": 0.005,
        "week": 0.018,
        "month": 0.348,
        "units": "kWh",
        "mpan": "XXXXXXXXXXXXX", # REDACTED
        "supplier": "British Gas",
        "price": {
          "unitrate": 0.291,
          "standingcharge": 0.5054
        }
      }
    },
    "power": {
      "value": 0.674,
      "value": 0.623,
      "units": "kW"
    }
  }
}

According to electricitymeter>import>day, I have only used 0.005 kWh of electricity today. The Bright app, however, shows that I have used 5.71 kWh. The actual kWh readings are out by a factor of 1000.

Bright app Energy Usage:

Bright app Cost:

Any idea how I can get an accurate reading from my IHD?

Thanks!


Edit: weirdly, although the MQTT payload says I’ve used 0.005 kWh, the Sources item in the Energy panel actually shows it correctly (note: in the time between the Bright app screenshots above and the Home Assistant Energy panel image below, usage had actually gone up from 5.71 kWh to 6.03 kWh). Cost still zero, though.
image

That is strange. Is this pulling the MQTT straight from the IHD? And if so you could try rebooting it. If you have access to the Glow MQTT feed, what figures do they show?

Thanks for the reply @BertrumUK , yes I am using local MQTT, I had to enter my MQTT broker details on the IHD. Tried resetting it, but no joy.

For now, I’ve decided to use the “Electric Consumption (Today)” entity from the Hildebrand Glow (DCC) integration, but of course I’d prefer the figures to come directly from the IHD via MQTT.

I’ve just changed it back to the local MQTT entity and it all seems to be working… Must’ve done something wrong the first time!

I have the same issue as yourself, my IHD from both my supplier and Glow are showing values for usage which are off by a power of 1000. This must mean it is an issue with the supplier.

You aren’t by any chance with British Gas are you?

Hi @litepalmer , yes I am with British Gas! I thought the problem was fixed but it isn’t, so I have had to revert back to the DCC integration’s electricity cost entity.

Is yours showing the correct figures in the Energy column in the Sources box/card?

As another British Gas customer the numbers are also off by a power of 1000. I actually reported this to British Gas for their IHD and never got anywhere close to a resolution.

I have managed to resolve this in HA however.

I created a helper using the “Utility Meter” option and set the source as the import and then to reset daily. I then changed the Daily cost to use this as the source instead of the “Day” reading coming from the IHD.

Hi Rav101

I am getting the same issue did you manage to resolve this?

Thanks
Keith

Hi,
Thank you so much for taking the time to do this, firstly I have added the entities to the config.yaml but when I add the template and further 2 entities I get an error like @rav101 does about the error in the line.

Next when I try and add the sensors to the HA energy dashboard I get the following and wondered if anyone could help?

Hi all - proviso, never rely on me checking this forum as I do so once every several months, please contact support directly usually, thank you. In this case - do you all have L&G electricity meters? From speaking to L&G and Igloo we learnt there is a known bug on this meter which results in extremely low day/week/month consumption values, this is what you are seeing. The values are 1000 times lower than they should be which is why they seem to not appear at all.

L&G have advised that this is fixed in firmware version 38040202 or later - you can check your version in the Bright App (no idea if it is in the MQTT feed). You will need to ask your supplier to have your meter firmware updated; we recommend that you contact the Smart Meter Technical team.

We’ve had a few BG customers get very inaccurate replies from BG Customer Service - and are seeing if we can pursue this on your behalf via the DCC BG Account manager.

Hope this helps.

@rav101 @baffles

There was a problem with the indentation of those template sensors. I have updated my original post and fixed it. I must have messed it up at some point when copy/paste from my config files.

Have a try and let me know if you need any help.

3 months later…

I now use the lifetime cumulative registers from the meter and let the Energy dashboard chop them into daily, weekly, monthly totals. Apart from the very occasional hiccup, the registers are monotonically increasing with no glitches. I’ve had to bodge the standing charge (still can’t believe this isn’t a standard feature…) I have a template which clocks up 1Wh of consumption at midnight and then multiplies this by the standing charge x 1000 for each of gas and elec. Clumsy but it works, for now.

Need some help here…falling at the first hurdle :frowning:

Where do I put the first section of @robertalexa 's code?

I have most of my files split out into separate yaml files, and initially tried creating an mqtt.yaml, pasting in there and then referencing in my config.yaml. But it wont pass config check like that.

#split out files
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
switch: !include switch.yaml
sensor: !include sensor.yaml
mqtt: !include mqtt.yaml

ERROR -

Invalid config for [mqtt]: [mqtt] is an invalid option for [mqtt]. Check: mqtt->mqtt->mqtt. (See /config/configuration.yaml, line 16).

Line 16 is the sensor: include in the code above (the line before adding the mgtt include)

Tried putting them in the sensors.yaml, get an error trying to validate that way…

- platform: template
  sensors:
    current_grid_in_watts:
      friendly_name: "Grid Current Power_Watts"
      unit_of_measurement: "W"
      value_template: "{{ states('sensor.develco_zhemi101_8423021b_smartenergy_metering')|float / 4   }}"
      unique_id: '543534654798'
      device_class: power
- platform: template
  sensors:
    total_grid_in_kw:
      friendly_name: "Grid Used Power Kw"
      unit_of_measurement: "kw"
      value_template: "{{ states('sensor.develco_zhemi101_8423021b_smartenergy_metering_summation_delivered')|float / 4  }}"
      unique_id: '540094654795'
      device_class: power
- platform: template      
  sensors:
    office_right_socket_amps:
     friendly_name: "office right socket amps Shelly"
     unique_id: 'shelly_current_channel_1'
     unit_of_measurement: "A"
     value_template: "{{ (states('sensor.office_right_socket_shelly_watts') | float / states('sensor.office_right_socket_shelly_voltage') | float) | round(2)  }}"
     device_class: power
    office_left_socket_amps:
     friendly_name: "office left socket amps Shelly"
     unique_id: 'shelly_current_channel_2'
     unit_of_measurement: "A"
     value_template: "{{ (states('sensor.office_left_socket_power') | float / states('sensor.office_left_socket_voltage') | float) | round(2)  }}"
     device_class: power
    coffee_table_amps:
     friendly_name: "coffee table amps"
     unique_id: 'coffeetable_1'
     unit_of_measurement: "A"
     value_template: "{{ (states('sensor.coffee_table_power_watts') | float / 240 | float) | round(2)  }}"
     device_class: power
- mqtt:
  sensor:  
    - name: "Smart Meter Electricity: Export"
      unique_id: "smart_meter_electricity_export"
      state_topic: "glow/78E36DD0172C/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/78E36DD0172C/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"

ERROR -

Invalid config for [sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 15).

Running out of skill now :wink:

In your mqtt file, but skip the mqtt heading (That is when people don’t split it in separate files and do everything from the configuration file).

Like this
image

1 Like

Booom…just like that. I was Sooo close :wink: Thank you so much…it was driving me nuts

All good on that piece, sensors all showing :slight_smile:

Should I add the cost templates to the mqtt file as well or should they go in maybe a separate templates file ?

EDIT - whacked in my config.yaml for now. Seems to be accepting it :slight_smile:

My approach was:
in configuration.yaml
image

PS: All my additional files are in an includes folder

Then in templates.yaml

Hope this helps

1 Like

Hi,
Does anyone know if it’s possible to either get or generate the current cost from data retrieved via MQTT? So like the cost per hour you can see on the CAD.

Thanks

Perfect, thanks @robertalexa !

One last question, is it possible to extract/add the ‘monitor individual devices’ section of the energy dashboard to add to your Lovelace version?

EDIT - Found it all at - Energy Cards - Home Assistant (home-assistant.io)

1 Like