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
72.67k stars 30.42k forks source link

Eufy light switch control stops working #33605

Closed gblachstein closed 11 months ago

gblachstein commented 4 years ago

The problem

Eufy light switches initially work but after some time they are no longer controllable from Hassio, The Eufy application still works fine when this occurs. Resetting the switch fixes the issue for a little while but the issue eventually comes back and the switch has to be reset again. The log file is filling up with looping error messages (currently 951 occurrences).

Environment

Problem-relevant configuration.yaml


eufy:
  username: email@gmail.com
  password: !secret eufy_password
  devices:
    - address: 192.168.7.134
      access_token: CAB97F9490E7410B
      type: T1211
      name: Smart Switch
    - address: 192.168.7.133
      access_token: 4D4CB87620254F87
      type: T1211
      name: Smart Switch
    - address: 192.168.7.108
      access_token: 8B25953ED3C94FA8
      type: T1211
      name: Smart Switch
    - address: 192.168.7.110
      access_token: CCDBAC1E1DAB4DF1
      type: T1211
      name: Smart Switch

Traceback/Error logs


2020-04-03 08:43:01 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.main_lights fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 476, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/eufy/switch.py", line 34, in update
    self._switch.update()
  File "/usr/local/lib/python3.7/site-packages/lakeside/__init__.py", line 246, in update
    response = self.get_status()
  File "/usr/local/lib/python3.7/site-packages/lakeside/__init__.py", line 242, in get_status
    response = self.send_packet(packet, True)
  File "/usr/local/lib/python3.7/site-packages/lakeside/__init__.py", line 232, in send_packet
    return device.send_packet(self, packet, response)
  File "/usr/local/lib/python3.7/site-packages/lakeside/__init__.py", line 97, in send_packet
    length = struct.unpack("<H", decrypted_packet[0:2])[0]
struct.error: unpack requires a buffer of 2 bytes

Additional information

dereitz commented 4 years ago

Same issue here -- and it appears to be common among all Eufy components. In my case, I'm using a Eufy bulb. There have been some fixes in the past to address this that have helped, but I'm still intermittently seeing this issue. There are two workarounds I'm currently aware of:

  1. Restart the Eufy device (bulb in my case)
  2. Restart HASS

Both seem to resolve the issue for days->weeks.

nanowireUK commented 4 years ago

New HA user here with fresh Hass.io set up starting at ~107.5. Eufy integration config is just the username and password. Having exactly the same issue as described.

Bulbs have DHCP static IPs on same network as HA. Iā€™m rarely getting more than a day of it working before having to restart HA. Bulbs stay controllable through Eufy app at all times.

akcamperdude commented 4 years ago

Same issues here. Eufy integration is almost unusable currently.

DoctorOctagonapus commented 4 years ago

I've got three T1012s set up the same way with local access tokens and mine are at times really sluggish and occasionally failing to update at all. I don't currently have any stacktraces in my logs, but I've had over 1000 "Updating eufy light took longer than the scheduled interval" messages over the course of two days. My lights have good days and bad days but it could be anything up to a couple of minutes before they respond to controls from Hass. The Eufyhome app is always lightning fast and like OP restarting Hass or power cycling the bulb will fix the issue for a time.

dclobato commented 4 years ago

I have eleven T102 light bulbs that were working fine on 0.89... I updated to 0.113.0 and they are barely working, as described above. My log id full of "Updating eufy light took longer than the scheduled update interval 0:00:30".

Afaik, there were no updates on lakeside component, so there were no changes on how HA handles Eufy lights. Am I right?

If I restart HA, they work fine for hours/days and, suddenly, start to ignore commands from the HA, but keep working on eufy app...

eh8 commented 4 years ago

Auto-discovery doesn't work with T1012 smart bulbs, both on my trusted LAN and segregated IoT VLAN.

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment šŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

DoctorOctagonapus commented 3 years ago

I can confirm this is still an issue on the latest version. Sometimes it works, sometimes it times out.

jloutsenhizer commented 3 years ago

+1 this is still happening to me on `2021.1.4, light bulbs continue to be fully responsive via google home even with homeassistant is failing to control them.

gblachstein commented 3 years ago

This is still an issue with core-2021.1.5.

dereitz commented 3 years ago

Agreed, this is still an intermittent issue.

nanowireUK commented 3 years ago

As others have said, it is still an issue but my impression is that it has become less frequent over the last 6 months.

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment šŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

gblachstein commented 3 years ago

This is still an issue in the latest version of HA.

dereitz commented 3 years ago

Agreed, this is still an intermittent issue. It's just one of those things I've learned to workaround though... :(

DoctorOctagonapus commented 3 years ago

Is there any serious intention of actually fixing this problem? This issue has been open for over a year with loads of people affected by it but it seems no one can be bothered to put any effort into coding a fix.

DoctorOctagonapus commented 3 years ago

OK I tried switching the config to add my e-mail address and Eufy password in case that made it any better. I thought it seemed more stable at first but it is still a problem. To give you an idea, here is a log entry. Over the course of 19 hours this broken integration has failed to do its job over nine hundred times. The app works perfectly, as does my Google Home, which is linked directly to EufyHome, rather than pulling the lights from HA.

Logger: homeassistant.components.light
Source: helpers/entity_platform.py:657
Integration: Light (documentation, issues)
First occurred: 24 May 2021, 22:14:07 (938 occurrences)
Last logged: 17:33:11

Updating eufy light took longer than the scheduled update interval 0:00:30
DoctorOctagonapus commented 3 years ago

Someone (not a dev) did some digging and found this dependency issue, which may be causing the problem. https://github.com/google/python-lakeside/issues/2

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment šŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

eh8 commented 3 years ago

Eufy still fails to activate upon network discovery or manual specification of devices in configuration.yaml

DoctorOctagonapus commented 3 years ago

The link I posted a couple of months ago has the solution. There is a dependency issue that needs fixing in the container. Until this is done this plugin will not work properly.

In my environment it is still very much intermittent and it is fairly random whether the light will respond immediately, after a delay of several minutes, or fail to respond at all.

DoctorOctagonapus commented 3 years ago

Since it looks like no one's planning on fixing this any time, does anyone on here know anything about Python who could shed some light on how to fix it ourselves? If we can work out a fix we can just fork the thing and use it as a custom integration or something.

From the python-lakeside issue I linked before: "I used pip3 to attempt to install everything in the import statements and it started working fine." Well obviously there's no pip3 here so does that mean it's set somewhere else?

Here are all the import statements I've found in https://github.com/google/python-lakeside.

setup.py:

import re
from setuptools import setup, find_packages
import sys
import warnings

I also found this in setup.py, which might be relevant

install_requires=[
        "protobuf",
        "pycryptodome",
        "requests",
    ]

init.py

from Crypto.Cipher import AES
import random
import requests
import socket
import struct
import threading
import time

from . import lakeside_pb2

lakeside_pb2.py

import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
from google.protobuf import descriptor_pb2

Since I'm very much not a programmer and am not familiar with the environment HassOS runs, I have no idea where to go from here. I'd appreciate any pointers.

kjake commented 3 years ago

My Eufy switches have been unavailable since August 29. I switched my config to just username and password and it did not resolve it.

I checked the Eufy API as documented in the Home Assistant docs and it still exists and works as documented, so this isn't a change to their platform that has broken something.

Logger: homeassistant.components.switch
Source: components/eufy/switch.py:26 
Integration: Switch (documentation, issues) 
First occurred: 8:41:15 PM (2 occurrences) 
Last logged: 8:41:19 PM

Error while setting up eufy platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/eufy/switch.py", line 11, in setup_platform
    add_entities([EufySwitch(discovery_info)], True)
  File "/usr/src/homeassistant/homeassistant/components/eufy/switch.py", line 26, in __init__
    self._switch.connect()
  File "/usr/local/lib/python3.9/site-packages/lakeside/__init__.py", line 229, in connect
    return device.connect(self)
  File "/usr/local/lib/python3.9/site-packages/lakeside/__init__.py", line 66, in connect
    self.update()
  File "/usr/local/lib/python3.9/site-packages/lakeside/__init__.py", line 246, in update
    response = self.get_status()
  File "/usr/local/lib/python3.9/site-packages/lakeside/__init__.py", line 242, in get_status
    response = self.send_packet(packet, True)
  File "/usr/local/lib/python3.9/site-packages/lakeside/__init__.py", line 232, in send_packet
    return device.send_packet(self, packet, response)
  File "/usr/local/lib/python3.9/site-packages/lakeside/__init__.py", line 90, in send_packet
    self.connect()

[-- snip hundreds of repeating lines --]

  File "/usr/local/lib/python3.9/site-packages/lakeside/__init__.py", line 239, in get_status
    packet.sequence = self.get_sequence()
  File "/usr/local/lib/python3.9/site-packages/lakeside/__init__.py", line 235, in get_sequence
    return device.get_sequence(self)
  File "/usr/local/lib/python3.9/site-packages/lakeside/__init__.py", line 112, in get_sequence
    packet.sequence = random.randrange(3000000)
  File "/usr/local/lib/python3.9/site-packages/google/protobuf/internal/python_message.py", line 702, in field_setter
    new_value = type_checker.CheckValue(new_value)
  File "/usr/local/lib/python3.9/site-packages/google/protobuf/internal/type_checkers.py", line 152, in CheckValue
    if not isinstance(proposed_value, numbers.Integral):
  File "/usr/local/lib/python3.9/abc.py", line 119, in __instancecheck__
    return _abc_instancecheck(cls, instance)
  File "/usr/local/lib/python3.9/abc.py", line 123, in __subclasscheck__
    return _abc_subclasscheck(cls, subclass)
RecursionError: maximum recursion depth exceeded while calling a Python object

I was able to fix my devices by unplugging them and plugging them back in. The Eufy Home app always worked though. Seem like the error is ultimately with the Lakeside library?

DoctorOctagonapus commented 2 years ago

@kjake I don't think it's Lakeside that's broken, it's the fact that Lakeside is missing a dependency because the manifest.json doesn't have it listed in the requirements section.

If I'm reading it right, someone needs to update this: https://github.com/home-assistant/core/blob/dev/homeassistant/components/eufy/manifest.json

and change

  "requirements": ["lakeside==0.12"],

to add all the unmet requirements I mentioned in my last comment. I think that's it anyway, can someone confirm?

DoctorOctagonapus commented 2 years ago

OK further to my last post, I discovered from reading forum posts that you can effectively overwrite a built-in integration with a custom integration of the same name and HA will use the custom integration. What I've done then is just download all the files for the eufy light and switch integration, stick them in a eufy folder in my custom_integrations folder, and update manifest.json to include the missing requirements.

I did this yesterday and touch wood that seems to have solved the problem with my lights. I still occasionally get delay warnings and failure messages in my log, but my lights are now at least responding to commands correctly.

I've made my own Github repo with my modified files if anyone wants to try them out on their setup, just stick them in a folder called eufy in your custom_components folder and restart the service. You don't need to modify any yaml files. To be clear, this is a workaround, not a fix.

https://github.com/DoctorOctagonapus/HA-Eufy-Integration

Let me know how you get on using this, if there's still a problem it will probably be beyond my knowledge to fix I'm afraid.

gblachstein commented 2 years ago

Excellent work Doctor, so far so good. This is the first time I got my switches to work without resetting them all individually.

DoctorOctagonapus commented 2 years ago

OK from a couple of weeks of using the custom integration, I can confirm it works a hell of a lot better than the official version but it's not perfect. I don't know if anyone else can confirm but I've found it's a lot more stable if I configure it with the e-mail and password than if I use the access token approach. With that set up I'd say the failure rate is around 50% as opposed to the 90% failure I was seeing with the official integration. It does start to get less reliable the longer HA has been running as well, no idea why that is.

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment šŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

gblachstein commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment šŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

gblachstein commented 2 years ago

This is still an issue in the latest version.

DoctorOctagonapus commented 2 years ago

Yeah the custom version I made isn't perfect but the official version is definitely still broken.

I think there might be something wrong with the lakeside component at the heart of the integration. If so we might be SOL because there's been no commits since 2019 and the guy who wrote it seems to have abandoned his account.

duckbrain commented 2 years ago

It does look like python-lakeview isn't being maintained, but there were a few people who submitted PRs against it to add a guard against malformed devices. I wonder if that patch could make it more resilient. https://github.com/google/python-lakeside/pull/20

Seeing as the dependency isn't maintained and the code is simple, it'd probably be better to copy it into home assistant and apply the patch to maintain it in the future.

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment šŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

DoctorOctagonapus commented 1 year ago

This is still a problem.

gblachstein commented 1 year ago

Yes, this is still a problem.

gblachstein commented 1 year ago

Did anything change with the latest release? I don't see anything listed in the release notes, but I just upgraded to 2023.1.5 and all of my inactive Eufy switches are now showing active again without me having to have reset the devices manually. Can anyone else confirm?

gblachstein commented 1 year ago

Nevermind, I updated to 2023.2.4 and it's broken again :(

DoctorOctagonapus commented 1 year ago

The latest release of HA Core has upgraded Lakeside from 0.12 to 0.13. Can anyone confirm if this fixes the issue?

The lakeside repo linked above has now been marked as archived, so it's likely now being maintained elsewhere.

gblachstein commented 1 year ago

The latest release of HA Core has upgraded Lakeside from 0.12 to 0.13. Can anyone confirm if this fixes the issue?

The lakeside repo linked above has now been marked as archived, so it's likely now being maintained elsewhere.

It is now working for me. I had to remove your custom component to get it working properly.

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment šŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

akcamperdude commented 1 year ago

I know there only seem to be a few of us who care, but it's still not working for me. These switches are nearly unusable via HA.

gblachstein commented 1 year ago

I too am still having issues with these switches. They don't work at all now.

dereitz commented 1 year ago

I'd recommend giving up on the Eufy integration and going to Zigbee or something instead.

gblachstein commented 1 year ago

It's been over three years since this integration has worked consistently. IMHO, it should either get fixed properly, or let people know that these switches will not work properly on the HA documentation page. The Eufy app and google assistant integration still works fine so they are what I currently use to control these switches.

DoctorOctagonapus commented 1 year ago

It's intermittent for me, at the moment it's OK about 80% of the time, but it's still problematic.

As we've said further up the thread it's not HA that's the issue, it's Lakeside that the integration depends on that's not working properly. The new repo has issues disabled as well so good luck telling them it's broken.

issue-triage-workflows[bot] commented 11 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment šŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.