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:
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.
Hey @JohnWH
I have updated my post, I have made a typo because initially i did the template for the gasmeter, and then manually modified. My brain was on auto pilot. Good spot!
You are very welcome. Trying to give back to others just like others gave to me
Thank you, 6,500Km in 20 days. I might need another holiday when i come back from holiday LOL
yes its pulling in data no problem, even checked mqtt and its showing data their too, but the energy dashboard is empty
I’m getting the error shown here when I attempt to add the GAS cost - do I just need to alter the unit of measurement in the template? (but if so why isn’t anybody else saying there’s an issue!)
@ianfretwell Can you please confirm this is what you have selected, including choosing the correct cost option - Use an entity tracking the total cost.
@si458 The energy dashboard can take up to 2 hours to start displaying information, in my case it was shorter than that, but more than 30 minutes. Also, your error suggests that you have used the Import Today entity, which is not what I have advised. Choose the Import (simple one) as that is cumulative and does not reset every day. HA will figure it out of how much it changes over time
Ahh - entirely my own fault there then - wrong cost option!
On a different note I’d like to be able to get things like the rssi value out as a sensor too but I can’t seem to make this work (all I’ve done is try to reverse engineer your work but apply it to the state values from MQTT instead) :
mqtt:
sensor:
- name: "Smart Meter IHD RSSI"
unique_id: "smart_meter_ihd_rssi"
state_topic: "glow/REDACTED/STATE/han"
device_class: "signal_strength"
unit_of_measurement: "dB"
state_class: "measurement"
value_template: "{{ value_json['han']['rssi'] }}"
icon: "mdi:wifi"
Thanks again.
@si458 Glad it is all good.
By the way, did you know you can replicate the Energy dashboard in lovelace? So then you can remove it from the sidebar and have everything nicely done in lovelave?
I have just updated my original post at the top with a screenshot and the YAML. Enjoy
@ianfretwell your state_topic
is wrong Should be state_topic: "glow/REDACTED/STATE"
. Then han
comes from the value_template
as per the MQTT output I posted. I am sure it was just a fluke at your end and you would have realised this eventually
Oh, I was so close! Thanks again!!
@robertalexa many thanks for your hard work on this !. One question when I set this up should I expect to see my entire gas / electricity usage to date on the HA energy stats page?
Could someone help me? I’m a real noob when it comes to MQTT, however I’m scratching my head because ive followed all the steps I’m seeing and my broker is not picking up anything from the display. I know that its connecting as when I turn the broker on and off it shows connection failed and connected. What does the topic need to be on the display? Where might I be going wrong? Thanks
My CAD was left at the default topic of glow. I just needed to pop in the ip of mosquito and the un/pw.
I would recommend MQTT Explorer on your PC, and you can then peek into Mosquito (if that is what you are using, a useful mqtt troubleshooting tool) to check that the messages are being processed as expected.