Anyone able to develop a Home Assistant Custom Component or templating ?
I’ve just got the Glow CAD to go with my new smart meters for Agile Octopus.
I’m planning in the next few months to get Solar and a Powerwall.
I’ve linked the MQTT data to Home Assistant using the Node Red flow that was published in this forum (thanks!)
It’s the first time I’ve used Node Red, and I’d prefer to not need a Node Red Server if I could achieve the same in a custom component. I might even have a go at creating one or trying to achieve the JSON splitting and maths using templating.
Before I do, thought I’d ask if anyone has already got the data through to Home Assistant without using Node Red?
Thanks.
Comments
There is a Home Assistant component available here but it is lacking key features. As for templating, I might give it a go as I've played with it before and it's really not that tough. The JSON that the MQTT stream produces is a bit obscure so I might need some tinkering.
If you'd like to have a go at it yourself, I would suggest running my mosquitto_sub command to see what MQTT spits out and looking at Home Assistant's templating guide to extract the values you need from it. I haven't figured out myself what all these values mean.
I actually heard back from Jane from Hildebrand support, she suggested I look into the Zigbee Smart Energy Profile specification to understand the format of the MQTT payload.
It isn't a very pleasant read, but the biggest takeaway there is that the elecMtr.0702.04.00 JSON path in the JSON payload will give you (after converting from hex to decimal) electricity consumption (it is not available for gas as that is only picked up every half hour), and the elecMtr.0702.00.00 as well as gasMtr.0702.00.00 JSON paths should give you electricity and gas meter readings.
A bit of background on the different fields from reading the docs:
Well done on plowing through the Zigbee SEP spec, welcome to our world! ;)
Thanks for adding to the knowledge base and welcome to the forums @ndfred
that's great, thanks. I'm having a go now.
I figured it out! I published a writeup of how to configure Home Assistant to work with a Glow device over MQTT:
https://gist.github.com/ndfred/5bb51b567f8cfaf2bb06da6393169321
Ok, success.
I'm using hassOS with the Mosquitto Broker.
So first thing was to bridge the Bright MQTT to my mosquitto MQTT:
In Mosquitto Broker config:
customize:
active: true
folder: mosquitto
Then in /share/mosquitto/glowmqtt.conf
connection glowmqtt
address glowmqtt.energyhive.com:8883
topic SMART/HILD/XXXXXXXXXX in 0
try_private false
notifications true
start_type automatic
remote_clientid glow
remote_username xxxxxxxxxxxxxxx
remote_password xxxxxxxxxxx
keepalive_interval 300
cleansession true
bridge_protocol_version mqttv311
local_clientid homeassistant
bridge_cafile /etc/ssl/certs/ca-certificates.crt
Then in the YAML:
sensor:
- platform: mqtt
name: "MQTT Elec Meter"
device_class: power
icon: mdi:counter
unit_of_measurement: "kwh"
state_topic: "SMART/HILD/XXXXXXXXXXX"
value_template: "{{ ((value_json.elecMtr['0702']['00']['00'] | int(base=16)) / 1000 )| int }}"
- platform: mqtt
name: "MQTT Elec Demand"
device_class: power
icon: mdi:flash-alert
unit_of_measurement: "kw"
state_topic: "SMART/HILD/XXXXXXXXXXX"
value_template: "{{ (value_json.elecMtr['0702']['04']['00'] | int(base=16)) / 1000 }}"
- platform: mqtt
name: "MQTT Export Power"
device_class: power
icon: mdi:flash-outline
unit_of_measurement: "kwh"
state_topic: "SMART/HILD/XXXXXXXXXXX"
value_template: "{{ (value_json.elecMtr['0702']['00']['01'] | int(base=16)) / 1000 }}"
- platform: mqtt
name: "MQTT Grid Power"
device_class: power
unit_of_measurement: "kwh"
icon: mdi:flash-circle
state_topic: "SMART/HILD/XXXXXXXXXXX"
value_template: "{{ ((value_json.elecMtr['0702']['04']['00'] | int(base=16))-(value_json.elecMtr['0702']['00']['01'] | int(base=16))) / 1000 }}"
- platform: mqtt
name: "MQTT Gas Meter"
device_class: power
icon: mdi:speedometer-slow
unit_of_measurement: "kwh"
state_topic: "SMART/HILD/XXXXXXXXXXX"
value_template: "{{( (value_json.gasMtr['0702']['00']['00'] | int(base=16)) / 1000) | int }}"
- platform: mqtt
name: "MQTT pan"
state_topic: "SMART/HILD/XXXXXXXXXXX"
value_template: "{{ value_json['pan']['status'] }}"
json_attributes_topic: "SMART/HILD/XXXXXXXXXXX"
json_attributes_template: "{{ value_json.pan | tojson }}"
just need to work out how to deal with the signed hex in :
Or I could have read your post above properly that said you’d written the instructions, that are pretty similar to mine !
If you are not exporting energy just treat InstantaneousDemand as unsigned.
Excellent Info everyone, received my CAD today and with the above info I was setup in a couple minutes. I have noticed that my mosquitto broker is outputting the following every few seconds though:
Data is coming through without issue but wondering if anyone else is seeing this?
I'd also like to say, super impressed with Glowmarkt support so far, Jane 👍️
I’m also having the socket error every few seconds. My connection is via a bridge in HomeAssistant. I contacted Hildebrand support, who said “The only people with issues in my logs like you are running in bridge”. I never got to the bottom of it but as my data comes through OK I am living with the spam in my log!
I am now exporting. So how do I handle the instantaneous demand to treat it as a signed integer ?
in home assistant templating I mean ?
After hours of variations to config files in varying locations without any success, thanks to BruceH5200's example I've at least got to the stage of *trying* to connect to the bridge.
However I now just get the dreaded
I've tried making the local_clientid unique, as others have suggested. I can see the MQTT messages directly, but nothing comes through the bridge.
My conf looks like
Any suggestions on how to debug? Home Assistant OS 5.12. Mosquitto broker 5.1.
Update...
I've added log_type all to my conf file, and that seems to have kicked it into a bit more life - some messages are getting through. The log ranges from
to
Any ideas?
This bridge works for me
Main difference is that I'm using bridge_capath to find all of the locally installed certificates (which includes the LetsEncrypt ISRG_root_X1).
Mine is also working, with anything between 0 and 3 successful results per minute - the others are failing with socket errors. This seems to be exactly the same problem reported by sourbrambles and martinb in October/December.
However the good news is that I'm able to feed the mqtt message into NodeRed, where it's easy to parse the json, convert the hex strings, and store the results in a remote MySQL database. I'd just like to fix the error causing the missing results.
Do the JSON parsing in C, that's a wonderful exercise in "how hard can this stuff be?".
I got a whole load of C code working today and I've got a Wemos with an LED strip responding to current usage. It needs a cleanup then I'll stuff it out on github for anyone who wants to roll their own.
For anyone that's interested I've circumvented my socket error problem by installing Mosquitto (from SynoCommunity) on my Synology NAS. I used the same mosquitto.conf lines as above. I could then switch to the Synology mqtt broker in NodeRed.
It seems rock solid with no dropped messages or socket errors, with a Glow message every 13 seconds or so. I guess my problem was something to do with the mosquitto bridge running locally on the RPi.