Issues with MQTT Cover

Need some help with my MQTT Covers. I originally just had the one (the first one below), but I’m now testing an MQTT double garage for my parents house. I added the two extra mqtt platforms to my cover.yaml file but when I try to restart HASS it fails and the error message is as follows:

Jan 27 01:37:04 raspberrypi systemd[1]: Started Home Assistant.
Jan 27 01:37:05 raspberrypi hass[32389]: ERROR:homeassistant.util.yaml:while parsing a block mapping
Jan 27 01:37:05 raspberrypi hass[32389]: in “/home/redwngsrul/.homeassistant/cover.yaml”, line 14, column 3
Jan 27 01:37:05 raspberrypi hass[32389]: expected block end, but found scalar
Jan 27 01:37:05 raspberrypi hass[32389]: in “/home/redwngsrul/.homeassistant/cover.yaml”, line 26, column 17
Jan 27 01:37:05 raspberrypi hass[32389]: Config directory: /home/redwngsrul/.homeassistant

- platform: mqtt state_topic: "home-assistant/garage/1/state" command_topic: "home-assistant/garage/1" name: "Garage" qos: 0 retain: false payload_open: "OPEN" payload_close: "CLOSE" payload_stop: "STOP" state_open: "OPENED" state_closed: "CLOSED" optimistic: false

- platform: mqtt state_topic: "home-assistant/parents/garage/dads/state" command_topic: "home-assistant/parents/garage" name: "Dads Garage" qos: 0 retain: false payload_stop: "TOGGLE_DADS" state_open: "OPENED" state_closed: "CLOSED optimistic: false

- platform: mqtt state_topic: "home-assistant/parents/garage/moms/state" command_topic: "home-assistant/parents/garage" name: "Moms Garage" qos: 0 retain: false payload_stop: "TOGGLE_MOMS" state_open: "OPENED" state_closed: "CLOSED optimistic: false

What does that mean? “expected block end but found a scalar”??? Any help would be greatly appreciated.

You’re missing a closing double quote after CLOSED. A scalar is a number.

Your entire YAML should look exactly like this:

- platform: mqtt
  state_topic: "home-assistant/garage/1/state"
  command_topic: "home-assistant/garage/1"
  name: "Garage"
  qos: 0
  retain: false
  payload_open: "OPEN"
  payload_close: "CLOSE"
  payload_stop: "STOP"
  state_open: "OPENED"
  state_closed: "CLOSED"
  optimistic: false

- platform: mqtt
  state_topic: "home-assistant/parents/garage/dads/state"
  command_topic: "home-assistant/parents/garage"
  name: "Dads Garage"
  qos: 0
  retain: false
  payload_stop: "TOGGLE_DADS"
  state_open: "OPENED"
  state_closed: "CLOSED"
  optimistic: false

- platform: mqtt
  state_topic: "home-assistant/parents/garage/moms/state"
  command_topic: "home-assistant/parents/garage"
  name: "Moms Garage"
  qos: 0
  retain: false
  payload_stop: "TOGGLE_MOMS"
  state_open: "OPENED"
  state_closed: "CLOSED"
  optimistic: false

Sorry, which line is missing the closing double quote? I don’t follow.

Nevermind, I spotted it. Wow it’s been a long day. Thanks.

Haha don’t worry about it!

I’m trying to do the same with one door using MQTT. How do you get the relay/output to toggle?

Here’s my code in first try:
cover:
- platform: mqtt
state_topic: “/garage/reed/state”
command_topic: “/garage/gpio/14”
name: “Garage”
qos: 0
retain: true
payload_open: “1”
payload_close: “1”
payload_stop: “0”
state_open: “0”
state_closed: “1”
optimistic: false

I custom made my garage board and the arduino code for the NodeMCU board that runs my garage controller. Without details on your board and the code associated, I really can’t speculate on why your relay doesn’t toggle.

The command_topic is the topic that the payload is sent to. So when you click the open/close button, it sends a “1” as a payload to /garage/gpio/14.

Your command topic leads me to believe that you have a relay connected to your raspberry pi, am I correct?

Can you provide more info?

I’m seeing some discrepancies in your code though.

I may be out of context, but you probably shouldn’t use retain: true. I would suggest making that false. For my garage, when I press the physical garage opener button (that’s wired to the garage), it simply closes a switch that passes the 24Vdc to the door activate input and moves the door. So for my Wifi Hass garage control board, I have, in essence, one relay on the board that parallels with the physical switch. If I hit the front end button for Open, Close, or Stop, they all perform the same function. They activate the relay to simulate a garage opener button press.

FYI I only have a single garage door. I show 3 up in my previous posts above because I was test building another double-garage controller for my parents house.

I’m using ESP Easy R148 and I have two switches, one on GPIO12 as a sensor for my garage door and another on GPIO14 to drive the relay. The relay needs to turn on for one second then off again to emulate the integrated garage controller. The GPIO12 switch is called ‘reed’ and is set to 'Push Button Active Low to toggle and the GPIO14 switch is called ‘relay’. I’ve now cracked it and below is rule I applied to turn the relay off after 1 second. The board is a NodeMCU v3 but I’ll be using a low voltage Sonoff in the production unit.

on System#Boot do
gpio,14,0 // Prevent relay turning on during boot
endon

on relay#state do
  if [relay#state]=1
  timerSet,1,1 // 1 second timer
endon

on Rules#Timer=1 do
  gpio,14,0 // Turn off relay
endon

If I send a MQTT message to /devicename/gpio/14 with a payload of 1, the relay turns on for one second which is great! I have the Value Name 1: for the ‘reed’ switch set to state so that when the door is closed, I get /garage/reed/state with either 1 or 0 (opened or closed). I’m now trying to figure out how to use ESP Easy rules to publish ‘open’ or ‘closed’ when the reed switch changes state. So far no luck.

Sorry, I’m not familiar with ESPEasy or the syntax of your code. I did Google “ESPEasy MQTT Publish” and found some information. Perhaps these links may help you.

http://www.letscontrolit.com/forum/viewtopic.php?t=1390#p6659

[http://www.letscontrolit.com/forum/viewtopic.php?t=709]
(http://www.letscontrolit.com/forum/viewtopic.php?t=709)

You don’t necessarily have to publish the words open or closed. The code you posted above from your cover configuration is looking for a 1 or a 0 for the state anyway. So 0 would be open and 1 would be closed, according to your yaml above. Make your ESP publish these numbers and the yaml will translate accordingly.