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.67k stars 414 forks source link

Fan not working after HA 2024.1 and 3.5.4 release - maximum recursion depth exceeded #1313

Closed jmcollin78 closed 7 months ago

jmcollin78 commented 8 months ago

Hello,

I have the same problem as here: https://github.com/AlexxIT/SonoffLAN/issues/1301 but for fan.

I update to 3.5.4 (last release) but the problem persist for the FAN. The others devices seems to work fine.

I tried to force the installation of integration (reload it), restart HA and I still got the error.

My device is the following:

iFan04 par SONOFF Micrologiciel : 3.5.0

-- The manifest of the installed release:

{
  "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"
}

The important part is here:

File "/config/custom_components/sonoff/core/entity.py", line 113, in internal_update
    self.set_state(params)
  File "/config/custom_components/sonoff/fan.py", line 58, in set_state
    self._attr_preset_modes.index(mode or SPEED_OFF)
    ^^^^^^^^^^^^^^^^^^^^^^^

More complete log:

2024-01-06 06:45:40.062 ERROR (MainThread) [custom_components.sonoff.core.entity] Can't init device: {'name': 'Ventilateur sam', 'deviceid': '10013f49a9', 'apikey': 'f3060487-fa07-4cb1-8482-4ab52d913f5f', 'extra': {'uiid': 34, 'description': '20210709002', 'brandId': '5c4c1aee3a7d24c7100be054', 'apmac': 'd0:27:02:7e:90:a3', 'mac': 'd0:27:02:7e:90:a2', 'ui': '智能风扇灯', 'modelInfo': '607ffb615a0f126444f59385', 'model': 'PSF-BFB-GL', 'manufacturer': '深圳松诺技术有限公司', 'chipid': '008D95B2', 'staMac': '9C:9C:1F:8D:95:B2'}, 'brandName': 'SONOFF', 'brandLogo': 'https://eu-ota.coolkit.cc/logo/q62PevoglDNmwUJ9oPE7kRrpt1nL1CoA.png', 'showBrand': True, 'productModel': 'iFan04', 'tags': {'m_3f5f_jmco': 'on'}, 'devConfig': {}, 'settings': {'opsNotify': 0, 'opsHistory': 1, 'alarmNotify': 1, 'wxAlarmNotify': 0, 'wxOpsNotify': 0, 'wxDoorbellNotify': 0, 'appDoorbellNotify': 1}, 'devGroups': [], 'family': {'familyid': '61f187a1e24f680009aedb0f', 'index': -9, 'members': [], 'roomid': '61f187a1e24f680009aedb0c'}, 'shareTo': [], 'devicekey': '05d4fc0d-bf63-4d7b-b2a2-f8d57e1170b2', 'online': True, 'params': {'bindInfos': {}, 'version': 8, 'only_device': {'ota': 'success'}, 'sledOnline': 'on', 'ssid': 'LaLiveBoxDesBoulis', 'bssid': '00:00:00:00:00:00', 'init': 1, 'fwVersion': '3.5.0', 'staMac': '9C:9C:1F:8D:95:B2', 'rssi': -83, 'switches': [{'switch': 'on', 'outlet': 0}, {'switch': 'off', 'outlet': 1}, {'switch': 'off', 'outlet': 2}, {'switch': 'off', 'outlet': 3}], 'configure': [{'startup': 'on', 'outlet': 0}, {'startup': 'off', 'outlet': 1}, {'startup': 'stay', 'outlet': 2}, {'startup': 'stay', 'outlet': 3}]}, 'isSupportGroup': True, 'isSupportedOnMP': True, 'isSupportChannelSplit': False, 'deviceFeature': {}, 'device_class': 'fan'}
Traceback (most recent call last):
  File "/config/custom_components/sonoff/core/entity.py", line 86, in __init__
    self.internal_update(params)
  File "/config/custom_components/sonoff/core/entity.py", line 113, in internal_update
    self.set_state(params)
  File "/config/custom_components/sonoff/fan.py", line 58, in set_state
    self._attr_preset_modes.index(mode or SPEED_OFF)
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 338, in _getter
    return getattr(o, private_attr_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 338, in _getter
    return getattr(o, private_attr_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 338, in _getter
    return getattr(o, private_attr_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  [Previous line repeated 977 more times]
RecursionError: maximum recursion depth exceeded
2024-01-06 06:47:43.639 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/sonoff/core/ewelink/cloud.py", line 351, in _process_ws_msg
    self.dispatcher_send(SIGNAL_UPDATE, data)
  File "/config/custom_components/sonoff/core/ewelink/base.py", line 63, in dispatcher_send
    handler(*args, **kwargs)
  File "/config/custom_components/sonoff/core/ewelink/__init__.py", line 229, in cloud_update
    self.dispatcher_send(did, params)
  File "/config/custom_components/sonoff/core/ewelink/base.py", line 63, in dispatcher_send
    handler(*args, **kwargs)
  File "/config/custom_components/sonoff/core/entity.py", line 113, in internal_update
    self.set_state(params)
  File "/config/custom_components/sonoff/fan.py", line 58, in set_state
    self._attr_preset_modes.index(mode or SPEED_OFF)
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 338, in _getter
    return getattr(o, private_attr_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 338, in _getter
    return getattr(o, private_attr_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 338, in _getter
    return getattr(o, private_attr_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  [Previous line repeated 979 more times]
RecursionError: maximum recursion depth exceeded
tmb088 commented 8 months ago

Have the same issue I, forced it to light in the configuration.yaml and it works now (just a workaround). Ideally this should be fixed. My issue was that i couldnt turn it on with the slide just

jmcollin78 commented 8 months ago

Have the same issue I, forced it to light in the configuration.yaml and it works now (just a workaround). Ideally this should be fixed. My issue was that i couldnt turn it on with the slide just

Can you post the configuration you have done please ?

tmb088 commented 8 months ago

Have the same issue I, forced it to light in the configuration.yaml and it works now (just a workaround). Ideally this should be fixed. My issue was that i couldnt turn it on with the slide just

Can you post the configuration you have done please ?

I removed my device id , you can get it from the app. there are 3 lights because it a 3 gang wall switch. if yu just have one just set it to device_class: lights for example

image

villmatt commented 8 months ago

Same problem here. I have 3 ifan03 devices. All set to lan control in the ewelink app. 2 of the 3 WORK without any issue. this one however does not work.

When i change the sonoff integration to just use local, the fan that is giving me the recursion error does not even work for light control. Otherwise having cloud and local, i can at least control the light entity of the ifan03 controller. The actual fan entity does not show up anymore for this particular device.

The cloud and local thing could be related. unsure, not expecting to find a fix for that here, doesnt bother me anyway. but here are my logs for the same issue as mentioned above.

Logger: custom_components.sonoff.core.entity
Source: custom_components/sonoff/core/entity.py:86
Integration: Sonoff ([documentation](https://github.com/AlexxIT/SonoffLAN), [issues](http://192.168.0.87:8123/api/sonoff/97f7558a-ba07-4134-ac28-ab8505f9bf03))
First occurred: 10:28:30 AM (1 occurrences)
Last logged: 10:28:30 AM

Can't init device: {'name': 'Sonoff Basic', 'deviceid': '1000a81f39', 'apikey': 'OMITTED', 'extra': {'uiid': 34, 'description': '20190911019', 'brandId': '5c4c1aee3a7d24c7100be054', 'apmac': 'd0:27:01:50:3b:c3', 'mac': 'd0:27:01:50:3b:c2', 'ui': '智能风扇灯', 'modelInfo': '5ca1f6d0b5210ca205adf0fc', 'model': 'PSF-BFB-GL', 'manufacturer': '深圳松诺技术有限公司', 'chipid': '008FAC79', 'staMac': 'D8:F1:5B:8F:AC:79'}, 'brandName': 'SONOFF', 'brandLogo': 'https://us-ota.coolkit.cc/logo/q62PevoglDNmwUJ9oPE7kRrpt1nL1CoA.png', 'showBrand': True, 'productModel': 'iFan03', 'tags': {'m_8e5c_mvil': 'on'}, 'devConfig': {}, 'settings': {'opsNotify': 0, 'opsHistory': 1, 'alarmNotify': 1, 'wxAlarmNotify': 0, 'wxOpsNotify': 0, 'wxDoorbellNotify': 0, 'appDoorbellNotify': 1}, 'devGroups': [], 'family': {'familyid': 'OMITTED', 'index': -10, 'members': []}, 'shareTo': [], 'devicekey': 'OMITTED', 'online': True, 'params': {'bindInfos': {}, 'version': 8, 'sledOnline': 'on', 'ssid': 'OMITTED', 'bssid': '00:00:00:00:00:00', 'init': 1, 'fwVersion': '3.5.0', 'staMac': 'D8:F1:5B:8F:AC:79', 'rssi': -66, 'switches': [{'switch': 'on', 'outlet': 0}, {'switch': 'off', 'outlet': 1}, {'switch': 'off', 'outlet': 2}, {'switch': 'on', 'outlet': 3}], 'configure': [{'startup': 'on', 'outlet': 0}, {'startup': 'off', 'outlet': 1}, {'startup': 'stay', 'outlet': 2}, {'startup': 'stay', 'outlet': 3}]}, 'isSupportGroup': True, 'isSupportedOnMP': True, 'isSupportChannelSplit': False, 'deviceFeature': {}, 'device_class': 'fan'}
Traceback (most recent call last):
  File "/config/custom_components/sonoff/core/entity.py", line 86, in __init__
    self.internal_update(params)
  File "/config/custom_components/sonoff/core/entity.py", line 113, in internal_update
    self.set_state(params)
  File "/config/custom_components/sonoff/fan.py", line 61, in set_state
    self._attr_preset_modes.index(mode or SPEED_OFF) / self._attr_speed_count * 100
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 338, in _getter
    return getattr(o, private_attr_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 338, in _getter
    return getattr(o, private_attr_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 338, in _getter
    return getattr(o, private_attr_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  [Previous line repeated 977 more times]
RecursionError: maximum recursion depth exceeded

I am an amateur and tried to use chatgpt to help here. so please disregard the line number where it states line 61 in set_state. I tried to add an error capture line. Obviously im not doing it right.

villmatt commented 8 months ago

My bad, I didn't realise I had this single unit mentioned in my yaml. Removed and it's all good now

jmcollin78 commented 8 months ago

My bad, I didn't realise I had this single unit mentioned in my yaml. Removed and it's all good now

I don't understand your point. What is good now ? Do you have resolved the issue ?

villmatt commented 8 months ago

My fan entity works as expected. No recursive errors.

villmatt commented 8 months ago

So to clarify,

In my home assistant configuration yaml. I have the sonoff integration in there and I had it very much like the image posted above. Where it says - devices I don’t know why at some point I placed a single device under devices. But it was the only device out of 9 that I placed in the yaml. I now don’t mention any devices in my yaml and all of my iFan03 devices work as expected. No recursion errors.

I can probably go one step further and delete the whole sonoff mention in my yaml. But I'll just leave it for now.

Is there a specific reason you do have it in your yaml?

jmcollin78 commented 8 months ago

I don't remember why I add it into the yaml. my sonoff.yaml is now:

username: !secret sonoff_login
password: !secret sonoff_password
force_update: [power]
scan_interval: '00:05:00'  # (optional) default 5 minutes
sensors: [power, current, voltage, battery]
default_class: switch
devices:
  10015c96cc:
    device_class: binary_sensor
  10013f49a9:
    device_class: fan

I guess the IFan was not recognize as a Fan.

I will try to remove this from my sonoff.yaml and see.

jmcollin78 commented 8 months ago

🎉 It's me again. Thank you so much @villmatt, it is working now 🎉 .

My sonoff.yaml:

username: !secret sonoff_login
password: !secret sonoff_password
force_update: [power]
scan_interval: '00:05:00'  # (optional) default 5 minutes
sensors: [power, current, voltage, battery]
default_class: switch
devices:
  10015c96cc:
    device_class: binary_sensor

So we have a good workaround now. But I guess there a bug somewehere, so I keep the issue open.

AlexxIT commented 7 months ago

Issue was with custom device_class after Hass 2024.1 update. You already have Fan, so device_class: fan was unnecessary.

And you not provide full device diagnostics. We could see a problem with YAML config there.

jmcollin78 commented 7 months ago

Here are the diagnostic file: sonoff-83be3ba9dd9f5cf6fd6a50daa5b74ad8-Ventilateur sam-739fd402522c97ba4e5c5c88ce01bad2.json

AlexxIT commented 7 months ago

Thanks. It's unnecessary now. Because your problem solved with removing device_class from yaml. Anyway this bug will be fixed in next release.

AlexxIT commented 7 months ago

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