Struggling with MQTT Cover (using 2 relays to open/close garage roller door)

im having a bit of bother trying to control my garage door, ive watched dr zzs video (both of them) and made my own node mcu running tasmota.

i have the reed switch working so the open/closed state is fine and working great, but im having problems with the cmnd setting.

as my door needs 2 relays to operate the door, one triggers the open shutter and one operates the close.

on most garage lifters they only use one relay and its a toggle on / toggle off

mine pulses relay 2 for 0.5seconds to open the door and 0.5 seconds on relay1 to close the door.

problem im having with cover.yaml is that the state topic has to have power1 and power2 so i try to use a wildcard but its not allowed in the configuration.

  • platform: mqtt
    name: “garage roller door”
    state_topic: “tele/garagedoor/SENSOR”
    command_topic: “cmnd/garagedoor/+” (+ is a wildcard but it would usually say POWER here but i need POWER1 and POWER2)
    availability_topic: “tele/garagedoor/LWT”
    qos: 1
    payload_open: “ON”
    payload_close: “OFF”
    payload_stop: “na”
    state_open: “1”
    state_closed: “0”
    payload_available: “Online”
    payload_not_available: “Offline”
    optomistic: false
    retain: false

if anyone could help me out please as really struggling to make it open the door or close the door

i can trigger it using mqtt as a switch but i want it to work using the cover buttons

1 Like

I think perhaps you need an intermediate step, such as an automation that reacts to a dummy MQTT topic.

So the automation is triggered by a change to dummy/payload and then triggers relay 1 or relay 2 depending which message was received.

PS I probably didn’t explain that very well.

1 Like

Could you use the ON topic for 1 relay and OFF topic for the other? Are you able to modify the Tasmota FW? I used to have an ESP on my garage door using MQTT to control, but haven’t tried Tasmota for this (just relays for lights). I used the Wemos D1 mini with a relay shield and cobbled together code from various online sources. It worked well and I know it would work for multiple relays, but it’s not as simple as Tasmota. Have you looked into ESPhomeyaml? This might be able to do what you need.

So the topics to open and close the door are:

Open door: cmnd/garagedoor/POWER1
Close door: cmnd/garagedoor/POWER2

What is the payload for the two topics? Is it ‘ON’ for both or is it ‘ON’ for the first topic and ‘OFF’ for the other?

Yes the payload is on for one relay but the other can be be quickly changed to on or off just a matter of moving one wire to the n/o or n/c on the relay

I had it as off as then I thought I could get the tasmota rules to make both relays spit out stat.garagedoor.POWER for each but it only seems to work for sensors

I’ll give the dummy mqtt messages a try tonight with some booleans, unless anyone has an easier way, it’s a shame I can’t get a floating relay and have it either go to position 1 and then back to float or position 2 back to float.

There are 3 terminals in the roller door,

Common and then up and down you jumper between up and gnd or down and gnd I could use it on one relay and have it’s no state as open and nc and closed but that means if I was manually to press the up on the doors panel manually would it not get confused as the relay still in its closed position with the relay holding it Down

If you make both relays respond to ON then here’s some code you can use.

  • The cover publishes ON/OFF to a dummy topic that’s monitored by a binary_sensor.
  • An automation is triggered by the sensor’s state-changes.
  • When the sensor is ON, the automation publishes ON to cmnd/garagedoor/POWER1.
  • When the sensor is OFF, the automation publishes ON to cmnd/garagedoor/POWER2.

Be advised that I have not tested it so it may require some adjustments and experimentation.

cover:
  - platform: mqtt
    name: "Garage Roller Door"
    state_topic: "tele/garagedoor/SENSOR"
    command_topic: "home/garagedoor/command"
    availability_topic: "tele/garagedoor/LWT"
    qos: 1
    payload_open: "ON"
    payload_close: "OFF"
    #payload_stop: "na"
    state_open: "1"
    state_closed: "0"
    payload_available: "Online"
    payload_not_available: "Offline"
    optimistic: false
    retain: false

binary_sensor:
  - platform: mqtt
    name: "Garage Door Command"
    state_topic: "home/garagedoor/command"
    payload_on: "ON"
    payload_off: "OFF"

automation:
  - alias: "Garage Door Controller"
    hide_entity: true
    trigger:
      platform: state
      entity_id: binary_sensor.garage_door_command
    action:
      service: mqtt.publish
      data_template:
        payload: "ON"
        topic: >
          {% if is_state("binary_sensor.garage_door_command", "ON") %}
            "cmnd/garagedoor/POWER1"
          {% else %}
            "cmnd/garagedoor/POWER2"
          {% endif %}

EDIT
One thing this does not handle is the cover’s stop command. I suggest setting its payload to OFF otherwise “na” will goof up the binary_sensor and automation.

Thankyou I will give it a go when I’m home later

You could just trigger the automation off the MQTT message, rather than having an additional binary sensor.

You’re right! I did some reading and I’ve revised the automation to use MQTT Trigger. This version monitors the MQTT topic directly and doesn’t need the binary_sensor as a middleman.

- alias: 'Garage Door Controller'
  trigger:
    - platform: mqtt
      topic: home/garagedoor/command
  action:
      service: mqtt.publish
      data_template:
        payload: "ON"
        topic: >
          {% if trigger.payload == "ON" %}
            cmnd/garagedoor/POWER1
          {% else %}
            cmnd/garagedoor/POWER2
          {% endif %}

@gazzaman2k

I believe my suggestion has a flaw. If you reboot Home Assistant (or simply reload Automations) it may cause the ‘Garage Door Controller’ to check the current state of home/garagedoor/command and act on it. I strongly recommend you include a ‘reboot/restart’ scenario in your testing! The last thing you want is this silly automation to open your garage door when Home Assistant restarts!

1 Like

thanks i done the one you suggested above and its working great :slight_smile: just had to make a few mods with the code and remove the quotes on the mqtt commands as they were being published along with them

- id: '1538253013402'
  alias: "Garage Door Controller"
  hide_entity: true
  trigger:
    platform: state
    entity_id: binary_sensor.garage_door_command
  action:
    service: mqtt.publish
    data_template:
      payload: "ON"
      topic: >
        {% if is_state("binary_sensor.garage_door_command", "**on**") %}
          cmnd/garagedoor/**POWER2**
        {% else %}
          cmnd/garagedoor/**POWER1**
        {% endif %}

once i done that it works great

Thankyou all for your help :slight_smile:

You’re welcome! Glad to hear it works!

That was literally the first automation I’ve ever built so it was bound to have some rough edges. Be sure to carry out the test I suggested (restart Home Assistant) to confirm the automation doesn’t trigger the garage door.

My Config:

cover:
  - platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Garage_Door_1"
        value_template: >-
          {% if is_state('sensor.door1_garage_sensor_1', 'ON') %}
            open
          {% else %}
            closed
          {% endif %}
        open_cover:
          service: mqtt.publish
          data:
            topic: cmnd/Door1_garage/power1
            payload: ON
        close_cover:
          service: mqtt.publish
          data:
            topic: cmnd/Door1_garage/power2
            payload: ON