Configure a cover for gate

Good day,

I am still new to Home Assistant and coding and would like to reach out to the community for assistance with the configuration of a cover for my gate status sensors.

I have set-up contact sensors to indicate the status of my gate and it is working as a door or garage door, but would like to configure a gate cover, in order for the gate icon to be displayed in an open or closed position, depending on the status of the sensor and to change colour based on the status.

I have entered the code below in my configuration.yaml and the cover is available in my dashboard, but it is returning an “Unavailable status” if I add the entity card in the my dashboard

cover:
  - platform: template
    covers:
      large_gate:
        device_class: gate
        friendly_name: "Gates Sensors Large Gate"
        value_template: "{{ states('binary_sensor.gates_sensors_large_gate')|float > 0 }}"
        open_cover:
          service: script.open_gate
          data:
            entity_id: binary_sensor.gates_sensors_large_gate
        close_cover:
          service: script.close_gate
          data:
            entity_id: binary_sensor.gates_sensors_large_gate
        stop_cover:
          service: script.stop_gate
          data:
            entity_id: binary_sensor.gates_sensors_large_gate
        icon_template: >-
          {% if is_state('binary_sensor.gates_sensors_large_gate', 'open') %}
            mdi:gate-open
          {% else %}
            mdi:gate
          {% endif %} 

Any advice from members to get the cover working would be highly appreciated.

Kind regards

I can see a couple of things wrong. Change your value template to this:

value_template: "{{ is_state('binary_sensor.gates_sensors_large_gate','on') }}"

Change your icon template to this:

icon_template: >
  {% if is_state('binary_sensor.gates_sensors_large_gate', 'on') %}
    mdi:gate-open
  {% else %}
    mdi:gate
  {% endif %}

Thank you very much for your valuable assistance. It is highly appreciated. My gate cover is working now.

Is there perhaps a way to set the open colour to red in the lovelace dashboard?
It is currently changing colour from blue-grey to purple when the staus changes from closed to open.