YAML for Yealink Smart Fan #1379
Replies: 2 comments 6 replies
-
Did you upgrade tuya-local to 2023.12.0 as well? There are some changes in the yaml parser in HA 2023.12 I became aware of when the unit tests picked up the beta version on 29 Nov, so the release was only made a few days before the HA release. Lately HACS does not seem to check as frequently for updates unless you go into the details page for the integration in HACS. |
Beta Was this translation helpful? Give feedback.
-
It seems a last minute change to the HA fan entity was made just before 2023.12 release that changes the API. Previously when I implemented fans, fan inherited its async_turn_on method from ToggleEntity, which is just an on/off switch, so that was what was implemented by this integration. It seems some time ago they added a fan specific async_turn_on that takes percentage and preset as arguments as well, but they did it in a backward compatible way with fallback to the simple on/off. But now they introduced an extra layer to do error checking on the supplied presets first, then explicitly calls the 3 argument version without any fallback to the old single argument version. Because they make all these changes quietly without calling them out in blog posts or release notes, and they merged this change at last minute before release it all went unnoticed by me. |
Beta Was this translation helpful? Give feedback.
-
Hi!
I've prepared a YAML configuration for Yealink Smart (KH-SY2626):
`name: Yealink fan
products:
name: Yealink Smart KH-SY2626
primary_entity:
entity: fan
dps:
type: boolean
name: switch
type: string
name: preset_mode
mapping:
value: "Świeży"
value: "Naturalny"
value: "Inteligentny"
value: "Uśpienie"
type: integer
name: speed
range:
min: 1
max: 15
mapping:
type: boolean
name: oscillate
secondary_entities:
name: Light
icon: "mdi:lightbulb"
category: config
dps:
type: boolean
name: switch
name: Beep
icon: "mdi:volume-high"
category: config
dps:
type: boolean
name: switch
name: Timer
icon: "mdi:timer"
category: config
dps:
type: string
name: option
mapping:
value: "wyłączony"
icon: "mdi:timer-cancel"
value: "1 godzina"
icon: "mdi:timer-play"
value: "2 godziny"
icon: "mdi:timer-play"
value: "3 godziny"
icon: "mdi:timer-play"
value: "4 godziny"
icon: "mdi:timer-play"
value: "5 godzin"
icon: "mdi:timer-play"
value: "6 godzin"
icon: "mdi:timer-play"
category: diagnostic
class: temperature
dps:
type: integer
name: sensor
unit: "°C"
class: measurement`
It was based on mapping:
{ "result": { "model": "{\"modelId\":\"000002fm9b\",\"services\":[{\"actions\":[],\"code\":\"\",\"description\":\"\",\"events\":[],\"name\":\"默认服务\",\"properties\":[{\"abilityId\":1,\"accessMode\":\"rw\",\"code\":\"switch\",\"description\":\"\",\"name\":\"风扇开关\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},{\"abilityId\":2,\"accessMode\":\"rw\",\"code\":\"mode\",\"description\":\"fresh nature smart sleep\",\"name\":\"工作模式\",\"typeSpec\":{\"range\":[\"fresh\",\"nature\",\"smart\",\"sleep\"],\"type\":\"enum\",\"typeDefaultValue\":\"fresh\"}},{\"abilityId\":3,\"accessMode\":\"rw\",\"code\":\"fan_speed\",\"description\":\"\",\"name\":\"风速\",\"typeSpec\":{\"max\":18,\"min\":1,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":1,\"unit\":\"\"}},{\"abilityId\":5,\"accessMode\":\"rw\",\"code\":\"switch_horizontal\",\"description\":\"\",\"name\":\"左右摆风开关\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},{\"abilityId\":13,\"accessMode\":\"rw\",\"code\":\"fan_beep\",\"description\":\"\",\"name\":\"声音\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},{\"abilityId\":15,\"accessMode\":\"rw\",\"code\":\"light\",\"description\":\"\",\"extensions\":{\"attribute\":\"16\"},\"name\":\"灯光\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},{\"abilityId\":21,\"accessMode\":\"ro\",\"code\":\"temp_current\",\"description\":\"\",\"name\":\"当前温度\",\"typeSpec\":{\"max\":50,\"min\":0,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0,\"unit\":\"℃\"}},{\"abilityId\":22,\"accessMode\":\"rw\",\"code\":\"countdown_set\",\"description\":\"\",\"extensions\":{\"attribute\":\"128\"},\"name\":\"倒计时\",\"typeSpec\":{\"range\":[\"cancel\",\"1h\",\"2h\",\"3h\",\"4h\",\"5h\",\"6h\"],\"type\":\"enum\",\"typeDefaultValue\":\"cancel\"}}]}]}" }, "success": true, "t": 1701887243436, "tid": "193f4d48946511ee82d73e55532a4cc5" }
Everything was working great until update HA Core to the 2023.12.0 version.
Right now turning fan on from switch entity in dashboard is causing error:
`Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:238
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 21:12:50 (14 occurrences)
Last logged: 21:21:49
[548172062272] TuyaLocalFan.async_turn_on() takes 1 positional argument but 3 were given
[547828963136] TuyaLocalFan.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: TuyaLocalFan.async_turn_on() takes 1 positional argument but 3 were given
`
I think the problem is caused, because service is not setting the "switch" entity to TRUE value.
Speed in this fan is set by integer value from 1 to 15 range. That's why I've used scaling with 0.15 factor (15/0,15=100%).
Apart from that everything works fine.
Can anyone help me to solve this problem?
After that I will pull request for adding a new device to repository.
Beta Was this translation helpful? Give feedback.
All reactions