Add Remote Shelly ONE Device to Home Assistant Server Using MQTT

I have a centralized Home Assistant running inside a Docker Container that controls 4 remote locations using MQTT. The Shelly 1 switch on my dashboard is greyed out and is unavailable under the Entities category.

I tested the MQTT connection and it’s connected as shown:

{
    "wifi_sta": {
        "connected": true,
        "ssid": "****************",
        "ip": "*****************",
        "rssi": -62
    },
    "cloud": {
        "enabled": false,
        "connected": false
    },
    "mqtt": {
        "connected": true
...
}

Under the Home Assistant Web Settings > Entities, I see the switch but it has a red :exclamation: mark under the status column and is showing “Unavailable”.

The configuration file for the switch:

# MQTT Devices
mqtt:
  - switch:
      unique_id: bathroom_light
      name: "Bathroom Light"
      state_topic: "shellies/shelly1-**************/relay/0"
      command_topic: "shellies/shelly1-**************/relay/0/command"
      availability:
        - topic: "shellies/shelly1-**************/online"
      payload_on: "ON"
      payload_off: "OFF"
      payload_available: "true"
      payload_not_available: "false"
      retain: true
      qos: 1

When I log directly into the local Shelly web interface and press the on/off button, I can see the recorded MQTT logs on my remote home assistant server. This tells me that it’s talking to the server and the message exchange works.

Message 21 received on shellies/shelly1-**************/relay/0 at 8:27 PM:
off
QoS: 1 - Retain: false
Message 20 received on shellies/shelly1-**************/relay/0 at 8:26 PM:
on

I also tried restarting the Home Assistant and MQTT containers but no luck.

Am I missing something? I used to be able to control the switch from the dashboard before but it stopped working. I don’t recall doing any updates to my Home Assistant server.

I finally figured it out with the help of this post.

In order to make the entity available, here are the steps.

  1. Go to Settings > Devices & Services > MQTT > Configure from the Home Assistant Dashboard
  2. (Optional) Under Listen to a topic - type shellies/# and click Start Listening
  3. Under “Publish a packet” topic, enter “shellies/shelly1-xxxxxxxxxxxx/online” and under Payload, put “online” without quotes
  4. Finally, click Publish

Voila! The dreadful exclamation mark is gone, and it’s now showing up on my dash board. Hope this helps someone.