Problem with 'cover' when using MQTT switch

Setup:

  1. Espeasy on esp8266 controlling my garage. Setup for MQTT and rest calls. Has reed switches connected to sense if door is open and closed. Works perfectly fine.
  2. Since garage door is integrated with esp8266 relay, only command I can send is ‘toggle’ which just clicks the garage switch. (i.e. there is no ‘open’ or ‘close’ explicit command)
  3. Homeassistant + node-red

Goal:

  1. Show upto date status in Homeassistant and control it through a ‘cover’ template entity.

When home assistant starts/restarts or when I want to open/close the garage door, I want to know correct status before I send the command. i.e. if door is open and i click ‘open’ button, home assistant shouldn’t send ‘toggle’ command. For this to work, home assistant should know if door is already open. Since MQTT status could be out of date we can’t rely on MQTT provided status. Alternate is to use REST sensor. So I setup a rest sensor, which works great.

Now in my cover template, I want to use REST sensor to get the state but send the command using MQTT to ‘toggle’. For some reason when I try to set sensor to rest sensor but switch to mqtt, the switch doesn’t work. The template sensor has correct state.

What could be wrong ? Does template not support mixed platform (mqtt and rest together?).

Here are my configs:

Cover (this shows the status correctly, but not able to trigger the switch)

cover:
  - platform : template
    covers :
      left_garage_door_cover :
        unique_id : "left_garage_door_cover"
        device_class : garage
        friendly_name : "Garage Door Left"
        value_template : "{{ is_state('binary_sensor.left_garage_door_rest','on') }}"
        open_cover :
          service : switch.turn_on
          data:
            entity_id : switch.garage_left_mqtt
        close_cover :
          service : switch.turn_off
          data:
            entity_id : switch.garage_left_mqtt

MQTT switch (this works independently)

mqtt:
  switch:
    - unique_id: garage_left_mqtt
      name: "Left Garage door MQTT Switch"
      state_topic: "garageLeft/IsOpen"
      command_topic: "garage/cmd"
      payload_on: "event,toggle"
      payload_off: "event,toggle"
      state_on: "1"
      state_off: "0"
      optimistic: true
      qos: 0
      retain: false

Rest sensor (this fetches status correctly)

rest:
  - scan_interval: 600
    resource: http://192.168.X.X/json
    binary_sensor:
      - name: "Left Garage Door Rest"
        unique_id: "left_garage_door_rest"
        value_template : "{{ value_json.Sensors[1].TaskValues[0].Value}}"