Cover MQTT broke after updating - 'value_template' must be set together with 'state_topic'

After updating to core-2021.7.3 and supervisor-2021.06.8 my cover MQTT suddenly stopped working. I receive the following error: Invalid config for [cover.mqtt]: ‘value_template’ must be set together with ‘state_topic’.
I have the following setup in my configuration.yaml:

  • platform: mqtt
    name: " Roller Shade1"
    command_topic: “/raw/esp8266/702539/in”
    set_position_topic: “/raw/esp8266/702539/in”
    position_topic: “/raw/esp8266/702539/out”
    value_template: “{{ value_json.position }}”
    json_attributes_topic: “/raw/esp8266/702539/out”
    json_attributes_template: “{{ value_json.position | tojson }}”
    retain: false
    payload_open: “100”
    payload_close: “0”
    position_open: 100
    position_closed: 0
    I cannot find anything in the changelog that describe a breaking cover mqtt changes. Any helps / ideas will be received with great pleasure!

I know they have been doing some clean up work with the MQTT cover integration recently
so its possible what use to work for you, perhaps by accident, may no longer work.
I think what you need to do is to add a state_topic and use the value_template with your state topic.
For your position value, use position_template instead.

Here would be a suggestion for the state configuration:

    state_topic: "/raw/esp8266/702539/out"
    state_open: "closed"
    state_closed: "open"
    value_template: '{% if value_json.position == 0 -%}closed{%- else -%}open{%- endif %}'

Thanks a lot! That did the trick

This is not really consistent with the docs, which state

If the cover reports its position, a position_topic can be configured for receiving the position. If no state_topic is configured, the cover’s state will be set to either open or closed when a position is received.

So a config like this

- platform: mqtt
  name: "Rolladen Kueche"
  position_topic: "homeassistant/cover/00111A499A1E40/position"
  set_position_topic: "homeassistant/cover/00111A499A1E40/set_position"
  qos: 2
  retain: false
  position_open: 100
  position_closed: 0
  value_template: '{{ (value_json.val * 100) | round(0) }}'
  set_position_template: '{ "position": {{ position }}, "topic": "HmIP-RF.00111A499A1E40:4.LEVEL" }'

was valid and worked as expected/is documented). Unfortunately the feature is broken now :frowning:

What about using position_template instead of value_template?