Automation of Shelly devices slow

Hi all,

I have a physical switch connected to a Shelly2.5 relay and a light connected to a Shelly Plug S. I have installed the Shelly integration on Hass.io.
When I control the devices manually, either through HA or the Shelly app, they appear to respond instantly. So far so good.
I have created an automation that whenever the physical switch connected to the Shelly2.5 is used it toggles the state of the Shelly Plug, effectively turning the light on/off:

- id: slaapkamer_licht
  alias: 'Slaapkamer licht aan'
  trigger:
    platform: state
    entity_id: switch.slaapkamer_schakelaar
  action:
    service: switch.toggle
    entity_id: switch.slaapkamer_plug_licht

This works.
The weird thing is that it takes about 2 seconds for the light to turn on/off through the automation. Why is this? And what could be done to counter this? TIA

It appears that the state change on the Shelly2.5 takes some time to register in HA. Because if I manually fire a state_changed event (with the dev tool), I get a prompt response.
Could this be due to slow polling?

That’s why. The shelly integration is polled on a fixed interval.

If you use mqtt the status update is pushed by the device to the broker then to home assistant virtually instantly. Ditch the integration.

4 Likes

You’re spot on.

I disabled Shelly Cloud (not big loss), enabled MQTT on the Shelly2.5. Then added an MQTT switch in HA, and changed the automation to react to a state change of the MQTT switch. I left the Shelly integration in place.
Everything works instantly now. Thanks for saving my marriage!

4 Likes

I know that this is a fairly old post, but for future googlers, I believe that this is incorrect (at least, not true now):

The shelly integration is polled on a fixed interval.

I had a problem with my Shelly Uni where events only showed in HA with a ~30 second delay. I came across this thread and sure enough, switching to MQTT fixed the issue and everything worked correctly.

However, this wasn’t the end of it. Turns out that I had not read the HA integration docs closely enough:

We recommend using unicast for communication. To enable this, enter the local IP address of the Home Assistant server and port 5683 into the CoIoT peer field and push SAVE button. This is mandatory for Shelly Motion with firmware 1.1.0 or newer. After changing the CoIoT peer , the Shelly device needs to be manually restarted.

I stripped out the MQTT stuff and set up the Shelly CoIoT settings properly, then HA got the events immediately without delay and worked as expected. I suspect that something similar happened in this thread - so it’s probably not a problem with polling but rather a problem with the CoIoT configuration.

Phil

10 Likes

Local push wasn’t available in the Shelly integration when my post was written. I too am now using it and find it very good.

3 Likes

Same here. Local push support with setting the home assistant address in CoIoT peer field resolved it as well.

Adding this to help those still in search for answers. Perhaps Phil’s post should be marked as ‘SOLUTION’ in this thread.

1 Like

Editing the CoIoT info reduced my delays from 30 seconds → instant. Thanks for sharing this info!

Thank you, it solved my problem!!!

Now it is istantly :slight_smile:

Thank you very much Phil! You saved my day :slight_smile:

Even though I did this, I still get noticeable delay with Shelly RGBW2 (0.5 to 1 second). I don’t know what else to try (before trying out MQTT).

With Shelly Plus 1PM there is no noticeable delay, it’s instant. I’m wondering if it has something to do with older gen of Shelly devices, but I see in other replies that it’s instant for other people.

I might be wrong (have limited experience with RGBW2, only one in use), but I think that this module by definition forces smooth startup of light, enforcing gradual brightness to connected LEDs. Then this is the question of how fast LED starts to light up while input is gradually increasing. This is purely based on observation; even if the light is turned on directly from web interface, I can observe slight delay and transition to full brightness and gradual transition to off, when switched off.

I do have transition time set at 0.4 seconds, but that is not what I meant by noticeable delay. Let me clarify a bit.

I set up 2 physical switches to be in detached mode (1 connected to Shelly RGBW2, 1 connected to Shelly Plus 1PM) to control LED strips that are connected to RGBW2. From the moment I flip the RGBW2 switch, the transition doesn’t start at all until 0.5-1 second later, whereas when I flip the 1PM switch there is no delay, transition starts immediately.

There is no delay when controlling the LED strips from Shelly app, or Home Assistant, just when flipping the RGBW2 switch when it’s in detached mode, which means that the problem is in communication from Shelly RGBW2 to Home Assistant, and not from Home Assistant to Shelly.

I’m using Gen2 and Gen3, i followed the HA shelly automation recommedations about RCP. No multicast or colot anymore.
It’s very fast using switching the output from the app or website. The problem is SW reaction time for HA, f i setup SW as (Momentary - Every push, toggles the state ON → OFF or OFF → ON) or (Activation - Used with motion sensor. Any input turns ON and resets Auto Off timer) it’s very fast because shelly doesn’t need HA.

Problem happens when i use (Detached - Input is separated/not changing state of the output/relay) a packet is sent to HA and then HA swith on the output, it uses to take about 1,5-2 seconds

I have to test using MQTT, ping time to shelly devices is from 10 ms to 280 ms, so it doesn`t seem a wifi problem.