Mqtt light does not change entity state when change on web ui?

Hi,

mqtt light does not change entity state when change on web ui?

Why?

      - platform: mqtt
        name: "mqtt_light_jimmy_sunlight"
        state_topic: "home/jimmy/sunlight-state"
        command_topic: "home/jimmy/sunlight"
        qos: 0
        payload_on: "on"
        payload_off: "off"
        payload_available: "Online"
        payload_not_available: "Offline"
        optimistic: false
        retain: true

Are you sure you are using the correct topic?

is the device actually connecting to the MQTT broker?

Also, it’s necessary to properly format your code when posting. see the blue box at the top.

I use rf 433mhz remote + socket in combination with mqtt light component. I convert signal from rf to mqtt and then back. When I press ON on rf remote I convert code trugh node-red to two topic home/jimmy/sunlight-state and home/jimmy/sunlight boath have ON payload. First is for state_topic and second is for command_topic. I configuret mqtt light like I show on my first post.

BUT NOT WORKING PROPERLY:
When I use remote, light is working on/off no problem (but entity status on web ui not changing).

On web-ui I can only turn on the lights but switch move to off position after 1s automaticaly. Light stays on. Off not working?

I suggest using an Mqtt sniffer program and connect to your broker to see what messages are being sent around when operating your device from the remote or ui.

I use mqttfx.

You can then see what exact topics are sent. At least it will help you narrow things down a little.

1 Like

Just a guess, but the payload (and topic) are case sensitive, so the state_topic would have to be “ON” to match this.

1 Like

I connect to my mqtt trough sniffer, but when I try to on/off the light on web-ui nothing hapened?

I try mqttfx and mqtt snooper on my android phone.

I try to publish:
home/jimmy/sunlight on or off and light goes on and off but I get nothing on my sniffer?

How did you configure your light to communicate with your broker?

It sounds like it isn’t connecting to your broker. If it was you should see SOMETHING on your sniffer when you cycle the remote control.

I have only one configured broker. When I try to stop it. Try again on/off the lights and not working if I stop broker. Soo I connected to correct broker. But still no messages on sniffer? Any idea?

No, sorry.

If you are connected to the correct broker with both your light and with the sniffer then there should be something showing on your sniffer when you operate the light.

Make sure that you have set up your sniffer to receive all messages by specifying # as the topic.

1 Like

Good point. I never really specified that.

I put # under subscribe and now I getting the messages from broker :slight_smile:

1 Like

Good news. Now you need to make sure that the messages being sent by your light match exactly what is expected.

Everything is case sensitive so a payload of on is not the same as ON

Another common mistake is mismatching /'s in the topic.

If in doubt, paste the actual messages you are seeing, and somebody will probably be able to spot the problem.

Thanks for help. Now switch is working. Now looks like this:

  - platform: mqtt
    name: "mqtt_light_jimmy_sunlight"
    state_topic: "home/jimmy/sunlight"
    command_topic: "home/jimmy/sunlight"
    qos: 0
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    optimistic: false
    retain: true
1 Like