AlexxIT / SonoffLAN

Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant
https://github.com/AlexxIT/Blog
MIT License
2.61k stars 408 forks source link

Problem with custom device_class after Hass v2024.1 #1333

Closed Kydonakis closed 5 months ago

Kydonakis commented 6 months ago

In v.3.5.4 and core v.2024.1.5 my two L1 led strips are not seen by the integration and I get the following debug:

This error originated from a custom integration.

Logger: custom_components.sonoff.core.ewelink
Source: custom_components/sonoff/core/ewelink/__init__.py:57
Integration: Sonoff (documentation, issues)
First occurred: 8:20:06 AM (4 occurrences)
Last logged: 8:38:59 AM

1000f7d8f7 !! can't setup device
1000ee2049 !! can't setup device
Traceback (most recent call last):
  File "/config/custom_components/sonoff/core/ewelink/__init__.py", line 57, in setup_devices
    entities += [cls(self, device) for cls in get_spec(device)]
                                              ^^^^^^^^^^^^^^^^
  File "/config/custom_components/sonoff/core/devices.py", line 469, in wrapped
    classes = func(device)
              ^^^^^^^^^^^^
  File "/config/custom_components/sonoff/core/devices.py", line 417, in get_spec
    classes = get_custom_spec(classes, device["device_class"])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/sonoff/core/devices.py", line 437, in get_custom_spec
    classes = [spec(classes[0], base=device_class)] + classes[1:]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/sonoff/core/devices.py", line 89, in spec
    return type(cls.__name__, DEVICE_CLASS[base], {**bases, **kwargs})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 408, in __init__
    wrap_attr(cls, property_name)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 380, in wrap_attr
    raise TypeError(f"Can't override {attr_name} in subclass")
TypeError: Can't override _attr_supported_features in subclass

Tried so far 3.5.3 and 3.5.4 will all core versions since 2023.12.4 (last one working fine) but with no luck.

In core v.2023.12.4 I get this device diag:

     "options": {
      "mode": "auto",
      "debug": false
    },
    "errors": [],
    "device": {
      "uiid": 59,
      "params": {
        "bindInfos": "***",
        "version": 8,
        "only_device": {
          "ota": "success"
        },
        "sledOnline": "on",
        "ssid": "***",
        "bssid": "***",
        "switch": "on",
        "light_type": 1,
        "colorR": 127,
        "colorG": 0,
        "colorB": 255,
        "bright": 13,
        "mode": 1,
        "speed": 100,
        "sensitive": 7,
        "rssi": -75,
        "fwVersion": "3.4.3",
        "staMac": "***"
      },
      "model": "L1",
      "online": true,
      "local": null,
      "localtype": null,
      "host": null,
      "deviceid": "1000f7d8f7"
    }
  }
}

Whereas in core v.2024.1.5 the same device diag is:

     "options": {
      "mode": "auto",
      "debug": false
    },
    "errors": [],
    "device": {
      "deviceid": "1000f7d8f7"
    }
  }
}

Any ideas?

AK-github888 commented 5 months ago

I had a similar problem after updating the core and operating system: all (!) SONOFF devices were not recognized. I then also updated the SONOFF LAN in HACS, then rebooted. After that everything works again.

Kydonakis commented 5 months ago

That is not similar to my problem; no restart could save the day. I've tested all core versions after 2024.12.3 (last stable) with the latest SonoffLAN versions (3.5.3 and 3.5.4). Same, reproducible error, yet no feedback.

I will either skip updating the core for ever, or replace the problematic L1s with other led strips.

AlexxIT commented 5 months ago

Please show full device diagnostics

Kydonakis commented 5 months ago

Thanks @AlexxIT. Just updated to core v.2024.1.6 just to get the device diag:

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2024.1.6",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.11.6",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Athens",
    "os_name": "Linux",
    "os_version": "6.1.71-haos",
    "supervisor": "2024.01.1",
    "host_os": "Home Assistant OS 11.4",
    "docker_version": "24.0.7",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {
    "alexa_media": {
      "version": "4.9.0",
      "requirements": [
        "alexapy==1.27.10",
        "packaging>=20.3",
        "wrapt>=1.14.0"
      ]
    },
    "browser_mod": {
      "version": "2.3.0",
      "requirements": []
    },
    "meross_lan": {
      "version": "4.5.3",
      "requirements": []
    },
    "sonoff": {
      "version": "3.5.4",
      "requirements": [
        "pycryptodome>=3.6.6"
      ]
    },
    "hacs": {
      "version": "1.34.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "localtuya": {
      "version": "5.2.1",
      "requirements": []
    }
  },
  "integration_manifest": {
    "domain": "sonoff",
    "name": "Sonoff",
    "codeowners": [
      "@AlexxIT"
    ],
    "config_flow": true,
    "dependencies": [
      "http",
      "zeroconf"
    ],
    "documentation": "https://github.com/AlexxIT/SonoffLAN",
    "iot_class": "local_push",
    "issue_tracker": "https://github.com/AlexxIT/SonoffLAN/issues",
    "requirements": [
      "pycryptodome>=3.6.6"
    ],
    "version": "3.5.4",
    "is_built_in": false
  },
  "data": {
    "version": "a4a8c5f",
    "cloud_auth": true,
    "config": {
      "username": "***",
      "password": "***",
      "force_update": [
        "temperature",
        "power"
      ],
      "scan_interval": "00:05:00",
      "devices": {
        "1000ac3f02": {
          "device_class": "light",
          "name": "Shelf lights"
        },
        "1000a5462c": {
          "device_class": "light",
          "name": "Kitchen lights"
        },
        "1000b6cf8a": {
          "device_class": "light",
          "name": "Back bedroom lights"
        },
        "1000940497": {
          "device_class": "light",
          "name": "Entrance light"
        },
        "1000c9efc5": {
          "device_class": "light",
          "name": "Porch light"
        },
        "1000a4b634": {
          "device_class": "light",
          "name": "Lamp"
        },
        "100099b647": {
          "device_class": "light",
          "name": "Light"
        },
        "1000b691fa": {
          "device_class": "light",
          "name": "Main bedroom lights"
        },
        "1000ca0133": {
          "device_class": "light",
          "name": "Cloud light"
        },
        "1000dd1176": {
          "device_class": "light",
          "name": "Front bedroom lights"
        },
        "1000ee2049": {
          "device_class": "light",
          "name": "Back bedroom led strip"
        },
        "1000f7d8f7": {
          "device_class": "light",
          "name": "Front bedroom led strip"
        },
        "1000900866": {
          "device_class": "light",
          "name": "Hassio"
        }
      },
      "rfbridge": {
        "Door": {
          "device_class": "door",
          "timeout": 10
        },
        "Button A": {
          "device_class": "motion",
          "timeout": 10
        },
        "Button B": {
          "device_class": "motion",
          "timeout": 10
        },
        "BridgeMotionSensor1": {
          "device_class": "motion",
          "timeout": 10
        },
        "PIR3-RF1": {
          "device_class": "motion",
          "timeout": 6
        }
      }
    },
    "options": {
      "mode": "auto",
      "debug": false
    },
    "errors": [],
    "device": {
      "deviceid": "1000f7d8f7"
    }
  }
}

One of the two (L1) devices having the issues is "deviceid": "1000f7d8f7"

In the Settings/System/Logs is get the following:

2024-02-06 11:21:48.373 WARNING (MainThread) [custom_components.sonoff.core.ewelink] 1000f7d8f7 !! can't setup device
Traceback (most recent call last):
  File "/config/custom_components/sonoff/core/ewelink/__init__.py", line 57, in setup_devices
    entities += [cls(self, device) for cls in get_spec(device)]
                                              ^^^^^^^^^^^^^^^^
  File "/config/custom_components/sonoff/core/devices.py", line 469, in wrapped
    classes = func(device)
              ^^^^^^^^^^^^
  File "/config/custom_components/sonoff/core/devices.py", line 417, in get_spec
    classes = get_custom_spec(classes, device["device_class"])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/sonoff/core/devices.py", line 437, in get_custom_spec
    classes = [spec(classes[0], base=device_class)] + classes[1:]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/sonoff/core/devices.py", line 89, in spec
    return type(cls.__name__, DEVICE_CLASS[base], {**bases, **kwargs})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 408, in __init__
    wrap_attr(cls, property_name)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 380, in wrap_attr
    raise TypeError(f"Can't override {attr_name} in subclass")
TypeError: Can't override _attr_supported_features in subclass

The device remains unresponsive through the HA, however, it is fully functional in eWelink: image

AlexxIT commented 5 months ago

Finally. You should have done this a month ago :) Problem with "device_class": "light" in your YAML. You don't need this for L1, because it is light by default. Anyway it is bug and should be fixed.

Kydonakis commented 5 months ago

Now that you mention there are still some left overs in my yaml config file from the era (can't remember when exactly) when we manually added the sonoff: integration details.

It seems that I still have:

ewelink integration

sonoff: username: '' password: '' devices: 1000f7d8f7: blablabla etc...

Shall I remove them all?

Thanks for pointing to the problem!

AlexxIT commented 5 months ago

It's up to you to decide what you need. https://github.com/AlexxIT/SonoffLAN#configuration-yaml

Kydonakis commented 5 months ago

Yeap you are right. I still had few lines in my config yaml to overwrite the class of some devices (those ran by sonoff mini mostly).

Now everything is back to normal.

Thanks for the support.

AlexxIT commented 5 months ago

Thank you for posting error. Most users stop at "nothing works for me after update".

AlexxIT commented 5 months ago

https://github.com/AlexxIT/SonoffLAN/releases/tag/v3.6.0