MQTT into Home Assistant

For me this is the holy grail, I have my LIVE SMETS-2 meter data (electricity usage and solar export) in Home Assistant. (I'm so excited! Big High Five and THANKYOU to all at Glow / Hildebrand who made this possible)

My Home Assistant knowledge in near minimal so I invite any HA experts to jump in and correct me, but for those at my level or below, this is how I got there:

A Glow IHD running v1.8.12 software (I believe you need V1.8.12 for MQTT support?)

Home Assistant 2022.6 (2022.6 this months release and has new support for MQTT)

The Mosquito MQTT Broker running on my Home Assistant hardware (its a standard add on see: settings/ add-ons)

MQTT is configured on the Glow IHD (very easy)

Optional: I have added the Visual Studio Code Server to HA (settings/ add-ons) or you use the File Editor add-on to edit the configuration.yaml file


You then need to "sense" the MQTT data in Home Assistant

The basic configuration is to edit configuration.yaml and add a section for mqtt (See below) and then you pickup/ use the sensor values as you want in the Home Assistant GUI

[The interface for this forum is basic so the indent spacing in the following may be mangled]

The following demonstrates picking up the Glow data from MQTT

mqtt:

sensor:

  - name: "Metered Current Consumption"

    state_topic: "glow/441793504B6D/SENSOR/electricitymeter" #Need SECRET

    unit_of_measurement: "kW"

    value_template: "{{ value_json.electricitymeter.power.value | round(1) }}"

    device_class: energy

    state_class: total_increasing

  - name: "Metered Export Reading"

    state_topic: "glow/441793504B6D/SENSOR/electricitymeter" #Need SECRET

    unit_of_measurement: "kWh"

    value_template: "{{ value_json.electricitymeter.energy.export.cumulative | round(1) }}"

    device_class: energy

    state_class: total_increasing

  - name: "Metered Import Reading"

    state_topic: "glow/441793504B6D/SENSOR/electricitymeter" #Need SECRET

    unit_of_measurement: "kWh"

    value_template: "{{ value_json.electricitymeter.energy.import.cumulative | round(1) }}"

    device_class: energy

    state_class: total_increasing

  - name: "Metered Unit Price"

    state_topic: "glow/441793504B6D/SENSOR/electricitymeter" #Need SECRET

    unit_of_measurement: "GBP"

    value_template: "{{ value_json.electricitymeter.energy.import.price.unitrate | round(3) }}"

  # Glow Device State Info

  - name: "Glow Han Status"

    state_topic: "glow/441793504B6D/STATE"

    value_template: "{{ value_json.han.status }}"

  - name: "Glow Han RSSI"

    state_topic: "glow/441793504B6D/STATE"

    value_template: "{{ value_json.han.rssi }}"

    unit_of_measurement: "dBm"

  - name: "Glow Software Version"

    state_topic: "glow/441793504B6D/STATE"

    value_template: "{{ value_json.software }}


Tips:

You can check the syntax of your yaml is correct from: developer tools / yaml / configuration validation

You can quickly (re)load the MQTT sensor(s) from developer tools / yaml / YAML config reloading / Manually configured MQTT entities

More/ Advanced:

If you are worried about sharing your config files and the ID of your glow device you can uses secrets.yaml and some thing like:

state_topic: !secret glow_MQTT_topic_electricitymeter

where glow_MQTT_topic_electricitymeter

is

glow_MQTT_topic_electricitymeter: "glow/441793504B6D/SENSOR/electricitymeter"

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsSAAALEgHS3X78AAAB3ElEQVQ4jY2TPWhTURTH/+e8l7QNJg0qCJpCSdEnONTFDk5udfILs9mS6iJYpI4VnURXUcRJrFG3gm3tXLpIxaUUIVA/iLRJayQ2Nk1q7cu99zjUF/JhQv7jOff/O+fcwyERAQAQEaoVjsdOirgP93L+W5svJpeq8xVfPWD/yPkepekBWbjETl8nM0h9XtkRV72xLbmdn5hJ/xdw4OaVkC6U7oBwg6MRH0d7fGTbQDoLIYKUXa2/rO5C6SdWOHh/4/HrLQCwvZZUoZi2Dh/ysdPbRZ0dNeOQCMj2WXTiaMCUtsdUKn0dQHcNAEZCVr+DViJjYAW6/NqI34txS0eVIqEwRgfONMTbApyORDE3PIbF9dX2AKPHTyESCFbMExeGMTL9EguZVHuAxY3vmBscwtkjfS3NTQELuQzi72bwaGAQ8elEUzNQtQUiLsmf3X3eCt/n1uBMPQUy2bqSDCIuNXQgjHnJ5kzTUt47rUQY8w0AG2ZcLX/bkc2t5m5mlJdTv22Y8QZAPjGbBPHl8oePRb2yruu9BjBu8msRGrF8YjZZGb3+mA5ePee4ip9xoKOfj/UGSRuYtR/b+ldxyW/paz+fv/0EtLhGT91DF2NgubtXnu4VXk1N1vzFP99f037PUFbu4yIAAAAASUVORK5CYII= There was an error displaying this embed.

HA Experts: Anything I can do better, please?

Comments

  • Sorry I forgot to add something about the MQTT topic.

    in the line:

    state_topic: "glow/441793504B6D/SENSOR/electricitymeter"

    I believe 441793504B6D is the id for the Glow device. You will need an MQTT client or similar to get the exact topic name your device is using.

  • @glider51

    [The interface for this forum is basic so the indent spacing in the following may be mangled]

    you can use the 3 backticks to insert code.

    value_template: "{{ value_json.electricitymeter.power.value | round(1) }}"
    

    Why do you round this? It will either round up or down as it stands. If you want just the integer part use int(0) (although a default of zero may cause problems with the accumulator).

  • ```value_template: "{{ value_json.electricitymeter.power.value | round(1) }}"
    

    >>Why do you round this?

    Because for my own preference I I don't want the number to 3DP or for the kWh daily/monthly/ all time usage I only want 1DP.

Sign In or Register to comment.