Setup Shelly Relay with Home Assistant using MQTT

 As I keep forgetting the steps I thouht I would write a quick guide on how to setup a Shelly relay with Home Assistant, in this specific case I am using a Shelly 1PM.

This guide is going to assume that you have already wired up your Shelly relay and you have Home Assistant up and running,

Connect Shelly to your local WiFi

Firstly connect directly to the new Shelly relay by WiFi, if you scan your WiFi you should see something like Shelly1-xxxxxxx or Shelly1pm-xxxxxxx depending on which version.

Now open the Shelly App on your phone and choose Add Device, making sure the WiFi connection specified in the app is the one you want to connect the device to.

You should now see the new Shelly device discovered in the app if you go to discovered devices, check that you can turn it on/off in the app as expected.

Set the Shelly Relay with the MQTT Server Settings

For my setup I am using the MQTT platform because I couldn’t get the direct Home Assistant Shelly setup to work.

I have the mosquito MQTT setup in my Home Assistant.

Find the local IP address and name of the Shelly Relay from the Shelly App by going into setting for the device, then right at the bottom you want Device Information, this will give you the Device IP and you also want to make a note of the Device ID but only the first ID not the one in brackets.

Now in order to setup the MQTT details on the Shelly you must go to the devices web server because you can’t do this from within the shelly phone app.

Under Internet & Security you will find Advanced – Developer Settings in here you can specify to use an MQTT.

The settings can be found in your MQTT configuration in Home Assistant, enter the credentials etc.
Username: from HA
Password: from HA
Server: your HA IP address followed by the default port of 1883

The rest of the settings I just kept as a default.

Add the Shelly Relay to Home Assistant

My Shelly was going to be controlling a light so in my configuration.yaml I setup a new section for light and then entered the following code:

light:
 - platform: mqtt
   name: "Rear Floodlight"
   state_topic: "shellies/shelly1-E09806979A34/relay/0"
   command_topic: "shellies/shelly1-E09806979A34/relay/0/command"
   payload_on: "on"
   payload_off: "off"
   retain: false

The only part you need to edit is the part after shellies/shelly- enter your device ID into here using all capitals on both lines, keep everything the same.

You should also enter a your own name for the device.

Save the file and then reboot your Home Assistant and your new device will now be visible under the lights section in your dashboard and you can now setup automations etc for the device.

Comments

Popular posts from this blog

Installing Zigbee2MQTT on Home Assistant for Beginners

Home Assistant with Virgin Media SMTP Server