Door-open, door-closed, door-closed-lock how to?

I already asked this in November 2021 and still wasn’t able to find a solution …

I have built a sensor for my cellar door, that gives three states by mqtt (see title).
I have mosquitto broker up and running.

How can I use this in home assistant, especially I want to visualize it with the same MDI icons.


Should be easy enough if all you need to do is display the three states.

Create a template sensor with an icon template.

I can help you with this if you share the entity or entities and their actual states (from Developer Tools → States, not the translated states from a dashboard card).

Thank you VERY much for offering your help, I really appreciate it! :slightly_smiling_face:

Perhaps we can first start with adding the sensor to home assistant?
Snippet from my configuration.yaml:

    - name: "Brightness"
      state_topic: K14/G/Lux
      unit_of_measurement: "lux"
    - name: "Kellertuer"
      state topic: K14/F0/Door

As you can see, I already have a brightness sensor (also DIY). That one was super easy, I assume because Home Assistant knows, what a brightness sensor ist.
But adding my door sensor already gives me this error message:
Invalid config for [mqtt]: [state topic] is an invalid option for [mqtt]. Check: mqtt->mqtt->sensor->1->state topic. (See /config/configuration.yaml, line 17).


Please use proper formatting next time by putting it between three backticks. You missed the underscore in the last state_topic and used a space instead.

This really embarrasses me, please excuse me.
But it was really a bug in the linux geany editor (you can google it: “geany invisible underscore” or “geany underscore not displayed”).

I think I will now read a little bit about what a template sensor and an icon template is. Perhaps I will be able to figure it out by myself.


No need to be embarrassed. It happens to the best of us.

OK, got it working:

But I would prefer, if the sensor could always have the same door icon at the left side and shows its current state with the specific icon at the right side.
Like (for examples) a switch does.

Is that also possible?