Solved: Garage Cover w/four states won't work for me - help?

I want to make an entity that has four states for a garage door controller.

The four states would be:

  • Open
  • Opening
  • Closed
  • Closing

I have one zwave door sensor to report closed status.
I have one zwave relay that triggers the garage door to open and close.

Are there any examples that I could look at which makes use of multiple binary inputs and switches, to report into a single entity that has different icons based on the state?

Thank you!

This https://www.home-assistant.io/integrations/cover.template/ or this https://www.home-assistant.io/integrations/cover.command_line/

1 Like

Awesome, thanks. I’ll take a look!

Can some help me understand this line of code?

 value_template: "{{ states('binary_sensor.garage_main_door_closed' | float > 0) }}"

In particular, I don’t understand the | float > 0 part. What does that mean?

| float turns the text into a number.

> 0 is true if the number is greater than zero. Although I don’t really understand this as the binary sensor is only 1 or 0. It would make more sense if the value was, say, a number between 0 and 100.

1 Like

Looking a bit closer, a cover integration can have states open, closed, opening, closing - see https://github.com/home-assistant/core/blob/49d98236309e39a12a2b18142726da334bc5e457/homeassistant/components/cover/device_condition.py around line 16

I am not sure all cover integrations do have opening and closing states, as they just don’t have the info available. With your example of knowing whether the door is closed only, you’d have to use optimistic https://www.home-assistant.io/integrations/cover.template/#optimistic-mode

I’m trying to put multiple actions under the various sections but am getting an error.

cover:
  - platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Garage J Door"
        value_template: "{{ is_state('binary_sensor.garage_main_door_closed', 'on') }}"
        open_cover: 
          service: switch.turn_on
          entity_id: switch.garage_main_door_relay

          service: input_boolean.turn_on
          entity_id: input_boolean.garage_main_door_opening

It’s saying there are duplicate keys for service there, because there is. Guessing I have to go about doing multiple things under each section differently. Anyone know how I would do what I’m trying to do above correctly?

The same way you would in a script or automation:

1 Like

That sneaky little -

1 Like

I’m trying to use the garage cover but with all four states. I can’t figure out how to get it to use the “Opening” and “Closing” states for some reason - all it shows is Closed and Open. I have automations set up to toggle the four input_booleans accordingly. Do I have to do anything different or am I going about this the wrong way?

cover:
  - platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Garage J Door"
        value_template: >-
          {% if is_state('input_boolean.garage_main_door_opening', 'on') %}
            opening
          {% elif is_state('input_boolean.garage_main_door_open', 'on') %}
            open
          {% elif is_state('input_boolean.garage_main_door_closing', 'on') %}
            closing
          {% else %}
            closed
          {% endif %} 

        open_cover: 
        - service: switch.turn_on
          entity_id: switch.garage_main_door_relay
        
        close_cover:
        - service: switch.turn_on
          entity_id: switch.garage_main_door_relay
        
        stop_cover:
          service: switch.turn_on
          entity_id: switch.garage_main_door_relay

        icon_template: >-
          {% if is_state('input_boolean.garage_main_door_opening', 'on') %}
            mdi:garage-alert
          {% elif is_state('input_boolean.garage_main_door_open', 'on') %}
            mdi:garage-open
          {% elif is_state('input_boolean.garage_main_door_closing', 'on') %}
            mdi:garage-alert
          {% else %}
            mdi:garage
          {% endif %}

What you have looks correct to me.

value_template template (Exclusive)

Defines a template to get the state of the cover. Valid values are open / true or opening / closing / closed / false . value_template and position_template cannot be specified concurrently.

Am I missing something? What is creating the input booleans kike input_boolean.garage_main_door_closing

I have four automations that key off the physical zwave switch. Those move through the four different states. Maybe they’re not needed if I can get all four states in the cover working properly.

I just saw in another post something like this that I will try tomorrow morning:

open_cover:
     - condition: state
            entity_id: cover.garagedoor
            state: 'opening'
close_cover:
     - condition: state
            entity_id: cover.garagedoor
            state: 'closing'

How do I set the state of the garage cover in an automation? It seems that by default the garage cover only supports open/closed by default and I’m going to have to set the “Opening” and “Closing” states myself. Am I understanding that right? I can’t figure out how to set the state of it to try it out for some reason.

When I set the flag for opening to ‘on’ in the developer tools, the icon changes on the garage cover, but the state doesn’t change. It stays showing “Closed”. Anyone have any idea why it is not working when I set the opening flag to ‘on’? I tried setting it to both opening and Opening and there wasn’t any difference.

This is the code:

cover:
  - platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Garage J Door"
        value_template: >-
          {% if is_state('input_boolean.garage_main_door_opening', 'on') %}
            Opening
          {% elif is_state('input_boolean.garage_main_door_open', 'on') %}
            Open
          {% elif is_state('input_boolean.garage_main_door_closing', 'on') %}
            Closing
          {% else %}
            Closed
          {% endif %}

        icon_template: >-
          {% if is_state('input_boolean.garage_main_door_opening', 'on') %}
            mdi:garage-alert
          {% elif is_state('input_boolean.garage_main_door_open', 'on') %}
            mdi:garage-open
          {% elif is_state('input_boolean.garage_main_door_closing', 'on') %}
            mdi:garage-alert
          {% else %}
            mdi:garage
          {% endif %}

        open_cover: 
        - service: switch.turn_on
          entity_id: switch.garage_main_door_relay
        
        close_cover:
        - service: switch.turn_on
          entity_id: switch.garage_main_door_relay

        stop_cover:
          service: switch.turn_on
          entity_id: switch.garage_main_door_relay

If you just make four input_booleans and make a garage cover with the code above, then manipulate the input_boolean switches, I would expect that the state of the cover would be able to change to opening and closing depending on which I input_boolean I have turned on.

You can see that the Open and Closed work as I think those are the defaults. But the switches for Opening and Closing don’t change the state of the cover.

This is my test setup:

Yeah I can’t figure this out. Sort of giving up I guess until I can learn something I’m doing wrong but I can’t figure out what that is. Any tips or pointers would be appreciated.

I just saw a popup where the IDE told me that the only valid states for this are open/true or closed/false.

Take a look at the screenshot below in the red box. That would explain why I can’t get it to display anything else.

Maybe I’m using it wrong… I saw that the HA docs said there were four states for it. Maybe I’m missing something.

The source code says that there are four valid states. See https://github.com/home-assistant/core/blob/71af0fac1644821b9303815b680914b9eeca444d/homeassistant/components/template/cover.py#L46 and lines straight after.

1 Like

I see it right there in the code that it supports all four states. Any idea how I can turn on logging or something so I can debug why it’s not working? The icons change just fine, but the state won’t change. The only states it will show is “Closed” and “Open” no matter what.

Here the code I’m working with along with four boolean_inputs to test it:

cover:
  - platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Garage J Door"
        value_template: >
          {% if is_state('input_boolean.garage_main_door_closing','on') %}
            closing
          {% elif is_state('input_boolean.garage_main_door_open','on') %}
            open
          {% elif is_state('input_boolean.garage_main_door_opening','on') %}
            opening
          {% else %}
            closed
          {% endif %}

        icon_template: >
          {% if is_state('input_boolean.garage_main_door_opening','on') %}
            mdi:garage-alert
          {% elif is_state('input_boolean.garage_main_door_open','on') %}
            mdi:garage-open
          {% elif is_state('input_boolean.garage_main_door_closing','on') %}
            mdi:garage-alert
          {% else %}
            mdi:garage
          {% endif %}

        open_cover: 
        - service: switch.turn_on
          entity_id: switch.garage_main_door_relay
        
        close_cover:
        - service: switch.turn_on
          entity_id: switch.garage_main_door_relay
      
        stop_cover:
          service: switch.turn_on
          entity_id: switch.garage_main_door_relay