Cover Function for Garage door or in my case Gate, I can not get it to function like it should(update just made it work)

Update, just made this work, but want to leave it here for others to be usefull.

Hi everybody, i am trying to use a modified sonoff basic to open and close the garage door or main gate and show the open state with a reed switch.
I know this has been mentioned many times before, the past few days i read almost everything about it i think. But i still can’t get it to work properly.

Here is what i have.
I modified a sonoff basic so that the relay acts independent from the incoming power.
So is it switches, it only makes a contact.
I programmed it wit the latest tasmota where i filled in the things needed for wifi and mqtt.
I also set a pulstime of 10 so that whenever i activate the switch it is only pulsing on for 1 second and then stays off again.
I set the mqtt topic to sonoffgate
I connected the reed switch to ground and GPIO14.

After starting the sonoff for the first time i set GPIO14 to 10switch2.
In the console I typed
switchmode1 0
switchmode2 2
switchtopic2 gatestate… This was my mistake, for some reason this does not work, this needs to be switchtopic2 2

When i test the buttons this shows up in the console
Switch

10:43:20 MQT: stat/sonoffgate/RESULT = {"POWER":"ON"}
10:43:20 MQT: stat/sonoffgate/POWER = ON
10:43:21 MQT: stat/sonoffgate/RESULT = {"POWER":"OFF"}
10:43:21 MQT: stat/sonoffgate/POWER = OFF

Reed switch

10:46:34 MQT: cmnd/gatestate/POWER2 = ON
10:46:38 MQT: cmnd/gatestate/POWER2 = OFF
So gatestate is now changed to 2, and gives me the same output

I made a binary_sensor in config.yaml like this.

binary_sensor:
  - platform: mqtt
    name: "gatestate"
    state_topic: "cmnd/gatestate/POWER2"
    payload_on: "ON"
    payload_off: "OFF"

This binary sensor is not needed for the cover to function correct but here i also changed gatestate to 2

This shows the state correct if i activate the reed switch so i assume this is working like it should.

I added this cover function in the config.yaml

cover:
  - platform: mqtt
    name: "test"
    state_topic: "cmnd/gatestate/POWER2"
    command_topic: "cmnd/sonoffgate/POWER"
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_open: "ON"
    state_closed: "OFF"
    optimistic: false
    retain: false

Abobe I changed state_topic: “cmnd/gatestate/POWER2” changed to"cmnd/2/POWER2"

Added this in the customize.yaml

cover.test:
  friendly_name: front gate
  device_class: garage

At first i thought i would do this later, but it is an important step to make the mdi icon work and change. the line "device_class: garage" sets the icon.

Added this in the groups.yaml

  garage_doors:
      name: Main gate
      view: no
      control: hidden
      icon: mdi:garage
      entities:
        - cover.test

For some reason i don’t think that the icon line ads anything, but in all the examples i have seen its there.
I am tired of trying, maybe someone can tell why this should be here.

This is what my cover looks like in HA
cover
Now when i click the black arrow, the relay switches like it should.
The same when i hit the black square.
So that is all good.

When i activate the reed switch, the mdi icon changes to an open garage door.
That is also like it should.

The thing that i am struggling with is that the grayed out arrow stays grayed out no matter what i do.

A already spent my complete weekend trying to figure this out but i can’t find the solution.

I hope that this can help others.
I am glad i finally made it work.