Glow / Hildebrand Display - Local MQTT Access - Template Help

Hi,
My CAD seems to not be sending “power” for Gas does something need to be enabled or has it been removed?

{
    "gasmeter": {
        "timestamp": "2022-10-15T08:46:05Z",
        "energy": {
            "import": {
                "cumulative": 11019.361,
                "day": 0,
                "week": 50.941,
                "month": 146.208,
                "units": "kWh",
                "cumulativevol": 987.06,
                "cumulativevolunits": "m3",
                "dayvol": 0,
                "weekvol": 50.941,
                "monthvol": 146.208,
                "dayweekmonthvolunits": "kWh",
                "mprn": "REDACTED",
                "supplier": "---",
                "price": {
                    "unitrate": 0.10424,
                    "standingcharge": 0.26627
                }
            }
        }
    }
}

This seems to be the only message it sends in relation to Gas. The electric equivalent has the extra power bit at the bottom.

Thanks

Gas power existed in the mqtt to start with but Glow has said they will remove it eventually because it is redundant and gas doesn’t need it. So they might have done that already

Thank you, sensor removed from my config. It did seem like it would be a little pointless as it updtes so infrequently.

I have created a current cost template should anyone want one

- name: "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('sensor.smart_meter_electricity_import_unit_rate') | float
      ) | round(2) }}"

Note I convert my current power to watts so need to divide by 1000 if you are not converting kWh to W then you can just use the below.

  - name: "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 
        * states('sensor.smart_meter_electricity_import_unit_rate') | float
      ) | round(2) }}"

@robertalexa I think I have found a problem with using stale records for Gas kWh. When my meter resets at midnight it reads 0 and we often don’t use any gas from midnight until 5am. This means that the stale record used to prevent zeros during the day causes the price to recalculate which then changes again when I get an actual reading.

Example:

  • Yesterday I used £1.46 of gas
  • Reset at midnight set this to 27p (standing charge)
  • It then when back to £1.46 shortly after as gas usage was the stale record
  • at around 4am we used some gas setting the daily cost to 93p
  • the energy dashboard now shows £2.39 of gas for today for 6.4kWh actual usage which should be 93p

Do I need to do a similar thing with the daily cost so that if gas from the MQTT reads zero, cost also equals zero as that would stop incorrect increments (I think)?

1 Like

Hi @hassio85

I am not seeing what you are seeing, so i suspect an issue with your mqtt feed data, possibly pushing wrong information?

Here is how my entities looked like for the last week

This sounds familiar to what someone else has encountering, but I do not fully remember the situation or the outcome. Please have a look at the replies above, as there will have steps about how to debug values from the mqtt feed to figure out which one (if any) is pushing erroneous data at weird times. It may be that you need specific way to combat your situation

Have a look and if you are stuck come back with some screenshots of your entities graphs, and we can check what is going wrong and when :slight_smile:

Thanks, I will take a look, here are my graphs for good measure though:-
image
image

I think the issue is that because I don’t use any Gas around midnight the sensor is using yesterdays entry which then ups the cost sensor which in turn adds to the usage graph. If I were using gas around midnight I do not think this would be a problem as the usage would be genuine.

Sensor details below:-

  - 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) }}"
- name: "Smart Meter Gas: Import (Today)"

    unique_id: "smart_meter_gas_import_today"

    state_topic: "glow/4C11AEAE0138/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 %}
1 Like

Have a look from that post downwards as it could be a timezone difference between ha and the glow.

You should also find around that post some instructions as to how to debug the mqtt data directly, leave it 1 night, and see if the mqtt data is wrong or if the issue is in ha.

Currently on the phone but will keep an eye open for your findings

Interesting, HA shows the correct time but an MQTT message shows:-

“timestamp”: “2022-10-17T11:24:13Z”

which is one hour out. I will check the monitor when I get home. The timezone settings in the bright app are UTC+1 but the modify button is greyed out so I presume I have to change that on the display itself…

Hi,
The time on my display is is correct and matches that of my HA setup. The MQTT seems to be one hour out but when entries are put on the graph the are correct so this just appear to be UTC but is ignored when entered.

It still looks like the problem is because the kWh used reverts to the previous days record as I have used 0 gas between midnight and 5am and the sensor only seems to account for allowing an MQTT value of 0 between 00:00:00 and 00:00:01. On the graphs above the first drop is 00:00:32 at 00:09:02 it then goes back to 11.43kWh which is the same as before midnight. It then drops to 4.95kWh at 04:39:02 as that is roughly when my hot water would have been heated. The todays cost times also match these and that makes sense as the sensor is kWh * unit rate + standing charge so if the kWh goes up it will add that but when it reverts back it does nothing then starts adding again as there is actual gas usage. My energy dashboard for between midnight and 08:00 is below. My actual total cost for today is: £1.85 however the energy dashboard shows: £3.31 which is today + yesterday.

My electricty graphs by comparison are working fine:

Edit: I have upped the threshold from 1 minute to 30 minutes to see if that helps.

Thanks

Heya, hope you are well :slight_smile:
Finally in front of a computer. Your issue was a good memory game for me i guess, but this was raised by @glitter-ball before, and maybe he has found some extra info since then?

Basically follow the debug instructions from here:

Let them run over a night so you can capture the reset as raw data from the IHD, which will pass it as raw data from your meter.

If you keep reading down form there the conversation between myself and Glitter Ball I have a feeling that you might be encountering a similar problem. In his case, the MQTT data showed wrong data coming straight from the meter. If you are seeing a similar thing, I would suggest you first get in touch with Jane at Glow via support email and show here your mqtt raw data. I have also provided “hacky” solutions to GlitterBall but they would have to be specific to your case. You will also find in that same conversation the reasoning for why the sensor is meant to accept 0 values only in the first minute of the day.

Happy to try to help you further once you have that debugging data - try to take inspiration from the information and graphs provided by GlitterBall in case your data turns to be healthy.

PS: my setup in HA is exactly as in my original post, latest version. In my case, I am sometimes seeing differences in the price between HA and Bright app, but the differences are only pennies (sometimes from rounding e.g. 0.01 difference).

Let me know how it goes and if I can assist you any further :slight_smile:

Hi,
Upping the threshold did not work. I have created the debug sensor and interestingly after restarting the HA services it was reading 0.0 (correct) but the edited one (original) was unknown as it was trying to use an old record that is cleared after a HA reset. I have manually set that one to zero so my dashboard looks correct for the day as I won’t be using any gas until around 4pm today.

I guess we just need to wait now until tomorrow to see what happens.

Thanks

I now use the lifetime registers out of the IHD - not the daily ones. The HA Energy dashboard works fine with them and daily totals now exactly match the IHD.

1 Like

Sadly this will not work with variable tariffs. The only possible solution I can think of is creating utility meter with multiple tariffs and summing them but then you would also need to store “previous” unit price somewhere. I wish they simply gave us today’s cost in MQTT…

That is indeed correct. Unfortunately I am not on a variable plan so I have never had the data/knowledge (real world numbers) to look into a solution for this.

@JaneatGlow Any ideas if this is on your roadmap? Expose via mqtt the either today’s cost as it stands with the variable tariff or can you guys propose an alternative method?

Jane is not always present on these forums so we might not get an answer here, but @resoai you could send Glow a support email and enquire about this?

Sorry I can’t be of much help unfortunately - or at least not at this point in time

1 Like

Thank you. Publishing cost via MQTT would surely be ideal.

Ok, so it looks like the meter sends a 0 around midnight but then at 00:09 it goes back up to what it was before midnight. I stayed up this evening to witness it and even the CAD display shows yesterdays usage so I am not entirely sure what is going on now. Can you check and see if your MQTT messages at UTC time as mine is different by exactly 1 hour but the time in both HA and on the CAD are correct and match each other. I still have the debug sensor setup so will be able to see tomorrow when it actually resets, my suspicion is it maybe around 1am if the MQTT time is anything to go by.

Turns out 00:38 was the magic time which seems random.

My mqtt feed is UTC as well, so one hour behind the current summer time. It means you are experiencing the same issue as @glitter-ball . I suggest you try using the lifetime entity as he has sugested as see how that goes.

Unfortunately there is nothing i can do with code, apart from a specific hack for your use case.

I am trying to fix it using the below. It works fine in the delevoper tab but errors in yaml, any ideas?

  - name: "Smart Meter Gas: Cost (Today)1"
    unique_id: smart_meter_gas_cost_today1
    device_class: monetary
    unit_of_measurement: "GBP"
    state_class: "total_increasing"
    icon: mdi:cash
    {% if now() < now().replace(hour=0).replace(minute=45).replace(second=0).replace(microsecond=0) %}
       {{ states('sensor.smart_meter_gas_import_standing_charge') | float | round(2)}}
    {% else %}
        {{  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) }}
    {% endif %}

This basically says between 00:00 and 00:45 keep the daily total at the standing charge then after that do the normal calculations.

Developer tab

Thanks