Please Help! total beginner just wants to turn on 1 light using MQTT

Hi!

I think this is an easy question but it already took me 2 days to get close but now i’m kinda stuck in a loop. I’m new with everything so please forgive me if i say stupid things :wink: I hope you guys know the answer and like to share :slight_smile:

So i just want to turn on a light using a device called “button+” that uses MQTT. Now i’ve got the broker (mosquitto) installed and use the MQTT explorer and HA to check if it is actually sending messages when i press the button i want to press to turn on the light. This all works. The messages are received and the payload can be read.

Now it seems just Home Assistant is not translating the received trigger to an actual on trigger of the light. For this i tried to figure out what the code should look like in the configurator.yaml and I probably made a mistake there. Like, it probably needs to know in some way which light i mean and it needs to target by using the exact right ID but how? I probably also made other mistakes that are mandatory that i just don’t realise.

This is the code right now:

mqtt:

  • light:
    name: light.ikea_of_sweden_tradfri_driver_10w_light
    command_topic: “office/light/switch”
    payload_on: “ON”
    qos: 0

If any of you can help please share :slight_smile:

Are you using Zigbee2mqtt?

Here’s an example from one of my switches.

alias: Mute Office Media (Office Switch 3)
description: ""
triggers:
  - topic: zigbee2mqtt/Office Switch/action
    payload: 3_single
    trigger: mqtt
conditions: []
actions:
  - data: {}
    action: script.mute_office
mode: single

However - I do use Zigbee2MQTT - not sure how you’d do it without tbh :slight_smile:

I am not! thanks to this reply i am now watching a tutorial on that, thnx! :slight_smile:

thanks for the example :slight_smile: yea, so this is where the beginner thing comes in I didn’t know MQTT was a thing yesterday and now i hear about Zigbee2MQTT. I’m going to watch a tutorial on that, thnx!

Can I ask what sends the mqtt message now ?

Well, the Button+ module sends it when i press one of the buttons. The interface looks like this:

Found it: https://button.plus/

@hodaiku - If this is the same button+ mentioned above, then it’s an ESP32 based wifi divice, so not zigbee. (Tradfri, on the other hand, is indeed zigbee, but so far it does not yet look like a zigbee problem your are asking.)

Anyways a couple of questions to double check:

  1. Sounds like, from MQTT Explorer, you can actually see the MQTT topic being updated when you press the button, correct?
  2. Did your HA connect to your MQTT server? Here is a way to test, per the docs.
  3. Can you control your Tradfri light(s) from HA already (, without the button+, that is)?

If yes to all of the above. I think you have everything you need already, (and likely do not even need the codes you quoted in your first post.)

(a) what is the MQTT topic being updated whenever you press your button+? You likely can find it from MQTT Explorer
(b) oh and, per the MQTT topic above, does your button+ give you on-off states, or momentarily events of button presses, or something else?
(c) what is the entity name of your Tradfri light? The entity can be found under Developer tools → States

With information (a) ~ (c) from you, people here likely can help you put together an automation in HA, to toggle the Tradfri light(s) based on the button+ switching (or presses.)

Let us know.

1 Like

Hi k8gg,

You are correct! I learned a lot while installing zigbee2mqtt though. Had to flash the dongle for new updates and learned the difference between ZHA and Zigbee2mqtt.
But in the end the solution to the problem was creating the correct automation when my button+ was connected correctly to the mqtt broker. When it received messages and when i created an automation that listened to the topic and payload, i send with the button+ device, it worked!

Thanks for all the help. All the replies helped me further in learning what is actually going on. :slight_smile: