Hybrid cover - MQTT for state + non-MQTT switch for actions

Hi,

I have my garage door set up as follows right now:

cover:
  - platform: template
    covers:
      garage_door:
        friendly_name: "Garage Door"
        value_template: >-
          {%- if is_state("binary_sensor.garage_door_state", "on") -%}
          Open
          {%- else -%}
          Closed
          {%- endif -%}
        icon_template:
          '{% if (states.cover.garage_door.state) == "closed" %}
            mdi:garage
           {% else %}
            mdi:garage-open
           {% endif %}'
        open_cover:
          service: homeassistant.turn_on
          entity_id: switch.sonoff_100097dbf9
        close_cover:
          service: homeassistant.turn_on
          entity_id: switch.sonoff_100097dbf9
        stop_cover:
          service: homeassistant.turn_on
          entity_id: switch.sonoff_100097dbf9

I’d like the cover to use all 4 states (open/opening/closed/closing) instead of just 2 (open/closed) in order to display a correct status in HomeKit. Currently, with only 2 states, “closing” and “opening” states are displayed rather randomly in HomeKit.

To do so, I’ve installed 2 MQTT binary sensors which report all 4 states. However, I’m struggling to implement this properly in configuration.yaml. Essentially, I’d like each of the 4 states to be reported via MQTT, but operation commands (open, close, stop) to still be performed via a Sonoff switch (integrated via HACS Sonoff component). Here is the config I’ve tried:

cover:
  - platform: mqtt
    name: "Garage Door 2.0"
    state_topic: "tele/RF_Bridge/RESULT"
    qos: 0
    retain: true
    open_cover:
      service: homeassistant.turn_on
      entity_id: switch.sonoff_100097dbf9
    close_cover:
      service: homeassistant.turn_on
      entity_id: switch.sonoff_100097dbf9
    stop_cover:
      service: homeassistant.turn_on
      entity_id: switch.sonoff_100097dbf9
    state_open: "066D39"
    state_opening: "078FC3"
    state_closed: "078FC9"
    state_closing: "066D33"
    optimistic: false
    value_template: '{{ value.x }}'

This is the config validation error:

Invalid config for [cover.mqtt]: [open_cover] is an invalid option for [cover.mqtt]. Check: cover.mqtt->open_cover.

It appears that MQTT Cover doesn’t support commands that would let me directly call a service to turn on a Sonoff switch.

Is there a workaround that would let me use a Sonoff switch to control an MQTT cover? That is apart from flashing Tasmota on the Sonoff switch to turn it into an MQTT switch and just having a full-blown MQTT cover.

Thanks!

Try a template cover :

Hi francisp, thanks for the suggestions. I believe template cover doesn’t support any states beyond ‘open’ and ‘closed’ and won’t help my situation.

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

Please correct me if I’m wrong, though.

Thank you!

there a position in the cover

position_template:

have you look at that

That’s an interesting idea, but how would HomeKit interpret a position value of say “50” as it can be both “closing” or “opening”?

Yes you right

THINKING OUT LOUD

BUT if you look at the LAST Status and the current position that should give you the maths

so

last status closed position 50% there must be opening

and

last status open position 50% there must be closing

or is it the red wine talking