MQTT messages not triggering sensors

I have MQTT configured (mosquitto) and working. I can issue mosquitto_sub and use mosquitto_pub to exchange messages. This works on the local machine and on other machines on the LAN.

I have the following in configuration.yaml (added after a fresh install of homeassistant on centos 7)

mqtt:
  broker: localhost
  port: 1883

binary_sensor:
  - platform: mqtt
    name: Hall PIR
    state_topic: "/home/security/hall"
    payload_on: "ON"
    payload_off: "OFF"
    device_class: motion

Reloading hass I see the sensor appear. Using the MQTT option on the web page to publish messages I can see them being received on a mosquitto_sub I have running so I know it can at least send to mosquitto.

If I then issue

mosquitto_pub -t home/security/hall -m ON

I see it appear on my mosquitto_sub but nothing happens to the sensor icon. Changing ON to OFF makes no difference either.

I dont see anything in the logs that indicate it’s connected to the broker either.

Running mosquitto in the foreground with -v I see the following when I start up hass

1516091134: New connection from ::1 on port 1883.
1516091134: New client connected from ::1 as e23ca6c6-bce3-4a8d-bb0a-fde70a67e060 (c1, k60).
1516091134: Sending CONNACK to e23ca6c6-bce3-4a8d-bb0a-fde70a67e060 (0, 0)
1516091135: Received SUBSCRIBE from e23ca6c6-bce3-4a8d-bb0a-fde70a67e060
1516091135:     /home/security/hall (QoS 0)
1516091135: e23ca6c6-bce3-4a8d-bb0a-fde70a67e060 0 /home/security/hall
1516091135: Sending SUBACK to e23ca6c6-bce3-4a8d-bb0a-fde70a67e060
1516091195: Received PINGREQ from e23ca6c6-bce3-4a8d-bb0a-fde70a67e060
1516091195: Sending PINGRESP to e23ca6c6-bce3-4a8d-bb0a-fde70a67e060

so it looks like it’s at least connecting. Sending an ON payload to the /home/security/hall topic I see the following

1516091341: New connection from ::1 on port 1883.
1516091341: New client connected from ::1 as mosqpub|13413-prime.dua (c1, k60).
1516091341: Sending CONNACK to mosqpub|13413-prime.dua (0, 0)
1516091341: Received PUBLISH from mosqpub|13413-prime.dua (d0, q0, r0, m0, 'home/security/hall', ... (2 bytes))
1516091341: Received DISCONNECT from mosqpub|13413-prime.dua
1516091341: Client mosqpub|13413-prime.dua disconnected.

Sending OFF results in the same output on mosquitto_sub but correctly indicates 3 bytes in the message.

Is there anything else I can try to see why hass doesnt appear to recognise my messages ?

home/security/hall is not the same as /home/security/hall - that’d be where I’d start :slight_smile:

1 Like

DOH !

I know that but somehow have missed it for a few hours. Must be getting tired.

Thanks heaps for spotting that. I’ve been going insane trying to figure out what was wrong.

It’s all behaving now :slight_smile:

1 Like