MQTT Connectivity sensor linked to availability topic

I’m trying to configure a Connectivity sensor connected to an availability topic that will change with MQTT Last Will. (online/offline).

{
  "dev_cla":"connectivity", 
  "name":"rho2_status", 
  "uniq_id":"rho2_status", 
  "dev":{"ids":"rho2","name":"rho2","mdl":"PLATFORMIO_D1_MINI","mf":"espressif"}, 
  "~":"homeassistant/binary-sensor/connectivity/rho2", 
  "stat_t":"~/out",
  "payload_on": "online",
  "payload_off": "offline"
}

My sensor stays always disconnected. The availability topic is:
homeassistant/binary-sensor/connectivity/rho2/out online

Please, what I’m doing wrong ? Thanks a lot for helping

Why don’t you use yaml? Did you put the platform type correctly?

Is your sensor battery powered and sleeping?

I’m using Arduino to program a Wemos d1. Upon starting the wemos will push a MQTT message (retained) with the config for the connectivity sensor as well as a Last will topic and message. I want to set up the connectivity sensor so that it reacts in HA to the availability topic, yet currently it always shows disconnected. My code up is the code posted to Mosquito broker.

Edit: Yes the sensor is powered and working

It’s working. I’m unsure what I did change to make it work, I just used the short version for the payloads on/off and suddenly it’s working.

{
   "dev_cla":"connectivity", 
   "name":"rho2_status", 
   "uniq_id":"rho2_status", 
   "dev":{"ids":"rho2","name":"rho2","mdl":"PLATFORMIO_D1_MINI","mf":"espressif"}, 
    "~":"homeassistant/binary_sensor/connectivity/rho2", 
   "stat_t":"~/out", 
   "pl_on":"online", 
   "pl_off":"offline"
}

edit: After posting I saw the error… silly me :frowning: binary-sensor Vs binary_sensor