How to create a Cover out of a Binary Sensor?

I have these garage door openers I made out of some Sonoff boards and using ESPHome for the configuration. They work perfect but I need a way to create a cover out of the binary sensor that determines if the door is open or closed. Below is the code from ESPHome and below that is the devices it creates.

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO14
      mode: INPUT_PULLUP
      inverted: True
    name: "Garage Door"
    device_class: garage_door
    
  - platform: template
    name: "Jeep"
    device_class: presence
    lambda: |-
      if (id(ultrasonic_sensor2).state < 1.5) {
        // car is in the garage
        return true;
      } else {
        // no car
        return false;
      }   
      
switch:
  - platform: gpio
    pin: GPIO12
    id: relay
  - platform: template
    icon: "mdi:arrow-up-down-bold-outline"
    name: "Garage Control"
    turn_on_action:
    - switch.turn_on: relay
    - delay: 500ms
    - switch.turn_off: relay

sensor:
  - platform: ultrasonic
    id: ultrasonic_sensor2
    trigger_pin: GPIO05
    echo_pin: GPIO04
    name: "Ultrasonic Jeep"
    update_interval: 60s
    filters:
      filter_out: nan
    timeout: 9m
    
  - platform: wifi_signal
    name: "Garage (2) WiFi Strength"
    update_interval: 300s

  - platform: uptime
    name: Garage (2) Uptime
_______________________
binary_sensor.garage_door
switch.garage_control
binary_sensor.jeep
sensor.ultrasonic_jeep
sensor.garage_2_uptime
sensor.garage_2_wifi_strength

Any help creating a cover out of the binary_sensor.garage_door to something like cover.garage_door is appreciated. That is the part that shows if the door is open or closed.

I think you can set device_class: garage_door binary sensor docs. It likely won’t actually be a cover, since more than just on/off go into a cover device.

I looked into that too but it has to have the extension cover.garage_door for it to work with several the the custom cards. I thought I could maybe do it like you do if you want to change a switch. to light. using a template but not sure how it would react.

Cover includes many more states than a binary_sensor is able to (going up, going down, stopped [not at top or bottom], etc). You’ll likely have to write a custom integration to translate a binary sensor to a cover if you actually want to use a cover for the sensor that you’ve got.

1 Like

Try a template cover.

1 Like

Owww Thanks I think that may work. Just have to bang it out and see.