Skip to content

Turning on light causing error #2459

@moxw

Description

@moxw

Device model / 设备型号

yeelink.light.color7

Component version / 插件版本

1.0.16

HA core version / HA版本

2025.3.1

Integrated mode / 集成方式

Automatic (自动模式)

The problem / 问题详情

Traceback

File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 648, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/config/custom_components/xiaomi_miot/light.py", line 156, in async_turn_on
    await self.device.async_write(dat)
  File "/config/custom_components/xiaomi_miot/core/device.py", line 701, in async_write
    data = self.encode(payload)
  File "/config/custom_components/xiaomi_miot/core/device.py", line 696, in encode
    conv.encode(self, payload, v)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/xiaomi_miot/core/converters.py", line 244, in encode
    super().encode(device, payload, rgb_to_int(value))
                                    ~~~~~~~~~~^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/miio/utils.py", line 102, in rgb_to_int
    return int(x[0] << 16 | x[1] << 8 | x[2])
                            ~~~~~^^~~
TypeError: unsupported operand type(s) for <<: 'float' and 'int'
2025-04-13 16:57:06.273 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [133839083133328] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2794, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2837, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/hass_utils.py", line 62, in service_func_proxy
    await existing_service.job.target(call)
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1007, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
        hass, entity, func, data, call.context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1079, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 648, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/config/custom_components/xiaomi_miot/light.py", line 156, in async_turn_on
    await self.device.async_write(dat)
  File "/config/custom_components/xiaomi_miot/core/device.py", line 701, in async_write
    data = self.encode(payload)
  File "/config/custom_components/xiaomi_miot/core/device.py", line 696, in encode
    conv.encode(self, payload, v)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/xiaomi_miot/core/converters.py", line 244, in encode
    super().encode(device, payload, rgb_to_int(value))
                                    ~~~~~~~~~~^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/miio/utils.py", line 102, in rgb_to_int
    return int(x[0] << 16 | x[1] << 8 | x[2])
                            ~~~~~^^~~
TypeError: unsupported operand type(s) for <<: 'float' and 'int'
2025-04-13 17:00:42.954 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [133839083133328] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2794, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2837, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/hass_utils.py", line 62, in service_func_proxy
    await existing_service.job.target(call)
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1007, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
        hass, entity, func, data, call.context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1079, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 648, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/config/custom_components/xiaomi_miot/light.py", line 156, in async_turn_on
    await self.device.async_write(dat)
  File "/config/custom_components/xiaomi_miot/core/device.py", line 701, in async_write
    data = self.encode(payload)
  File "/config/custom_components/xiaomi_miot/core/device.py", line 696, in encode
    conv.encode(self, payload, v)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/xiaomi_miot/core/converters.py", line 244, in encode
    super().encode(device, payload, rgb_to_int(value))
                                    ~~~~~~~~~~^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/miio/utils.py", line 102, in rgb_to_int
    return int(x[0] << 16 | x[1] << 8 | x[2])
                            ~~~~~^^~~
TypeError: unsupported operand type(s) for <<: 'float' and 'int'```

Entity attributes / 实体属性

button.info: x
model: yeelink.light.color7
did: x
mac: x
lan_ip: x
app_link: x
miot_type: urn:miot-spec-v2:device:light:0000A001:yeelink-color7:1
available: true
home_room: x
icon: mdi:information
updater: local
updated_at: 2025-04-13 22:51:52.269271+05:30
light.on: false
light.brightness: 76
light.color_temperature: 3848
light.color: 16743424
light.mode: 1
light.nl_br: 
light.off_delay_time: 0
converters: button.info, light.light.on, light.brightness, light.color_temperature, light.color, light.mode, number.light.off_delay_time, button.light.toggle
customizes: 
number_properties: off_delay_time,light_on_gradient_time,light_off_gradient_time
switch_properties: bg_on,init_power_opt,fan_init_power_opt
button_actions: toggle
chunk_coordinators: []
interval_seconds: 20

info: null
device_class: update
friendly_name: x

Home Assistant Logs / 系统日志

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions