Newbee, MQTT question

Hello,

I’m just starting with Home Assistant, i’m comming from openhab.
So far i like HA.

I’m running for now to one problem.
All my light switches and dimmers are working over MQTT, when i turn on one of the lights the status isn’t updated within HA.

the rest of the familie is stil working with openhab, so when they control the light, to my knowledge the status within HA should also be updated.
But that isn’t true.

I don’t know where to look or what is wrong.
The switches and dimmers are controlled by ESP.
There is custom software in these, so if needed i can alter it.
don’t wan’t to use esphome

below, a part of my config file.

light:
  - platform: mqtt
    name: "Vogels"
    command_topic: "/arnold/switch/"
    state_topic: "/arnold/switch/"
    command_on_template: "1,{{ brightness|d }}"
    command_off_template: "0"
    payload_on: "1"
    payload_off: "0"
    state_template: "{{ value.split(',')[0] }}"
    brightness_command_topic: "/arnold/dim/"
    brightness_template: '{{ value_json.brightness }}'
    brightness_state_topic: "/arnold/dim/" 
    brightness_scale: 100
    qos: 1
    retain: true
    optimistic: false
  
  - platform: mqtt
    name: "Zwartekast"
    command_topic: "/wifidimmer2/switch/"
    state_topic: "/wifidimmer2/switch/"
    command_on_template: "1,{{ brightness|d }}"
    command_off_template: "0"
    payload_on: "1"
    payload_off: "0"
    state_template: "{{ value.split(',')[0] }}"
    brightness_command_topic: "/wifidimmer2/dim/"
    brightness_state_topic: "/wifidimmer2/dim/"
    brightness_template: "{{ value_json.brightness }}"
    brightness_scale: 100
    qos: 0
    optimistic: false

they should update if the topics and messages are the same. Start with the topics and make sure they are the same between home assistant and openhab and work from there

I am just learning about MQTT but are your command and state topics supposed to be the same?
I thought 1 topic sent the command to turn them on and off and the other topic identified if it was on it off.

@Sleeepy,

That’s true, but i don’t send back a status update.
In the futher i plane to send a status back, but for now i don’t

If your device don’t report upon state change to any topic, you can define a state_topic to listen to.

You would then have to set the state_topic to the topic the light reacts up on. Note that there are several state topics for several state changes like RGB, brightness…

Well actually you did this… Is your state_template correct?

well i don’t know.

i’m still learning how to use te state_template.
what i send/recivie are:

switching topic, 0=off, 1=on
dim topic: only one value from 0 - 100 (dim value in %)

i think it is right :slight_smile:

Could you please use an external software (like mqtt.fx, mqtt-spy or mqtt explorer) to watch the messages that your ESP sends to the broker and show us here (in plain text)? Would be a great help in debugging this case maybe.