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.

  • edited July 2020

    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:

    0702: Metering
    - 00: Reading Information Set
     - 00: CurrentSummationDelivered: energy consumed (meter)
     - 01: CurrentSummationReceived: solar panels production?
     - 02: CurrentMaxDemandDelivered: ?
     - 07: ReadingSnapshotTime: UTC time
     - 14: Supply Status: 0x2 is on
    - 02: Meter Status
    - 03: Formatting
    - 04: Historical Consumption
     - 00: InstantaneousDemand (Signed)
     - 01: CurrentDayConsumptionDelivered
     - 30: CurrentWeekConsumptionDelivered
     - 40: CurrentMonthConsumptionDelivered
    0705: Prepayment
    0708: Device Management
    
  • 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

  • edited July 2020

    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 :

     - 00: InstantaneousDemand (Signed)
    


  • Or I could have read your post above properly that said you’d written the instructions, that are pretty similar to mine !

  • edited July 2020

    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:

    Socket error on client local.core-mosquitto.glowmqtt, disconnecting.
    Connecting bridge glowmqtt (glowmqtt.energyhive.com:8883)
    

    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 ?

  • edited March 2021


    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

    1614785570: Connecting bridge glowmqtt (glowmqtt.energyhive.com:8883)
    1614785572: Socket error on client homeassistant_73527485673, disconnecting.
    

    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

    connection glowmqtt
    address glowmqtt.energyhive.com:8883
    try_private false
    notifications true
    start_type automatic
    keepalive_interval 300
    cleansession true
    bridge_protocol_version mqttv311
    remote_username x@y.net
    remote_password mypassword
    bridge_cafile /etc/ssl/certs/ca-certificates.crt
    topic SMART/HILD/0123456789AB in 0
    local_clientid homeassistant_73527485673
    remote_clientid glow
    
    

    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

    1614788635: Connecting bridge glowmqtt (glowmqtt.energyhive.com:8883)
    1614788635: Bridge glow sending CONNECT
    1614788635: Received CONNACK on connection homeassistant_73527485673.
    1614788635: Bridge homeassistant_73527485673 sending SUBSCRIBE (Mid: 50, Topic: SMART/HILD/xxxxxxxxxxxx, QoS: 0, Options: 0x00)
    1614788635: Received PUBACK from homeassistant_73527485673 (Mid: 49, RC:0)
    1614788635: Received SUBACK from homeassistant_73527485673
    1614788638: Socket error on client homeassistant_73527485673, disconnecting.
    

    to

    1614788644: Connecting bridge glowmqtt (glowmqtt.energyhive.com:8883)
    1614788644: Bridge glow sending CONNECT
    1614788644: Received CONNACK on connection homeassistant_73527485673.
    1614788644: Bridge homeassistant_73527485673 sending SUBSCRIBE (Mid: 52, Topic: SMART/HILD/xxxxxxxxxxxx, QoS: 0, Options: 0x00)
    1614788644: Received PUBACK from homeassistant_73527485673 (Mid: 51, RC:0)
    1614788644: Received SUBACK from homeassistant_73527485673
    1614788644: Received PINGREQ from 5c389384-caf2-4b12-9afa-f8504c28b0ea1614773610055
    1614788644: Sending PINGRESP to 5c389384-caf2-4b12-9afa-f8504c28b0ea1614773610055
    1614788645: Received PUBLISH from homeassistant_73527485673 (d0, q0, r0, m0, 'SMART/HILD/xxxxxxxxxxxx', ... (677 bytes))
    1614788645: Sending PUBLISH to 5c389384-caf2-4b12-9afa-f8504c28b0ea1614773610055 (d0, q0, r0, m0, 'SMART/HILD/xxxxxxxxxxxx', ... (677 bytes))
    1614788647: Socket error on client homeassistant_73527485673, disconnecting.
    

    Any ideas?

  • This bridge works for me

    connection glowmqtt
    address glowmqtt.energyhive.com:8883
    try_private false
    notifications true
    start_type automatic
    keepalive_interval 300
    cleansession true
    bridge_protocol_version mqttv311
    remote_username example@gmail.com
    remote_password RedactedPasswordHere
    topic SMART/HILD/DEADBEEFCAFE in 0
    bridge_capath /etc/ssl/certs
    local_clientid raspberrypi_mosq
    remote_clientid raspberrypi_glow
    
    

    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.

Sign In or Register to comment.