ha-switchbot-remote icon indicating copy to clipboard operation
ha-switchbot-remote copied to clipboard

Entity fan.fan does not support action fan.turn_on. (or turn_off)

Open zareami10 opened this issue 11 months ago • 4 comments

I used to get errors when turning fan on/off, but it still would work regardless. However it stopped working altogether recently. SwitchBot Cloud works just fine with my fan.

(not sure if relevant but the fan does not have actual on/off buttons, but rather a toggle button)

zareami10 avatar Jan 07 '25 11:01 zareami10

Hello @zareami10 please provide a real example and some logs.

I do not have a compatible fun so I cannot replicate.

KiraPC avatar Jan 07 '25 11:01 KiraPC

Analysis Result by ChatGPT o3-mini-high:

The issue originates from the implementation of the is_on property in the fan entity. Currently, the property is defined as follows:

@property
def is_on(self):
    """Check if fan is on."""
    return self._state

Here, self._state holds the string values STATE_ON or STATE_OFF (e.g., "on" or "off"), rather than a boolean (True/False). Home Assistant expects a boolean value for the is_on property to correctly determine whether the fan supports the fan.turn_on (or fan.turn_off) action. Although previous versions of Home Assistant may have tolerated this mismatch (albeit with warnings), newer versions enforce stricter type expectations, which is why the actions now fail to execute.

Before (Current Implementation):

  • Property Definition:
    @property
    def is_on(self):
        """Check if fan is on."""
        return self._state
    
  • Outcome:
    Returns a string (STATE_ON/STATE_OFF) instead of a boolean, causing Home Assistant to misinterpret the entity’s state and report that the fan does not support turning on/off.

After (Corrected Implementation):

  • Revised Property Definition:
    @property
    def is_on(self):
        """Check if fan is on."""
        return self._is_on
    
  • Outcome:
    Returns the boolean value stored in self._is_on, which is properly set to True in async_turn_on and False in async_turn_off. This complies with Home Assistant’s expectations, ensuring that the fan.turn_on and fan.turn_off actions are recognized as supported.

Conclusion:

To resolve the issue, update the is_on property to return self._is_on instead of self._state. This change will align the entity’s state reporting with Home Assistant’s required boolean format and restore the functionality of the on/off actions.

Please review and apply the correction as detailed above.

jleinenbach avatar Feb 20 '25 20:02 jleinenbach

I can confirm this issu.

Jejebond avatar May 11 '25 13:05 Jejebond

Also having this issue.

Logger: homeassistant.core Source: core.py:2822 First occurred: 5:22:29 PM (2 occurrences) Last logged: 5:22:30 PM

Error executing service: <ServiceCall fan.turn_on (c:01K1S3WSSVT8HXH36QVBTSVN1G): entity_id=['fan.woozoo_power']> Error executing service: <ServiceCall fan.turn_off (c:01K1S3WVNRBFY8Y5PGWBQGSGJ5): entity_id=['fan.woozoo_power']> Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/core.py", line 2822, in _run_service_call_catch_exceptions await coro_or_task File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 991, in entity_service_call raise ServiceNotSupported(call.domain, call.service, entity.entity_id) homeassistant.exceptions.ServiceNotSupported: Entity fan.woozoo_power does not support action fan.turn_on

4rft5 avatar Aug 03 '25 23:08 4rft5