MQTT light state not working

Hi all,

I have finally managed to have some lights in my house message its states through a MQTT-topic to home assistant. The light supports dimming, so I have configured my configuration.yaml using the ‘brightness’ function.
I can turn the light on and off in HA from the dashboard. However the problem starts when I switch the physical on/off switch of the light.
I see, using MQTT explorer, that the light (when I manually turn the light on or off) correctly sends its state through the topic. However Home assistant does not update the state accordingly.
If I set ‘optimistic’ to false, HA does automatically turn the light on the dashboard back to off every time I try to turn it on in the dashboard.
Does anybody know what might be wrong in my config file?

Configuration.yaml:

- platform: mqtt
    unique_id: Licht_eettafel__dgts
    name: "Eettafel"
    state_topic: "digitalstrom/devices/Licht_eettafel__dgts/brightness/state"
    command_topic: "digitalstrom/devices/Licht_eettafel__dgts/brightness/command"
    on_command_type: 'brightness'
    brightness_scale: 100
    brightness_state_topic: 'digitalstrom/devices/Licht_eettafel__dgts/brightness/state'
    brightness_command_topic: 'digitalstrom/devices/Licht_eettafel__dgts/brightness/command'
    payload_off: '0'
    optimistic: true   

I am running Home Assistant supervised on a raspberry-pi:
version: core-2022.2.6
installation_type: Home Assistant OS
dev: false
hassio: true
docker: true
user: root
virtualenv: false
python_version: 3.9.7
os_name: Linux
os_version: 5.10.92-v8
arch: aarch64

Mosquito broker add-on v 6.0.1

Your onoff state topics and your brightness topics are the same
I have never ‘not’ supplied a separate onoff topic, I can see it is possible to map 0 to off but what should HA send to turn the light on ?

Hi @xAPPO ,

Indeed the topics are the same. Unfortunately I dont think I can change this. The lights I am trying to configure are from a rather closed home automation platform. The only mqtt message it will send is the topics mentioned.
If I am not mistaken I have to define a state and command topic and also for the brightness function. As the lights only communicate via the one topic, I entered the same for both.

The message that is needed to turn on is any brightness level that is not 0. So for example if I send this message to the mqtt broker the light turns on at brightness 25:

topic: digitalstrom/devices/Licht_eettafel__dgts/brightness/command
message: 25

What I understand from the brightness function, any value posted on the command topic between 1 and 100 should trigger a state change.

After searching more on the forum I found this post. This helped my identify the mistake I made.

In short: the payload messages that I needed to use were: ’ 0.00’ and ’ 100.00’. I mistakenly used ‘0’ and ‘100’.