MQTT issue

I currently have two binary sensors connected to Mosquito via the Smartthings bridge. I can see all of the activity of both in the ST Bridge logs. However, the activities aren’t registering in HA (including my Lovelace dashboard) for one of the sensors. I believe I have them both configured correctly (i.e. identical), so I’m completely at a loss as to what could be wrong.

binary_sensors.yaml:

- platform: mqtt
  name: "Liquor Cabinet"
  state_topic: "smartthings/Liquor Sensor/contact/state"
  payload_on: "open"    
  payload_off: "closed"  
  device_class: opening 
  retain: true   
  
- platform: mqtt
  name: "Dog Food Sensor"
  state_topic: "smartthings/Bella Feeder/contact/state"
  payload_on: "active"
  payload_off: "inactive"
  device_class: motion
  retain: true

Again, nothing showing up in History or logs for the Dog Food Sensor but the Liquor Sensor works perfectly. Any suggestions?

Use MQTT client software (like MQTT.fx or MQTT-Spy) to subscribe to the dog food feeder topic:
smartthings/Bella Feeder/contact/state

Then do whatever needs to be done to make the physical feeder publish its status and see what is received by the MQTT client. If you get nothing then double-check the the topic’s spelling. If you get something other than active or inactive, then you’ve found the problem.

BTW, you don’t need to specify retain: true for these two sensors in HA. That’s applicable only if HA is publishing messages for these sensors. In your case, the two sensors are subscribers (i.e. receiving).

Have you tried subscribing to these topics on the MQ server to verify that something is publishing to it?

Not sure if it is a good idea to have spaces in the topics, although the mqtt specs allow for it. Topics are case sensitive, a common source of errors.

BTW, for sensors the retain: true line is useless and can be deleted.

Thank you. I had concerns with the spaces too, but weird that one works and other doesn’t but both have spaces in them.

This is the only difference between the two. Are you sure these match the payloads being sent in the messages? As was mentioned before, the best way to check is to connect another client and display the actual messages being sent, rather than trust the logs.

Mosquitto is a good choice. Mine runs on a second raspberrypi on Debian stretch that also runs deconz and two RF USB sticks. The standard mqtt port is 1883. You can listen to all topics with the command

mosquitto_sub -h localhost -t '#' -v

Hassio add-on broker connects perfectly with MQTT.fx
You probably need to configure the broker up address… I was using this yesterday but am away from home for the day so can’t give more exact information.

Thank you all for the help. Got it working!

The issue is I was using command vs motion on the Pet sensor.

state_topic: “smartthings/Bella Feeder/contact/state”

should have been:

state_topic: “smartthings/Bella Feeder/motion/state”

1 Like