Lovelace Card to control Garage Door

Trying to figure out the best way to control my garage doors and represent state.

Doors are opened/closed by a relay toggled from an ESP8266 (Wemos D1 Mini) configured as a Cover using ESPHome. That works great, but because the door is simply toggled open/close regardless of position, I’m using Aqara door/window sensors on the doors to detect when they’re closed or open.

Ideally, I’d like to have a single button that shows an icon representing the current open/close state of the relevant door, with a toggle action that opens/closes the door when tapped.

I am not seeing any cards that seem suited to this task, however.

Is this a case where I could use conditional logic in the YAML to set the icon of a Button card based on the state of the door/window sensor?

I have been able to get pretty close using a Button card, with the entity set to the door/window sensor, and then using a Service call on the Tap action to call the cover.open service on the appropriate door.

The piece I’m missing (hence the question about conditional) is having the icon match the open/close state of the door based on the sensor (yes, I know I can have the state represented as text, but would be nice to have both that and icon).

Still fairly new to Lovelace, so apologies for the newb question.

I had achieved this at one time with the custom button card. Individual states/icons for open, close, and in-between with capacity to open/close by touch.

I learned how to do it from this video: Custom Button Card 3: Home Assistant Icons: Borders, Backgrounds and Advanced Animation - YouTube

I don’t have the yaml anymore because I just overhauled to mushroom last week but if you can’t get it, I can write it up when I get back to a computer. It was pretty straight forward from the video.

1 Like

Unfortunately, after spending a couple hours playing with it, I’m not having any luck getting the sensor state to change the icon. I’m sure if I spent more time, I could probably make it work, but not really worth the effort for the small difference it would make.

Appreciate the pointer, however!

1 Like