MQTT Cover State - multiple options (open/opening, closed/closing)

I’m using the MQTT Cover component with the Linear zwave garage door opener (on a different HASS instance). The door reports “open”, “opening”, “closing” and “closed” as states (no tilt or other position info). So when I open or close the door, i get the following error: Payload is not True or False: closing (or opening, depending which way the door is going).

Is there a way to template state_topic (maybe with value_template) so that it will recognize “opening” as the same as “open” and vice versa? It’s only a single error line so it’s not the end of the world but it’s annoying.

Here’s my current config:

  - platform: mqtt
    name: "Garage Door"
    command_topic: "homeassistant/cover/garage_door/set"
    state_topic: "homeassistant/cover/garage_door/state"
    retain: true
    device_class: garage
1 Like
value_template: "{{ 'open' in value }}"

open or opening will be true, all else will be false.

Nice! Ok, so if i need it also to be for “close” how would I define both?

Why would it matter? It’s only going to be 1 of 4 states according to you. If it’s not open or opening, its going to be closed or closing.

oh, i see what you’re saying now. i’ll give it a go, thanks!

Still getting an error, this time on reboot. And the door status reports as “unknown”

WARNING (MainThread) [homeassistant.components.mqtt.cover] Payload is not True or False: False

that’s not an error, that’s a warning.

Does it work?

No it did not. The status would show up as unknown and i couldn’t control it. Here is what ended up working with no error/warning:

    value_template: >
      {% if value == 'open' or value == 'opening' %}
      {% else %}
      {% endif %}

Well the controlling part is based on what commands it excepts from MQTT. So you need to find that out. You are using the defaults currently which are “OPEN” and “CLOSE”.

Right, the default commands work. The issue was that my door would report “closing” and “opening” and the MQTT cover doesn’t support those two states it seems. So i just needed to tell it to treat the value “opening”/"open as “open” and “closing”/“closed” as “closed” so I don’t get an error. Works perfectly fine now.

Makes sense. Wasn’t aware you needed to return ‘open’/‘closed’. I would assume it’s binary. Anyways if you want a short concise template that takes up less space you can use an inline if statement.

value_template: "{{ 'open' if 'open' in value else 'closed' }}"

Thanks! I figured there was a way to consolidate what I had. I’m not the greatest with templates/jinga.