home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70k stars 29.07k forks source link

Wiz plugs become unavailable (while still connected and responding in the wiz app) #117852

Open EscapeRush opened 1 month ago

EscapeRush commented 1 month ago

The problem

My Wiz Plugs becomes randomly unavailable. They are still perfectly reachable and respond from the Wiz App. My network infrastructure is on Unifi so I can tell Unify to reconnect the Wiz Plugs to the network which make them reappear in Home Assistant. So my guess is a polling/pinging error.

What version of Home Assistant Core has the issue?

2024.5.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Wiz

Link to integration documentation on our website

https://www.home-assistant.io/integrations/wiz/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.wiz
Source: helpers/update_coordinator.py:347
integration: WiZ (documentation, issues)
First occurred: May 16, 2024 at 11:57:12 AM (31 occurrences)
Last logged: 9:16:38 AM

Error fetching WiZ Socket A982C9 data: Failed to update device at 192.168.5.31:
Error fetching WiZ Socket A9565A data: Failed to update device at 192.168.5.167:
Error fetching WiZ RGBW Tunable 95B345 data: Failed to update device at 192.168.5.173:
Error fetching WiZ Socket A9E4FB data: Failed to update device at 192.168.5.250:
Error fetching WiZ Socket A8E3CF data: Failed to update device at 192.168.5.176:

Additional information

Logger: homeassistant Source: components/wiz/entity.py:70 First occurred: May 17, 2024 at 3:15:38 PM (4 occurrences) Last logged: 9:15:19 AM

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 643, in _async_run return await self.script.async_run(script_vars, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1731, in async_run return await asyncio.shield(create_eager_task(run.async_run())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 503, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 533, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 501, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 736, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 699, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2738, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2779, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 654, in _service_handler response = await self._async_start_run( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 612, in _async_start_run script_result = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 643, in _async_run return await self.script.async_run(script_vars, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1731, in async_run return await asyncio.shield(create_eager_task(run.async_run())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 503, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 533, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 501, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/trace.py", line 284, in async_wrapper await func(*args) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1206, in _async_parallel_step raise result File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1198, in async_run_with_trace await self._async_run_script(script) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1210, in _async_run_script result = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 699, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1731, in async_run return await asyncio.shield(create_eager_task(run.async_run())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 503, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 533, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 501, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 736, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 699, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2738, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2779, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 654, in _service_handler response = await self._async_start_run( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 612, in _async_start_run script_result = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 643, in _async_run return await self.script.async_run(script_vars, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1731, in async_run return await asyncio.shield(create_eager_task(run.async_run())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 503, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 533, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 501, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 736, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 699, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2738, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2779, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1000, in entity_service_call raise result from None File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1605, in async_request_call return await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1047, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 638, in async_handle_light_off_service await light.async_turn_off(**filter_turn_off_params(light, params)) File "/usr/src/homeassistant/homeassistant/components/wiz/entity.py", line 70, in async_turn_off await self._device.turn_off() File "/usr/local/lib/python3.12/site-packages/pywizlight/bulb.py", line 630, in turn_off await self.send({"method": "setPilot", "params": {"state": False}}) File "/usr/local/lib/python3.12/site-packages/pywizlight/bulb.py", line 762, in send raise WizLightConnectionError(str(ex)) from ex pywizlight.exceptions.WizLightConnectionError

home-assistant[bot] commented 1 month ago

Hey there @sbidy, mind taking a look at this issue as it has been labeled with an integration (wiz) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `wiz` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign wiz` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


wiz documentation wiz source (message by IssueLinks)

rlust commented 1 month ago

I have A19 bulbs with same issue.

SiiiiiiD commented 1 month ago

Same here for ~7 different type WIZ lights

notfork commented 1 month ago

I have the same issue on all a19 bulbs I own, have tried two different sets. I have removed from Wiz app and home assistant and re added. I also am using 3x B12 bulbs that have no issue with staying connected to home assistant. I can provide any logs or do any trouble shooting steps necessary to help with this.

sbidy commented 1 month ago

It seems not a direct issue with the integration. Because of different connectivity stacks, the app uses MQTT via TCP and the integration (must use) UDP. This means,

If it is a general issue, no bulbs will respond.

Please check:

In the past most of the time the issue is a weak Wi-Fi connection to the bulb which results in UDP datagram package lost.

Hope this helps. I try to continuously test new bulb FWs and App updates to keep this integration alive.

EscapeRush commented 1 month ago

Two problems got mixed up in this thread, for the sake of clarity i will just precise à few things.

I have problems with Wiz plugs i've had zero problems with Wiz bulbs.

So this trhread was meant to adress à probleme with Wiz plugs only.

The bulbs were still completely operational on the Wiz app when they appeared unavailable in home assistant. So if it was a connectivity issue i guess my plugs would have been unavailable in the app too which was not the case.

Anyway since disabling roaming on my unify Network and updates of the home assistant I don't have the problem anymore.

sbidy commented 1 month ago

Basically, there is no different between bulbs and switches regarding the communication and API call approach. But, what I discovered, the plugs have more problems to establish a "good" WiFi connection because these are hidden behind e.g. cupboards etc.

As mention above - there IS a big difference between the integration and the app usage. The HASS integration use a UDP stack which is in wireless networks, especially with small devices without a proper antenna and really close to high voltage systems, a bad idea. UDP can not verify if a package is transmitted successfully. There is no back channel - that's why the integration will send out a UDP datagram multiple times (kind of spamming) to ensure that the command reaches the device. Additionally, some access points or router will block or "manage" these type of UDP stuff, because normally you use UDP for e.g. data streaming.

The app uses MQTT-TLS with TCP.

EscapeRush commented 1 month ago

Oh ok i didn't get the part regarding UDP on in the hass integration.

Thanks for the clarification.

Anyway bulbs and plugs are working perfectly now.

cmd204 commented 4 weeks ago

Just chiming in here with another solution. I had the same issue with about 10-15 older A19 bulbs. I have a UniFi network setup. It looks like the bulbs were constantly jumping between multiple access points (APs). I could tell there was an issue when I went on the Wiz integration in HASS. I saw a ton of reconnecting issues in the integration. I went into the UniFi application and locked each bulk to an AP. I immediately saw the reconnection issues resolve in the Wiz integration in HASS. All my issues with the bulbs have now resolved, and I'm getting very quick and consistent response times on all of them now.

I wanted to put forward this as an alternate solution to @EscapeRush 's solution of turning off "roaming" in UniFi. I put "roaming" in quotes here, because I'm not sure there's a a way anymore, as of June 2024, to disable roaming on a WiFi network. It appears this feature may, sort of, used to exist, but not really anymore with the latest UniFi OS. I think you have either set the WiFi network to a single AP or you have to lock each network client device (e.g. each Wiz Smart bulk) to a specific AP within the client devices settings. Locking each bulk to a specific AP basically does the same thing (at the bulb level) without disabling network-wide roaming that might be useful on other devices.