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.74k stars 416 forks source link

Fix custom device_class fan support after Hass v2023.12 #1266

Closed Fokir closed 9 months ago

Fokir commented 11 months ago

Reproducible after updating to HA 2023.12 There are 3 devices with the "fan" type overridden. When trying to turn it on/off, an error appears. Similar devices with the "light" type work well.

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:238
Integration: Home Assistant WebSocket API ([documentation](https://www.home-assistant.io/integrations/websocket_api), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
First occurred: 13:04:15 (10 occurrences)
Last logged: 13:19:29

[140184720678080] XSwitch.async_turn_on() takes 1 positional argument but 3 were given
[140184324040128] XSwitch.async_turn_on() takes 1 positional argument but 3 were given
[140184324300480] XSwitch.async_turn_on() takes 1 positional argument but 3 were given
[140184301793984] XSwitch.async_turn_on() takes 1 positional argument but 3 were given
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 238, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 878, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 305, in async_handle_turn_on_service
    await self.async_turn_on(percentage, preset_mode, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: XSwitch.async_turn_on() takes 1 positional argument but 3 were given
bepluy commented 11 months ago

Same issue after updating to 2023.12.1. All devices marked as fan via Sonoff Lan can't be turned on with error Failed to call service fan/turn_on. XSwitches.async_turn_on() takes 1 positional argument but 3 were given

wokkeltje13 commented 11 months ago

if I read this, then I think we have a HA issue and not a Sonoff issue. Since I have exact the same issue with a xaomi fan.

https://github.com/syssi/xiaomi_fan/issues/239

trullock commented 11 months ago

I have this same issue.

I use Sonoff LAN integration, so simply remapped my fan as a light for now to keep it working

andrewraj commented 11 months ago

I have the same issue as well, and it works when the entity is converted back to switch instead of a fan.

TTLucian commented 11 months ago

Same problem here!

IvanGavrilenko commented 11 months ago

Just the same, while switching off - works fine (I can switch on via ewelink app and switch off via HA)

gmikulski commented 11 months ago

Seems I have same issue, how did you guys solve it?

moorsey commented 10 months ago

Watching this, seeing same issue

Looks like the xiaomi_fan issue linked above was fixed by the author, stating it was caused by this HA core change - https://github.com/home-assistant/core/commit/953a212dd697c5b916a335869bed8b36be466b92

dkurzelewski commented 10 months ago

I was change

async def async_turn_on(self, **kwargs):

to:

async def async_turn_on(self, speed: str = None, mode: str = None, **kwargs) -> None:

in switch.py work for me. I will be wait for official pull.

IvanGavrilenko commented 10 months ago

I was change

async def async_turn_on(self, **kwargs):

to:

async def async_turn_on(self, speed: str = None, mode: str = None, **kwargs) -> None:

in switch.py work for me. I will be wait for official pull.

Did the same - now fan switches on correctly

AlexxIT commented 9 months ago

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