MQTT Sensors failing

I am facing weird problems. Things started to fail out no reasons after I upgraded to 0.39.2. For example, my MQTT sensors suddenly stopped working.

  • When I subscribed to the same topic via other client (e.g. my android phone), I can see the payload. But in HA, the state of the MQTT sensor doesn’t change at all and remained “unknown”
  • Automation using MQTT still works fine. The payload of a topic can trigger the automation.
  • Service call using mqtt.publish works as well.
  • The MQTT sensors work again after I restart HA but the restart process took longer than usual.

Is this a bug in 0.39.2? Anyone else facing this problem?

1 Like

I’m still getting MQTT out of memory error in 0.39.2, so that may be the cause?

MQTT sensors still fail after awhile out of no reason. I gave up. Downgrading back to 0.38.4.

Will monitor for few more days and hopefully it stays stable.

I miss those days when I felt excited after each upgrades. Now, I just kept my fingers cross and hopefully things doesn’t get worse after upgrade.

i have the same problema.
with your 0.38.4 do you have acess HA from your android phone? i tested with 3 android… and show me LOADING DATA and not enter.

I have no problem loading the frontend from any devices.

Update: After 2 days, MQTT sensors are still working fine.

Just as a qualifier to this, I have been running 0.39.3 since Saturday with 4 MQTT PIR sensors going through mosquitto, and have not had a problem. Three sensors are through the MySensors MQTT gateway and one directly from an Esp8266.

I have restarted a couple of times because of configuration changes.

Are you using the internal broker or something else?

Im using external broker. I can see the payload using mqttfx in PC and MQTT Dashboard in Android. But HA doesn’t update the MQTT sensors that I have…

- platform: mqtt
  state_topic: "home/livingroom/window"
  name: Living Room Window

- platform: mqtt
  state_topic: "home/kitchen/backdoor"
  name: Back Door

I have 14 of these sensors.

Maybe I should elaborate further on my MQTT sensors setup.

Firstly, I have 433Mhz sensors that transmit code when it is triggered. This code is then captured by a standalone gateway and then publish the code via MQTT.

In HA, I created an automation using MQTT trigger. For example…

- alias: 'Open Close Sensor - Living Room Window Open'
  trigger:
    platform: mqtt
    topic: home/433toMQTT
    payload: !secret 433_openclose_livingwindow_open
  action:
    service: mqtt.publish
    data:
      topic: 'home/livingroom/window'
      payload: 'open'
      retain: 'true'

- alias: 'Open Close Sensor - Living Room Window Close'
  trigger:
    platform: mqtt
    topic: home/433toMQTT
    payload: !secret 433_openclose_livingwindow_close
  action:
    service: mqtt.publish
    data:
      topic: 'home/livingroom/window'
      payload: 'close'
      retain: 'true'

- alias: 'Open Close Sensor - Living Room Window Tempered'
  trigger:
    platform: mqtt
    topic: home/433toMQTT
    payload: !secret 433_openclose_livingwindow_tempered
  action:
    service: mqtt.publish
    data:
      topic: 'home/livingroom/window'
      payload: 'tempered'
      retain: 'false'

As you can see, when the payload of topic home/433toMQTT equals to certain code, it will publish to another MQTT topic with its corresponding payload.

This topic will be used by the MQTT sensor such as this…

- platform: mqtt
  state_topic: "home/livingroom/window"
  name: Living Room Window

As mentioned earlier, my MQTT broker is not in the same computer as HA. It is hosted in another computer.

I’m having similar problems with latest HASS version.
MQTT (mosquitto) sensor not reading on HASS, but reading fine when subscribed elsewhere. MQTT publish using HASS working fine. It used to work before. Is MQTT sensor broken in HASS version 0.40.1?

sensor SERVER:
  - platform: mqtt
    name: "Switches"
    state_topic: "Switches"

mqtt:
  broker: 192.168.0.37
  port: 1883
  protocol: 3.1
  client_id: home-assistant-1
  keepalive: 60

Just about everything else was reported to break on 0.40.1, so I never upgraded. But it does work fine on 0.40.0

Tried it with the latest 0.41.0 which has just been released. Still broken.

Does your mosquitto log show that HA is connecting correctly?

How do I check that. Where is the log on Linux and what should I look for? home assistant ?
Ps. Tried enabling logging in the mosquito config file. Didn’t work.

The log file is normally stored in /var/log/mosquitto/mosquitto.log, but it depends on how you configure it. You should get an entry stating your client-id connected.

I have the exact same issue. not all mqtt sensor stop working but I have 3 philips motion sensors which a poll via a node script and publish to mqtt. During the day they work fine. but mostly after the night the stop working. My guess so far is that because it’s dark and there no motion in the night there are no updates for a while and HA is not picking up changes the next morning. I checked the mqtt broker and I still see publishes from the script to mqtt, so it does not seem to be an issue with the broker.

I started HA with debugging on the mqtt component today to see if there is anything logged. So maybe I know more tomorrow, maybe not :slight_smile:

I have the same issue! I have and MQTT alarm panel and after 5/6 hours of starting HA, he stops to work! If I use mosquitto clients I can see that the messages work as expected but HA doesn’t publishes or receives the messages. At the same time other components start to fail too (some command line switches and mysensors actuators).

Seems that HA just stops noticing. I still see mqtt traffic with the mqtt client but HA just stops, nothing in the logs, debugging just stops.

Also I see mqtt from an esp8266 with a temp/humidity sensor incomplete in HA:

Ha logs:
17-04-04 17:02:30 INFO (Thread-11) [homeassistant.components.mqtt] Received message on home/badkamer/temp: 18

mqtt_sub:
home/badkamer/temp 18
home/badkamer/humidity 35
home/badkamer/dht11/battery 2989

I should see something like:
17-04-04 14:56:58 INFO (Thread-11) [homeassistant.components.mqtt] Received message on home/badkamer/temp: 18
17-04-04 14:56:58 INFO (Thread-11) [homeassistant.components.mqtt] Received message on home/badkamer/humidity: 35
17-04-04 14:56:58 INFO (Thread-11) [homeassistant.components.mqtt] Received message on home/badkamer/dht11/battery: 2989

I am also seeing a failure of an MQTT - ESP8288 sensor which was working until I did an upgrade. I am now running 0.41.0 on my ‘production’ version. I also have a kind of ‘development’ version running on a separate RPi which has a stripped down version of my Config. The same sensor seems is working fine on that version. They both use the same internal broker running on my ‘production’ RPi. I sometimes see this error when I click on the sensor icon:

‘Cannor read propery V of undefined’

How old is the version you are running as dev?