Pointers on setting up Shelly relays for detached mode lights

Hello everyone

I am a brand new HA user so please bear with me. I’m pretty new in the automation world, at least in terms of configuration past Google Home UI!

I have got my HA server set up on a Win 11 PC running VirtualBox and I have added the majority of my smart devices, but that’s it. No automations or anything yet.

I have replaced all of my wall switches with momentary ones, and installed Shelly Relays behind them all. All bulbs are smart.

Like many before me, I realised that I need to set up detached mode in order to maintain power to the bulbs to automate anything past a basic on/off.

I have been reading old posts from here and elsewhere, and picking up fragments of information but I’m finding it hard to piece it all together, probably because I have gaps in my knowledge on how HA works & other protocols like mqtt. I would be very grateful if people could point me in the right direction!

Here’s where I am with it right now.

My Shelly relays are a mix of the 1PM Mini Gen3 and 2PM Plus.
All of my B22 bulbs are Tapo L530’s
All of my GU10 bulbs are Tuya/Smart Life
I have installed the MQTT Broker integration

The relays are currently working as Button & Momentary Switch.

So, I assume the next steps would be to:

  1. Put Shelly into Detached mode
  2. Configure Shelly to send HA notification of a button press
  3. Configure HA to toggle the bulb on/off when it detects that notification

And I think MQTT is the protocol between step 2 and 3?

Any assistance as where to go from here would be most appreciated!

Hmmm I see you haven’t gotten any responses, but I’m looking to do the same thing. Did it work?

Hi there;

You’re on the right track, and you can improve it.

I’m working on this with a friend, who’s house is getting re-built, and he’s choosing a very similar set up as you, but more.

His operation (and I recommend you follow) is as follows;

  • Light bulbs set to behave so that; ‘when power turns on - light turns on’ (Not; when power turns on, light resumes previous state).
  • ShellyPM has a script;
  • IF ShellyPM can ping Home Assistant - Shelly PM acts in Detached Mode.
  • IF Not ShellyPM can ping HA - ShellyPM acts as Toggle switch.

This way; Home Assistant responds to the ShellyPM input button, and turns smart lights on pending what you automate in HA; bright lights for day, dim for night etc. All the smarts are done in HA. Remembering you need a few things running for this to work; HA, your wireless network, and the lights at a minimum.

However, if the ShellyPM script can’t ping / communicate with HA, the setup goes into dumb mode; the button and ShellyPM acts as a toggle, and you can still manually turn the light on and off.

There are pre-written ShellyPM scripts that do the ping check with HA for this exact reason, I’ve had one working on a ShellyPM device for testing and it works well.

Hope this helps.

Also, read up on CoIoT settings for your ShellyPM. You may need the following CoIoT Settings;

Forward 5683 port to your HA instance (if in Docker or on a VM) so this traffic get from the Shelly to the HA install.

You also need to set the HA server address within each Shelly Device;