SOLVED: I want my MQTT sensor to show OPEN/CLOSE, not 1/0

Just getting into the MQTT game here as far as actually doing some configuring on my own.

Switched my shelly1 over from wifi to mqtt. I have communication up.

I have an open/close sensor wired into switch terminals of the shelly1, but have it setup in app as detached so its not acting on the switch status, just relaying it. So when door is shut, the switch status comes across mqtt as input 0=1. When door is open it comes across as input 0=0.

image
.
.
.

I added this into my home assistant page and it updates and everything correctly. But can I get it to show OPEN/CLOSE or ON/OFF as opposed to 1/0?

image
.
.
.

Heres my config yaml
image

Look at device class.
https://www.home-assistant.io/docs/configuration/customizing-devices/#device-class

1 Like

Theres no device class for a sensor thats shows on/off or open/close.

I tried to change sensor to binary sensor with a device_class: garage_door, but then it always shows closed even when the input changes states.

I think you want:

  • a binary_sensor flavor entity, instead of a sensor
  • a device_class: door which is a known device class
  • and specifications for payload_off: and payload_on: in your MQTT binary_sensor configuration

you might choose to select some other icon that matches the type of door you want to represent.

Alternatively, you might choose an MQTT cover entity that’s often used for door, shades, etc.

2 Likes

Yes, I just figured it out through trial and error. This worked. (changed the friendly name between the first post and now)

image
image

I don’t think that garage_door is a valid/recognized device class, at least based on the list at https://www.home-assistant.io/integrations/cover/ which does have garage in the list of options.

I have it as a binary_sensor not cover.