Why is this binary sensor 'unavailable' after each restart

I recently updated my Outlander Detector project to send the MQTT config for a binary sensor and reset switch upon starting.

Here is the MQTT discovery data as shown in the MQTT info section.

'Car Home Sensor' (binary_sensor.car_home_sensor)
MQTT discovery data:
Topic: homeassistant/binary_sensor/garage/carHomeSensor/config
Payload
   name: Car Home Sensor
   device_class: presence
   state_topic: homeassistant/binary_sensor/garage/carHomeSensor/state
   payload_on: home
   payload_off: away
   qos: 1
   availability_topic: homeassistant/binary_sensor/garage/carHomeSensor/availability
   unique_id: CarHomeSensor
  device:
     name: Car Home Sensor
     manufacturer: NandPez
     model: Outlander Detector
     sw_version: '1.3'
     identifiers:
      - CarHomeSensor
      - RstCHS
   platform: mqtt
'Reset' (switch.reset)
MQTT discovery data:
Topic: homeassistant/switch/garage/carHomeSensor/config
Payload
   name: Reset
   icon: 'mdi:lock-reset'
   command_topic: homeassistant/switch/garage/carHomeSensor/set
   state_topic: homeassistant/switch/garage/carHomeSensor/state
   availability_topic: homeassistant/binary_sensor/garage/carHomeSensor/availability
   unique_id: RstCHS
   device:
     name: Car Home Sensor
     manufacturer: NandPez
     model: Outlander Detector
     sw_version: '1.3'
   identifiers:
      - CarHomeSensor
      - RstCHS
   platform: mqtt

This works as expected until I restart HA. Both entities are unavailable following a restart and the MQTT info section is now completely blank.

I’m assuming there is something wrong with my config setup as I can see from listening to the relevant topic that the device does come online and send it’s current status when HA has restarted but as there is no config info for those topics nothing happens (i’m assuming).

Hi :slight_smile:

Your problem is with:

At startup, HA will check the availability status at this topic.
Make sure that this data is present when HA needs it.
Best practise would be to send retained data to this topic.

You star! Sending config on availability check has been solved it! thanks.