Possible to create a 'cover' card for my driveway gate using the sonoff relay switch and door sensor?

So I’ve rigged up my driveway gate remote with a sonoff switch, which I can toggle through HA now, but obviously that doesn’t know the state of the door. I have a door sensor on the gate which shows if it’s open or closed.

Is there a way to create a Cover like card, the one with the up and down arrows to open or close, that uses the information from the door sensor, and activates the sonoff switch when the open or close button is pressed?

Essentially what I think it would have to do is have an open and close button that both just trigger the sonoff switch, but the open button is active(able to press) only when the gate status is closed and the close button is active only when the gate status is open.

Creating something like this is way beyond my knowledge, and I’m only a novice… so, maybe hoping there is a simple solution out there. Thanks!

create a template cover entity. And then you can use any cover card!

Ah, yeah nice. Pretty simple! Just set that up, and the only thing I’m not sure about is the value template. In the example it’s using

“{{ states(‘sensor.garage_door’)|float > 0 }}”

I tried using that and just replacing with my door sensor, but my door sensor is a binary sensor(binary_sensor.driveway_gate) and it gives the values of on or off. The configuration variables says that valid values are open/true or closed/false. If I put in my binary sensor into the example line, it doesn’t change the buttons when the gate is opened or closed.

These value template things always confuse me. Any help appreciated!

try this:

value_template: “{{ states(‘binary_sensor.garage_door’) }}”

No, that kicks back this error when I check config:

Invalid config for [cover.template]: invalid template (TemplateSyntaxError: unexpected char ‘‘’ at 11) for dictionary value @ data[‘covers’][‘driveway_gate’][‘value_template’]. Got ‘“{{ states(‘binary_sensor.driveway_gate’) }}”’. (See ?, line ?).

I tried creating a sensor that translates on/off to open/closed, and using that in the line instead, but the state of the buttons still don’t change.

This is what I have done

covers:
  drive_gate:
    friendly_name: "Drive Gate"
    value_template: "{{ is_state('binary_sensor.drive_gate_status', 'on') }}"
    open_cover:
      service: switch.toggle
      data:
        entity_id: switch.drive_gate
    close_cover:
      service: switch.toggle
      data:
        entity_id: switch.drive_gate
    icon_template: >-
      {% if is_state('binary_sensor.drive_gate_status', 'on') %}
        mdi:gate-open
      {% else %}
        mdi:gate
      {% endif %}

Perfect! Thank you so much. Works great. The open gate icon is a nice touch too. Didn’t know that existed.