Why can't we use MQTT states as a conditional for automation

My garage door has a ratgdo on it, it uses MQTT.

If its up and I hit a zigbee button I want it to close and vice versa. However there is no way for me to add status of the door is open to initiate a close etc. It would be easiest to have the status of the door and the button press activate a publish command.

Any help would be appreciated.

Isn’t your garage door represented by a Cover entity? The state of the cover entity indicates if the door is currently open or closed.

If you simply want to toggle the cover’s state, you can use the cover.toggle service call (no obligation to check its current state).

Ratggo reports the door status, alledgedly


I guess I’ll have to custom define the sensor in the config.yaml file, I’ll see if that works.

It does, however no current method to use an MQTT state in the “and-if” section of automation via the webservice.

It sure does… if you define that MQTT state as an HA sensor, ofc.

I seem to be having issues doing so. I am a novice at HA, full disclosure lol

I added this in the configuration.yaml with the added on file viewer. Yet I cannot see said sensor in my entities list.

 - platform: mqtt # This is an MQTT device
   name: "Garage Door" # Choose an easy-to-remember name
   state_topic: "Garage Door/status/door" # The topic to read the current state
  1. Don’t use screenshots for code. Use actual code properly formatted

  2. Check the actual documentation rather than old posts or chatgpt. That way to define mqtt sensors is deprecated.

  1. Check the log for errors.

Oh, that does seem a much better way to share code, I edited my prev post. I’ll check out the guide your posted here shortly.

1 Like

Got it! Thank you!


I don’t understand why you need to do that when ratgdo automatically creates entities in Home Assistant that represent your garage door.

From ratgdo’s documentation:

You can also integrate with Home Assitant through MQTT. Since version 1.7, ratgdo has home assistant auto discovery over MQTT. When ratgdo boots, three discovery messages are sent via mqtt which will add a door, light and obstruction sensor entities under a single device in Home Assistant.

There should be no need to manually define an MQTT Sensor.

1 Like

Oh, maybe I don’t have my auto discovery properly configured?

I see nothing in my devices/entities.

Well looky here…. Is this due to having a space between Garage and door?

Something is amiss because the documentation clearly states that ratgdo is capable of automatically creating all necessary entities in Home Assistant.

I think I might have found my issue. Look above your post. I’ll rename my ratgdo and see if that helps.

After you fix it, and a cover entity is automatically created for your garage door, you can use it to determine the door’s state (open/closed).

I believe other entities will also be created, such as the ability to control the opener’s light.