A lot of times you want to display values on the Button+ without already having that value available in MQTT, or maybe that value is in a different format and you want to want to publish a formatted version of that value.

To get started with this, I use a very simple automation for each value I need. Of course, this can probably be done in a more complex way, but the idea is to demonstrate how to get the value in MQTT.

This ‘tutorial’ expects you to have MQTT running and connected to both Home Assistant and Button+.

Living room temperature

In my case, I really want to display the living room temperature on the Button+ device. This is a value that Home Assistant fetches directly, without using MQTT, from the device itself.

For me this value is stored in a sensor called sensor.living_room_temperature and when I look at the value in my HA developer tools, it looks like this.

image

What we need now is a nice automation that tells Home Assistant to publish the temperature to MQTT each time it changes, that way the Button+ can display the most recent value.

In Home Assistant, we click Settings > Automations & Scenes and then Create Automation. We use the Create new automation option from the dialog that pops up.

Here is the YAML for the automation:

alias: "[Button+] Living room temperature"
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.living_room_temperature
condition: []
action:
  - service: mqtt.publish
    data:
      qos: 0
      retain: true
      topic: button.plus/thermostat/current
      payload: "{{ states('sensor.living_room_temperature') }}"
mode: single

In this automation you can see that the trigger is a state change of the entity sensor.living_room_temperature. The action that is triggered is called an mqtt.publish and the payload we publish is a state from the same sensor.

That’s it!

A good way to monitor MQTT and see if everything is getting published correctly is by using a tool like MQTT Explorer which gives you a real-time view of the values in your MQTT broker.