MQTT Binary Sensor not working after latest HA upgrade

Hello clever people and please forgive me if I have missed something fundamental!

For about three years I have been using the embedded MQTT broker to monitor a ground source heat pump - HA running on Raspberry Pi. Also MQTT is used to transport data from another RPi with the BME680 environmental sensor. Apart from some annoying micro-sd hassles (broken 3 of them and 2 USB drives!), things have been running well. Then I recently upgraded HA to Home Assistant 0.116.4 and the MQTT stopped working. Some research here led to me install the Mosquitto broker and disable the embedded MQTT broker.

After some farting about I know have the “normal” sensors working. Here is a snippet for two of the working sensors:

sensor 1:
  - platform: mqtt
    state_topic: "heatpump/0001"
    name: "GT01 - Rad Return"
    unit_of_measurement: "c"
  - platform: mqtt
    state_topic: "heatpump/0F61"
    name: "GT01 - Rad Return On"
    unit_of_measurement: "c"

However, no binary sensor for MQTT is recognised. Here is a snippet for a couple of them:

  - platform: mqtt
    state_topic: "heatpump/1A01"
    name: "Compressor"
    payload_on: "1"
    payload_off: "0"
  - platform: mqtt
    state_topic: "heatpump/1A07"
    name: "Switch valve"
    payload_on: "1"
    payload_off: "0"

I can see that there have been big changes with MQTT in HA and I understand the drive to put more into discovery and via the GUI as I assume this would require less technical skills. Do I need to set up some complex template to do this now?

Using MQTT.fx on a separate laptop I can see that the heat pump interface is generating the correct data and that is being published. Even using the mqtt.publish service within HA does not switch any of the binary sensors. I cannot find any error in the HA logfile too.

I was hoping that I could persuade Mosquitto to show me which subscriptions are in place but that has defeated me too!

I apologise profusely if I have missed something obvious or indeed a post where this is covered. Any help would be gratefully received!

Do you get any error in the logs? Do you maybe have binary_sensor: twice in your configuration.yaml? Can you show a snippet from MQTT.fx for one of the non working sensors?

The first two sensors you showed, are these temperature sensors? If so, change unit of measurement to “°C”.

The switch valve, is this a switch you want to be able to control from HA or only get the state of it? If you want to control it, you need to make an MQTT switch, not a binary_sensor.

Thank you very much for the quick response!
I do not want to control any of the config only monitor and store some history. The temperature sensors work ok. For example the Rad Return sensor shows 25.1 c at the moment.

The payload for the binary sensors is “1” for when it is active and “0” for when it is off. That is ASCII 1, and not a binary integer value.

The code to publish the MQTT message originates from the heat pump manufacturer and it would take some tweaks to convert the data to JSON from what I can see. Although it is written in Python. The interface is on the same Rpi as HA.

I also use HA to display data from a Bosch BME680 running on another Rpi. As that is not using a binary sensor then that works ok too. Here is the YAML for the temp part of the payload…

  - platform: mqtt
    name: "BME680 Temperature"
    state_topic: "bme680_sensor"
    value_template: "{{ value_json.Temperature }}"
    unit_of_measurement: "c"
    device_class: temperature

Thanks again for the response. I am keen to get it working again as winter is coming and I would like to ensure the heat pump is behaving itself!

Were not going to be able to help unless you answer all the questions.

Yeah, they work, but the unit of measurement is incorrect.

For the rest, as Tom said, we’re not able to help you before you provide the answers to my questions.

Doh! I missed this in the log:

Logger: homeassistant.components.websocket_api.http.connection.1239969616
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 21 October 2020, 19:49:19 (2 occurrences)
Last logged: 21 October 2020, 19:49:23
two or more values in the same group of exclusion 'payload' @ data[<payload>]

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/websocket_api/", line 143, in handle_call_service
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/", line 1289, in async_call
    processed_data = handler.schema(service_data)
  File "/srv/homeassistant/lib/python3.7/site-packages/voluptuous/", line 272, in __call__
    return self._compiled([], data)
  File "/srv/homeassistant/lib/python3.7/site-packages/voluptuous/", line 576, in validate_dict
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: two or more values in the same group of exclusion 'payload' @ data[<payload>]

That could have been when I was modifying the config yesterday as there is nothing of relevance in there today.

Here is a section from today…

[Bedroom clock(] Failed to connect to service Lenovo-Smart-Clock-4be7cc59d56b2cfc178688408efe609c._googlecast._tcp.local., retrying in 5.0s
12:17:08 – /srv/homeassistant/lib/python3.7/site-packages/pychromecast/ (ERROR) - message first occurred at 21 October 2020, 15:43:47 and shows up 4 times
[Bedroom clock(] Heartbeat timeout, resetting connection
12:16:52 – /srv/homeassistant/lib/python3.7/site-packages/pychromecast/ (WARNING) - message first occurred at 21 October 2020, 15:43:17 and shows up 5 times
Error handling request
12:07:35 – components/media_player/ (ERROR) - message first occurred at 10:54:04 and shows up 8 times
Update for sensor.efergy_728324 fails
09:47:59 – components/efergy/ (ERROR) - message first occurred at 21 October 2020, 15:07:22 and shows up 122 times
Update of sensor.per_device_usage is taking over 10 seconds
09:47:01 – /usr/local/lib/python3.7/asyncio/ (WARNING) - message first occurred at 21 October 2020, 15:32:03 and shows up 25 times
Could not update status for Per-Device Usage
09:44:34 – efergy (WARNING) - message first occurred at 21 October 2020, 15:37:40 and shows up 3 times
Retrying (Retry(total=6, connect=6, read=10, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x49eb6cf0>, 'Connection to timed out. (connect timeout=1)')': /public/data/val/wxfcs/all/json/353311?key=f95c7d68-a5b2-4f4a-850e-a7ede003d2a9&res=3hourly
09:43:49 – /srv/homeassistant/lib/python3.7/site-packages/urllib3/ (WARNING) - message first occurred at 09:42:19 and shows up 8 times
Updating efergy sensor took longer than the scheduled update interval 0:00:30
09:38:51 – Sensor (WARNING) - message first occurred at 21 October 2020, 15:36:49 and shows up 5 times

I am awaiting the pump to restart before I can get the entry from MQTT.fx.

Have a look in the mqtt log too.

Could you please point me to the mqtt log?

Here is the screenshot from MQTT.fx

That would depend on what you are using. If you are using the mosquitto addon, it’s one of the taps on the addon’s page in the supervisor.

Ah - that is another thing I forgot to mention - I have no Supervisor on HA.

What mqtt broker are you using then?

Mosquitto - and that is as the embedded one doesn’t seem to work to well after the update.

Heatpump is active at the moment and the boolean data is indeed being generated for the broker. I wonder if there is a way to determine what topics are being subscribed to?

Do you see the binary_sensors and they show unavailable or do you not see them at all?

They just show as Off…

When you go to Configuration -> Integrations and click on the Configure button of the MQTT integration, and subscribe to the topic of the pump, do you see the packets there?

It came up with this for the radiator pump…
Message 0 received on heatpump/1A06 at 20:38:


I shall try another one

Yep - another result…

Message 0 received on heatpump/1A06 at 20:38:


QoS: 0 - Retain: true

try changing th payload_on, payload_off in your binary_sensors to True and False respectively, I’d try different varations like “True”, True, true