Native Shelly integration is very slow to recognise state change

I have a Shelly 1L. One of the switch inputs is in detached mode and I have an automation setup I’m HA to turn on another light.
I am using the native Shelly integration
I have configured the CoIoT with unicast to home assistant. (This improved the time from 20 sec to 1 sec)
I have a UniFi edge router and the shellies are on a seperate vlan to HA.
I have the mDNS repeater configured.

Any ideas how to improve the performance?
I don’t want to set up MQTT if I don’t have to…

I am currently dealing with the same issue on an i3, where the delay ranges from 1 to as much as 7s. One input is used in HA, the other uses Shelly direct device communication, and the direct comm latency appears to be around 50ms

I have not had time to see if it is a delay in getting the coap packet to HA (doubtful given DDC latency) or in processing the packet

With correctly configured Shelly devices, the delay should not be noticeable (measured in ms).

Please enable debug for homeassistant.components.shelly in logger configuration and look at your log. If everything works as it should you will have entries like this:

2021-03-15 15:13:43 DEBUG (MainThread) [homeassistant.components.shelly] Manually updated shelly1l-84CCA8ADBE94 data
2021-03-15 15:13:43 DEBUG (MainThread) [homeassistant.components.shelly] Finished fetching shelly1l-84CCA8ADBE94 data in 0.040 seconds

If you’ll have entries like this:

2021-03-15 15:13:44 DEBUG (MainThread) [homeassistant.components.shelly] Polling Shelly Device - shelly1l-84CCA8ADBE94

you have network problems and they generate delays.

Hello, Thanks for your reply.
I took a look at the logs
I am using one of the channels of ‘Anna’s Room Light’ to switch the ‘Hall Light’ the logic is in home assistant. from your example, it looks like it is set up correctly. although i don’t have the second line with ‘Finished fetching’.
I have another automation set-up the same except I have a toggle switch on the dashboard. That switches the light almost instantly.

2021-05-06 21:53:45 DEBUG (MainThread) [homeassistant.components.shelly] Manually updated Hall Light data
2021-05-06 21:53:49 DEBUG (MainThread) [homeassistant.components.shelly] Manually updated Anna's Room Light data
2021-05-06 21:53:50 DEBUG (MainThread) [homeassistant.components.shelly] Manually updated Hall Light data
2021-05-06 21:53:52 DEBUG (MainThread) [homeassistant.components.shelly] Manually updated Anna's Room Light data
2021-05-06 21:53:52 DEBUG (MainThread) [homeassistant.components.shelly] Manually updated Hall Light data
2021-05-06 21:53:53 DEBUG (MainThread) [homeassistant.components.shelly] Manually updated Anna's Room Light data


I temporarily turned on longing from the Shelly. Here it is, I don’t know if it helps…

101336625817:1620304351137179 mgos_sys_config.c:174   Saved to conf9.json
101336713385 mgos_http_server.c:180  0x3fff236c HTTP connection from 192.168.2.80:54580
101341226590 mgos_http_server.c:180  0x3fff236c HTTP connection from 192.168.2.80:54590
101341240388 json.c:420              RAM: 50448 total, 37472 free
101346153442 shelly_ping_check.c:154 Ping 192.168.20.1 (1)
101346158047 shelly_ping_check.c:109 Ping response (1, 5)
101346184710 switch1pm.c:338         ==== inputs changed: 00000000 -> 00000002 initial=0
101346187846 switch1pm.c:368         ========= output 0 state=0 same=1
101346190374 switch1pm.c:368         ========= output 1 state=1 same=0
101346192893 switch1pm.c:238         idx 1 ison 1
101346238310 mgos_http_server.c:180  0x3fff258c HTTP connection from 192.168.2.80:54603
101346249203 json.c:420              RAM: 50448 total, 37388 free
101346984830 shelly_longpush.c:51    LONGPUSH: channel[1]: event[1]
101347804665 switch1pm.c:338         ==== inputs changed: 00000002 -> 00000000 initial=0
101347807809 switch1pm.c:368         ========= output 0 state=0 same=1
101347810347 switch1pm.c:368         ========= output 1 state=0 same=0
101347812876 switch1pm.c:238         idx 1 ison 0
101351244631 mgos_http_server.c:180  0x3fff20dc HTTP connection from 192.168.2.80:54618
101351258388 json.c:420              RAM: 50448 total, 37800 free
101354304724 switch1pm.c:338         ==== inputs changed: 00000000 -> 00000002 initial=0
101354307320 switch1pm.c:368         ========= output 0 state=0 same=1
101354310420 switch1pm.c:368         ========= output 1 state=1 same=0
101354312947 switch1pm.c:238         idx 1 ison 1
101355104908 shelly_longpush.c:51    LONGPUSH: channel[1]: event[1]
101356153504 shelly_ping_check.c:154 Ping 192.168.20.1 (1)
101356158701 shelly_ping_check.c:109 Ping response (1, 5)
101356423894 mgos_http_server.c:180  0x3fff236c HTTP connection from 192.168.2.80:54633
101356437620 json.c:420              RAM: 50448 total, 37804 free
101361258393 mgos_http_server.c:180  0x3fff236c HTTP connection from 192.168.2.80:54644
101361272275 json.c:420              RAM: 50448 total, 37844 free
101361864575 switch1pm.c:338         ==== inputs changed: 00000002 -> 00000000 initial=0
101361867174 switch1pm.c:368         ========= output 0 state=0 same=1
101361870287 switch1pm.c:368         ========= output 1 state=0 same=0
101361872831 switch1pm.c:238         idx 1 ison 0
101365444719 switch1pm.c:338         ==== inputs changed: 00000000 -> 00000002 initial=0
101365447875 switch1pm.c:368         ========= output 0 state=0 same=1
101365450428 switch1pm.c:368         ========= output 1 state=1 same=0
101365452968 switch1pm.c:238         idx 1 ison 1
101365863807 shelly_sntp.c:433       minute tick at 22:03:00
101366153542 shelly_ping_check.c:154 Ping 192.168.20.1 (1)
101366158090 shelly_ping_check.c:109 Ping response (1, 5)
101366244972 shelly_longpush.c:51    LONGPUSH: channel[1]: event[1]
101366270914 mgos_http_server.c:180  0x3fff23e4 HTTP connection from 192.168.2.80:54657
101366284586 json.c:420              RAM: 50448 total, 37720 free
101367644517 switch1pm.c:338         ==== inputs changed: 00000002 -> 00000000 initial=0
101367647112 switch1pm.c:368         ========= output 0 state=0 same=1
101367650264 switch1pm.c:368         ========= output 1 state=0 same=0
101367652817 switch1pm.c:238         idx 1 ison 0
101371276280 mgos_http_server.c:180  0x3fff23e4 HTTP connection from 192.168.2.80:54670
101371290053 json.c:420              RAM: 50448 total, 37800 free
101374887396 mgos_http_server.c:180  0x3fff23e4 HTTP connection from 192.168.2.80:54678

Maybe I am expecting too much. I looked at the new aotomation trace, it is taking about half a second. Is that normal

Same automation using binary input 0.04sec

You may want to try the ShellyForHass custom integration. It is still updated and maintained.
I’m still using it as I just don’t want to go through changing to the native integration.

The Coap protocol does seem very sensitive to WiFi strength though, every once and a while I notice the state change is a little slow because I have smart bulbs automated to turn on and off with the switch.