MQTT Publishing

Tags: #<Tag:0x00007f3f13befd30>

Hi Hassio Friends

I have an Raspberry pi running Hassio and MQTT on the Pi
I did Build an arduino to publish data to Hassio that is working fine, but for some reason i cannot publish a payload on and off to the arduino i did try the local mqtt publish service on the Developer tab and that works fine but the normal toggle switch that i have made is not working at all i also have mqtt lens running and i cant see the msg coming into the mqtt broker so i know the problem is not the arduino, is the way i send the toggle on and off not correct?

This is what i have a

switch:

  • platform: mqtt
    name: “Zone1”
    command_topic: “zone1”
    qos: 0
    payload_on: “zone1triggeron”
    payload_off: “zone1triggeroff”

i created the lovelace card that works but a soon as i slide the toggle i dont get the msg “payload” in mqtt lens nor the arduino gets it any ideas?’

as soon as i toggel it should send zone1triggeron and zone1triggeroff when i toggle back.

Go to Home Assistant’s MQTT page and enter your topic and payload. Click the PUBLISH button.

If MQTT Lens does not show that the topic received the payload you just published then it means Home Assistant is not connected to the MQTT Broker.

Screenshot%20from%202019-05-28%2016-52-45

That is working fine i can publish and it sends no issues the arduino does what it needs to do so its not that

I have Sensor config in my configuration.yaml file that connects to the broker and that is also reading data like it should

i dont know if it has something todo with the one mqtt publish button that i created it works in my script.yaml file it triggers a payload and then triggers it back but that is a custom script button that i created to do that for a flip on flip off instant switch that i tested and that also works

As an experiment, I added this MQTT Switch:

  - platform: mqtt
    name: "Test Switch"
    command_topic: "zone1"
    payload_on: "zone1on"
    payload_off: "zone1off"

I restarted Home Assistant and ‘Test Switch’ appeared in the Lovelace UI. I turned the switch on then off.

Screenshot%20from%202019-05-28%2017-20-56

Using MQTT Explorer, I confirmed it published zone1on and zone1off to the topic zone1.

Screenshot%20from%202019-05-28%2017-22-39

So the MQTT Switch configuration is functional.

That’s why I asked you to test if Home Assistant was connected to the MQTT Broker. You reported it is connected, yet your MQTT Switch fails to publish to its topic.

The results don’t add up:

  1. You can publish from Home Assistant’s MQTT page.
  2. The MQTT Switch’s configuration is functional.
  3. The MQTT Switch fails to publish to its command_topic.

There’s a missing piece to this puzzle.

i am use MQTT Lens 0/0 messages

i then pub this
image

and get this

i then try the switch
image

then i get no answer
image

this is the code
image

so im not sure perhaps two diffrent mqtt brokers on my system cant be that so im not sure why

i will scratch more tomorrow and give feedback

I think I found the missing piece of the puzzle.

Your screenshot, of your configuration, shows you are using the wrong kind of quotes.

You need to use standard single ' or double " quotes. Your configuration is using fancy double quotes.

Issue Resolved

i knew it must be something small thanks for assisting, sometimes you just need a new pair of eyes to spot the issue.

Glad to hear it works now.

Please consider tagging my post with the ‘solution’ flag so others can find it more easily. See point #21 in How to Ask a Good Question.