Configure Shelly Plus RGBW PM in configuration.yaml

I have configured a Shelly Plus RGBW PM as a 4x white light dimmer in configuration.yaml. Everything works except that when I start HA the status shown is “Unknown” for some minutes or until I press at least once the on/off command on its card. I don’t think that the problem is related to the configuration but I’m in search of advices. Below the extract from the configuration.

mqtt:
  light: 
    - name: "shellyplusrgbwpm-macaddress-0"
      unique_id: "shellyplusrgbwpm_macaddress_0"
      command_topic: "shellies/shellyplusrgbwpm-macaddress/rpc"
      state_topic: "shellies/shellyplusrgbwpm-macaddress/status/light:0"
      availability_topic: "shellies/shellyplusrgbwpm-macaddress/online"
      command_on_template: >
        {"id": 0,"src": "ha","method": "Light.Set","params":{"id": 0,"on": true
        {%- if brightness is defined -%}
        , "brightness": {{brightness | float | multiply(0.3922) | round(0)}}
        {%- endif -%}
        }}
      command_off_template: '{"id": 0,"src": "ha","method": "Light.Set","params":{"id": 0,"on": false}}'
      <<: &shelly_rgbwpm
        payload_available: 'true'
        payload_not_available: 'false'
        schema: template
        state_template: "{% if value_json.output %}on{% else %}off{% endif %}"
        brightness_template: "{{ value_json.brightness | float | multiply(2.55) | round(0) }}"
        qos: 2
    - name: "shellyplusrgbwpm-macaddress-1"
      unique_id: "shellyplusrgbwpm_macaddress_1"
      command_topic: "shellies/shellyplusrgbwpm-macaddress/rpc"
      state_topic: "shellies/shellyplusrgbwpm-macaddress/status/light:1"
      availability_topic: "shellies/shellyplusrgbwpm-macaddress/online"
      command_on_template: >
        {"id": 0,"src": "ha","method": "Light.Set","params":{"id": 1,"on": true
        {%- if brightness is defined -%}
        , "brightness": {{brightness | float | multiply(0.3922) | round(0)}}
        {%- endif -%}
        }}
      command_off_template: '{"id": 0,"src": "ha","method": "Light.Set","params":{"id": 1,"on": false}}'
      <<: *shelly_rgbwpm
    - name: "shellyplusrgbwpm-macaddress-2"
      unique_id: "shellyplusrgbwpm_macaddress_2"
      command_topic: "shellies/shellyplusrgbwpm-macaddress/rpc"
      state_topic: "shellies/shellyplusrgbwpm-macaddress/status/light:2"
      availability_topic: "shellies/shellyplusrgbwpm-macaddress/online"
      command_on_template: >
        {"id": 0,"src": "ha","method": "Light.Set","params":{"id": 2,"on": true
        {%- if brightness is defined -%}
        , "brightness": {{brightness | float | multiply(0.3922) | round(0)}}
        {%- endif -%}
        }}
      command_off_template: '{"id": 0,"src": "ha","method": "Light.Set","params":{"id": 2,"on": false}}'
      <<: *shelly_rgbwpm
    - name: "shellyplusrgbwpm-macaddress-3"
      unique_id: "shellyplusrgbwpm_macaddress_3"
      command_topic: "shellies/shellyplusrgbwpm-macaddress/rpc"
      state_topic: "shellies/shellyplusrgbwpm-macaddress/status/light:3"
      availability_topic: "shellies/shellyplusrgbwpm-macaddress/online"
      command_on_template: >
        {"id": 0,"src": "ha","method": "Light.Set","params":{"id": 3,"on": true
        {%- if brightness is defined -%}
        , "brightness": {{brightness | float | multiply(0.3922) | round(0)}}
        {%- endif -%}
        }}
      command_off_template: '{"id": 0,"src": "ha","method": "Light.Set","params":{"id": 3,"on": false}}'
      <<: *shelly_rgbwpm

This discussion of MQTT message retention and lights seems on point.

If you’re using Z2M, you can configure the device messages to be retained in the Settings tab for the device. Hopefully that will eliminate the “unknown” state that you’re seeing between when you start HA and get a new state update from the device.

You need to send status_update to <DEVICE_ID>/command topic after HA start.

Thanks, both replies were useful. As suggested “status_update” was missing.

References from Shelly API docs:

I updated my automations.yaml as follows:

- alias: MQTT Announce
  description: ''
  triggers:
  - event: start
    trigger: homeassistant
  conditions: []
  actions:
  # Shelly gen1 devices
  - action: mqtt.publish
    data:
      topic: shellies/command
      payload: update
  # Shelly gen2 devices
  - action: mqtt.publish
    data:
      topic: shellies/command
      payload: status_update

The strange thing is that before adding the new Shelly Plus RGBW PM (gen2) I had some Shelly RGBW2 (gen1) and some Shelly Plus 2PM (gen2). MQTT announce automation had only the “update” payload and at HA startup both RGBW2 and Plus 2 PM states were available. Not sure why Plus 2 PM worked.