Problem getting binary sensor (door/window) to show in Hassio

scratching my head here. I have a simple door/window sensor that senses both open and close. I have a Sonoff Bridge that registers open and close - and that successfully posts the 2 separate open and close code to my Mosquitto MQTT broker. So far, so good.

So, I want to just see if the door is open or closed in my Hassio frontend, but the entity does not appear. I must be missing something obvious… but what?

my configuration.yaml code:

binary_sensor:
  - platform: mqtt
    state_topic: "tele/sonoff_bridge/RESULT"
    name: "havedor"
    value_template: "{{value_json.RfReceived.Data}}"
    payload_on: "F8300E"
    payload_off: "F8300A"
    device_class: motion
    optimistic: false
    qos: 1
    retain: false

How to I get this sensor to be recognized as an entity (and thus make it appear in the frontend)?

Thanks, in advance!

Could you edit your post to format your config (using the guide in the blue box at the top of the page) it will make it easier for people to spot if you have indention/syntax issues etc.

Apologies - struggled a bit with that formatting. I think I got it now.

Yeah, that is much better.
Unfortunately I don’t do a lot with manual MQTT I tend to use the ESPHomeYAML which automates a lot of the config. However I just had a quick look at the docs and I noticed that retain: false doesn’t appear to be listed as a valid option for the binary sensor ( I thought the retain was set on the MQTT message itself rather than the subscribing client)

Are you running HASS.IO or another environment? Also do you get any validation errors if you check your config?

I run HASSIO and the config passes the check

I got the retain:false from this: https://www.youtube.com/watch?v=OfSbIFIJPuc&t=627s

Other than that retain line (which I honestly don’t know if that will cause it not to work) I am beyond the point I can offer more advice, hopefully someone with more MQTT manual setup experience will be able to advise further.

Out of interest is there a reason you chose the class motion over door ?

Thanks for considering. I got the “motion” bit from this vid: https://www.youtube.com/watch?v=OfSbIFIJPuc&t=627s

but I guess it could be something else.

Just out of interest have you checked with an MQTT client that the messages are in the topics you are subscribing to?

I don’t really know how the Sonoff devices work but I did notice that your topics are different to those examples. Your code has

tele/sonoff_bridge/RESULT  

the video has

tele/RF_bridge/RESULT

I don’t know if that’s critical or just the name you have given to the device (forgive me, I’m still picking this up too, but often find that someone asking basic questions can also sometimes prompt a solution)

I do know however that capitalisation needs to match in most things in HA so its always worth checking.

Good point - but I can confirm that the topic is correct. My bridge posts to tele/sonoff_bridge/RESULT, so this is OK.

Thanks, anyway

So, I was thinking if any new entity would not show up in the frontend - a more general problem… So, I added another z-wave Aeotec 6in1 sensor. Showed up fine - so it is the binary one still.

I read something about templates somewhere - do I need to use a template to the define the “look and feel” of a binary sensor for it to show up in the frontend?

You may have done this already but have you restarted home assistant after adding your binary sensor? Does it show up in dev tools?

Yes - I have restarted several times. No - it does not appear in dev tools. But good troubleshooting tips - thanks

Is the Sonos bridge is running tasmota? I guess so.

You haven’t got another entity named havdor have you?

You are right it’s odd that the config is passing but you can’t see it even in dev tools.

Have you put the binary sensor in your config directly. I have seen before where someone has defined the entities in a separate file using config split and forgot to put new entities in the right place

Yes, the Sonoff is on tasmota. And it is posting correctly to my MQTT - verified via my MQTT.fx app

I have added a json IP sensor (reporting back my IP number) right next to the “havedor” (garden door in Danish) in my configuration.yaml - and this shows up, both <> and frontend. So…still puzzled.

Sorry to bring an old topic back up, but I am having the same issue as well. If you have a resolution, I would be interested in it. The only thing that I can think of from my trouble shooting could be the name value. When I add the name, I get a not found error where the binary sensor should be. If I delete/comment the name value then it shows correctly.

   <code> binary_sensor:
      - platform: mqtt
        name: "hallway"
        state_topic: "/sensor/pir/hallway"
        payload_on: "on"
        payload_off: "off"
        off_delay: 180
     - platform: mqtt
        name: "closet"
        state_topic: "/sensor/pir/closet"
        payload_on: "on"
        payload_off: "off"
        off_delay: 180