MQTT COVER not working


My garage door send the following status info:
opening, closing, open, closed
to the following topic:
it is based on sonoff device.
I can check if its Online or Offline.

I have the following mqtt cover:

    - name: "MQTT Cover"
      command_topic: "stat/sonoff/brama/POWER"
      state_topic: "stat/sonoff/brama/state"
        - topic: "tele/sonoff/brama/LWT"
      qos: 0
      retain: true
      payload_open: "OPEN"
      payload_close: "CLOSE"
      payload_stop: "STOP"
      state_open: "open"
      state_opening: "opening"
      state_closed: "closed"
      state_closing: "closing"
      payload_available: "Online"
      payload_not_available: "Offline"
      optimistic: false
      value_template: "{{ value.x }}"

why it is not working?
I use my remote controller to open/stop/close door.
The cover is offline (grey) (while mqtt explorer is showing Online).
I added Button with garage door icon to the lovelace.
At the begining Id like to see the status of my door (I dont want to send and open,close commands).

thx for any tips.

I think your value.x in value_template should be value. I also cannot see LWT message in your image to report availability. Is your device sending this?

See this bit.

Could you pls write few sentences why value.x didnt work. I dont understant it to be honest.


this one doesnt work

        - topic: "tele/sonoff/brama/LWT"

this one does:

        - topic: "home-assistant/cover/availability"

so It has to be named availability (the topic)?
cannot be any topic containing online/offline?

ok. now I get it:

when using

        - topic: "home-assistant/cover/availability"

then, it has to be availability=online/offline

when using:

availability_topic: "tele/sonoff/brama/LWT"

then the topic can be…anything reporting online/offline
so, LWT=online will do