Mqtt json light state switches off

I have an ESP8266 with the milight control. When i activate a light, the lamp goes on, the switch in hass returns to off immediately while the lamp stays on. thus i cannot control the color/brightness or turn off the light.

my config for the lights:

light:

  • name: “Milight Lamp #1
    command_topic: milight/0x02FF/rgb_cct/1
    state_topic: milight/states/0x02FF/rgb_cct/1
    <<: &MILIGHT_PARAMS
    platform: mqtt_json
    color_temp: true
    rgb: true
    brightness: true

  • name: “Milight Lamp #2
    command_topic: milight/0x02FF/rgb_cct/2
    state_topic: milight/states/0x02FF/rgb_cct/2
    <<: *MILIGHT_PARAMS

  • name: “Milight Lamp #3
    command_topic: milight/0x02FF/rgb_cct/3
    state_topic: milight/states/0x02FF/rgb_cct/3
    <<: *MILIGHT_PARAMS

Mqtt topic pattern:
milight/:device_id/:device_type/:group_id

mqtt update topic pattern:
milight/update/:device_id/:device_type/:group_id

mqtt state topic pattern:
milight/states/:device_id/:device_type/:group_id

I think the state topic is not updated since i see no info in this topic ever. How can i fix this?

The symptoms you describe are exactly what happens when HA does not receive a suitable message matching the state_topic.

If your ESP8266 is not sending a state message you can use the optimistic flag in the HA configuration so that HA does not expect a status message in response.

figured it out: /0x02FF/ should be /0x2FF/