Platform MQTT switch wrong icon since last update

The most recent update has odd behavior with my mqtt/arduino switches. The icon is the old lightning bolt. However once I activate the switch (Office Desk), one time, the icon changes to the expected icon (like the 4 above it) and doesn’t change back. But if I reboot, it’s wrong again. Been running these for about 2 years without issue. Anything new that I need to update or is this a bug?

  - platform: mqtt
    name: "Office Desk"
    unique_id: light.office_desk_light
    command_topic: "mqttuser/feeds/office_desk/lights"
    payload_on: "on"
    payload_off: "off"
    state_topic: 'mqttuser/feeds/office_desk/lights/state'
    state_value_template: >-
      {% if value == 'on' %}
      {% elif value == 'off' %}
      {% else %}
      {% endif %}
    brightness_state_topic: 'mqttuser/feeds/office_desk/lights/bstate'
    brightness_command_topic: 'mqttuser/feeds/office_desk/lights'
    brightness_value_template: '{{value}}'
    rgb_state_topic: 'mqttuser/feeds/office_desk/rgblights/state'
    rgb_command_topic: 'mqttuser/feeds/office_desk/rgblights'
    on_command_type: 'brightness'




There has also been an issue opened on Github:

Great, thank you. Maybe I can build an automation or have my Arduinos periodically publish their state even when not asked (gotta think about that one though). It seems that we should have an “assumed off” state unless otherwise stated.

Yeah I mentioned that option on Github, but I may raise a feature request on the forum as well.

1 Like

Same issue for me. I use my own ESP8266 based implementation for 15 433Mhz RF sockets. When homeassistant (core-2022.4.7) sends the MQTT Birth message my device publishes discovery messages for each device followed by the state message. Therefore there is no need to set a retain flag. Being in unknown state happens randomly for some of the devices resulting in the two flash symbols instead of one slider symbol. Once switching it changes into the slider symbol. The switching can be done externaly, e.g. via the web interface of my esp8266 device.

To me it looks like a timing issue in homassistant missing or not being ready to receive the switch state messages if they are send to early.

If I do delay the state updates by a few seconds (just tried 5s) everything is fine.

I noticed that delaying the ON/OFF state did not help reliable with this issue (now using core 2022.5.4). Sometimes after restarting the core it still comes up with the dual flash symbols. Because I have the source of my DIY MQTT switches I decided to update them to support the availability topic and reported them to be online directly after a discovery loop. That did fix the issue.