MQTT binary sensor and naming question

Dear Community,

Setup:
I have binary mqtt sensor which goes regularly to deep sleep (esp32 wakeup on input - which is selfmade pir with an am312 on battery). This PIR sensor only sends “on” commands, but no “offs” - I use the delay_off function of the mqtt binary sensor.

I have two minor problems with the binary mqtt sensor:

  1. It requires an availability topic - I didn’t implement one so I need to “activate” the sensor manually by sending a manual mqtt message “online” with “retain option” - I don’t like that approach. Btw. I cant’ send a last will & testament message, because the sensor is more or less always in sleep mode. Tricky …?!
    Is there any good solution for this situation in HA?

  2. If I reboot HA I was able to see that the sensor goes first to on state after the delay_off of 300 seconds (which is my value at the time) it goes off.

Any chance to trigger the sensor to “off” after reboot? Otherwise, my light will always switch on after reboot … which quite funny but nonsense.

Totally different topic:
I recognized that HA is using the “name” attribute for the automation references. like entity_id: switch.bathroom_small_ventilator. On my HA dashboard I see now this “ugly” description bathroom_small_ventilator:

  1. I want to translate it to another language.
  2. I want to give it a nicer name.

How can I do this and not disturbing the automation references?

Many thanks for your help. I really appreciate your effort in helping me understand HA better!

Best regards
Matt

1 - availability topic is optional according to the docs, why do you need it?

2 - I don’t know about this one tbh, but didn’t want to just ignore it :slightly_smiling_face:

Friendly_name - you might have to do this via customise, but normally you can do it by clicking on the cog icon in the more info box for the entity.

@anon43302295:
Sorry, I messed up availability and availability-topic. I hope I can clarify what I meant:

@anon43302295: Thanks for that one - works perfectly, after I configured a unique_id for the items.

1 Like

Yeah, but that’s only required IF you use the optional availability key - so, if you don’t want/need to monitor availability, don’t use it :man_shrugging:

@anon43302295: In this case, I don’t understand how you should configure a PIR sensor with a binary sensor mqtt in HA. I think not every PIR sensor has a “topic” that sends online/offline state on the market, right?

(For my case it’s simple, I can just write my on c++ code and change the esp32 code to whatever I like to, but I’m a little bit astonished that there is no other way to do it in HA.)

Post your config?

@anon43302295: if that could help clarify things, why not:


switch 4:
  - platform: mqtt
    unique_id: 93u2ndu
    name: "ShellyTest"
    state_topic: "shellies/shelly1/relay/0"
    command_topic: "shellies/shelly1/relay/0/command"
    qos: 0
    payload_on: "on"
    payload_off: "off"
    retain: false
    optimistic: false



binary_sensor 25:
  - platform: mqtt
    name: "bathroom_small_pir"
    state_topic: "m2/esp32/pir/0"
    availability:
      - topic: "m2/esp32/pir/0/availability"
        payload_available: "online"
        payload_not_available: "offline"
    qos: 1
    off_delay: 300
	

timer:
  bathroom_small_light:
    duration: '00:07:00'
	
	
- id: bathroom_small_light_off
  trigger:
    platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.bathroom_small_light
  action:
    service: homeassistant.turn_off
    entity_id: switch.shellytest


- id: bathroom_small_light_on
  trigger:
    - platform: state
      entity_id: binary_sensor.bathroom_small_pir
      to: 'on'
  action:
    - service: switch.turn_on
      entity_id: switch.shellytest
    - service: timer.start
      entity_id: timer.bathroom_small_light
	  


but this alls works according to the docs - so you won’t find a problem here.

What’s wrong with doing this…

binary_sensor 25:
  - platform: mqtt
    name: "bathroom_small_pir"
    state_topic: "m2/esp32/pir/0"
    qos: 1
    off_delay: 300

?

@anon43302295: :rofl:I thought this “required” in the docs force me to use it. Sorry, my fault. Everything is running fine now without the “availability” snippet. Many many thanks!

1 Like

Yeah, if you look at your screenshot the availability list is optional.

BUT if you choose to use it, THEN you MUST include a topic for it to monitor.

Glad you’re sorted :+1: