Garage Door Template Help

I have my garage door being controlled with a Shelly 1 with a reed switch. I can not get the Lovelace card to display open or closed. It shows the status as on or off. In my config, it is set to show open or closed along with the correct icon to display an open garage or closed garage. The icon also does not changed based on door status. Here is a copy of my config. What could be wrong with the config?

# Shelly Garage Door
cover:
  - platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Garage Door"
        value_template: "{{is_state('binary_sensor.shelly_garage_door_switch', 'open')}}"
        open_cover:
          service: switch.turn_on
          data:
            entity_id: switch.shelly_garage_door_control
        close_cover:
          service: switch.turn_off
          data:
            entity_id: switch.shelly_garage_door_control
        stop_cover:
          service: switch.turn_on
          data:
            entity_id: switch.shelly_shelly_garage_door_control
        icon_template: >-
          {% if is_state('binary_sensor.shelly_garage_door_switch', 'open') %}
            mdi:garage-open
          {% else %}
            mdi:garage
          {% endif %}

Binary sensor states are only ever on or off. No matter what is displayed in Lovelace.

I understand for automations and such that the syntax needs to be on or off. But in Lovelace I wanted it to display open or closed and have the matching icon.

I keep seeing this example getting posted everywhere. Where did you find it? I want to remove it, it does nothing but lead to confusion.

Bare minimum, this is all you need to get it to display the way you want it to display.

# Shelly Garage Door
cover:
  - platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Garage Door"
        value_template: "{{is_state('binary_sensor.shelly_garage_door_switch', 'on')}}"
        open_cover:
          service: switch.turn_on
          entity_id: switch.shelly_garage_door_control
        close_cover:
          service: switch.turn_off
          entity_id: switch.shelly_garage_door_control
        stop_cover:
          service: switch.turn_on
          entity_id: switch.shelly_garage_door_control

This will show the correct icon and translated state.

I replaced my config with your code and I can still control the door, but the door status doesn’t change from closed.status

Also, none of the automations that I have set in Node Red are working. I have the lights in the garage set to turn on when the door is open and turn off when its closed. I also failed to mention before that I had some code entered in the customizations file. Does this affect things:

binary_sensor.shelly_garage_door_switch:
  device_class: garage_door
switch.shelly_garage_door_control:
  device_class: switch
  icon: mdi:swap-vertical-bold

Well your screenshot shows 4 different entities. Circle the one you expect to have a state change please.

From what I see, all 4 look correct.

In a perfect setup, I would want the “garage door position” to indicate the status. But if thats not possible, I would want the entity with the arrows to have the correct icon to indicate status and the correct arrow highlighted depending on the state. The arrows have never changed with the door status. The up arrow is always lit up. I wasn’t sure if the position entity would work since I had a value template in the config. The docs say you can’t have a position and a value template at the same time.

If the up arrow is always lit up, that means you’re using the wrong sensor to sense whether the door is open or not. So, does binary_sensor.shelly_garage_door_switch properly update when the door is open and closed?

I figured out one of the issues. There was the old Shelly for Hass HACS integration still installed and causing some issues. I uninstalled that and then the Shelly Smart Home integration discovered “new” devices. After adopting the devices, They are all defaulted to their original entity names. However, for the Shelly 1’s, it only discovers one device and one entity- the switch. It does not discover a binary sensor for the switch that has the contact sensor attached. Without the contact sensor the system has nothing to tell it if the door is open or closed. Is there something I’m missing to get the binary sensor discovered?

I also noticed that it appears each device is kind of its own integration. When I click on each device, it then tells me how many entities and gives me the system options.shelly shelly1

I just activated another Shelly 1. HA only discovered one device and one entity with this one also. Only the switch is discovered, not the binary sensor for the switch.

From reading other threads on the forum, it appears that the switch status as a binary sensor is not implemented into the new Shelly integration. Is that the case or did I read things wrong?

It’s a new integration. So quite possibly not all features are implemented yet.

If I were you I would delete the integration and configure manually with mqtt.

MQTT is local push (for very fast response) where as the integration is polled on an interval.

I am not a programmer or anything but I find it odd that the binary sensor for switch status is not part of the integration for the Shelly 1 but the Shelly 2.5 has binary sensors for power consumption.

So if I got the MQTT route, do I have to flash the devices with Tasmota or will they work with MQTT using the factory firmware? Do I have to run all Shelly devices using MQTT or can I run MQTT only on the ones I need for binary sensors?

No flashing required. You set up mqtt on the device setting page (go to the device ip address in a web browser).

You can run some through the integration as well as some through mqtt. You may have to ignore any devices set up as mqtt if they are discovered as well.