hass-miio-yeelink icon indicating copy to clipboard operation
hass-miio-yeelink copied to clipboard

yeelink.light.mono6 support

Open Paclanc opened this issue 2 years ago • 6 comments

Hi. I tried to add a new bulb, but this appeared on the logs

Logger: homeassistant.components.light
Source: custom_components/miio_yeelink/__init__.py:492
Integration: Luz (documentation, issues)
First occurred: 15:49:06 (1 occurrences)
Last logged: 15:49:06

miio_yeelink: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 432, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 601, in async_device_update
    await task
  File "/config/custom_components/miio_yeelink/__init__.py", line 492, in async_update
    self._color_temp = int(attrs.get('ct', 0))
ValueError: invalid literal for int() with base 10: ''

Paclanc avatar Jul 24 '21 20:07 Paclanc

Fixed in https://github.com/al-one/hass-miio-yeelink/commit/bce78932e54b020c91c3f319ea3f6397874c205b, Please try master branch.

al-one avatar Jul 25 '21 02:07 al-one

Hi. Thank you, the fix did indeed make the bulb appear and function. However, now, when I try to turn on the light, a small delay occurs while a little message that says "division by zero" appears, then the light turns on. And these two events appeared on the logs.

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/miio_yeelink/__init__.py:561
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 0:08:24 (1 occurrences)
Last logged: 0:08:24

[139720463411808] division by zero
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1491, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1526, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 675, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 406, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 455, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 837, in state_attributes
    color_mode = self._light_internal_color_mode
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 687, in _light_internal_color_mode
    if COLOR_MODE_COLOR_TEMP in supported and self.color_temp is not None:
  File "/config/custom_components/miio_yeelink/__init__.py", line 456, in color_temp
    return self.translate_mired(self._color_temp)
  File "/config/custom_components/miio_yeelink/__init__.py", line 561, in translate_mired
    return round(1000000 / num)
ZeroDivisionError: division by zero

And this

Este error se originó a partir de una integración personalizada.

Logger: homeassistant
Source: custom_components/miio_yeelink/__init__.py:561
Integration: Miio For Yeelink (documentation, issues)
First occurred: 0:08:32 (1 occurrences)
Last logged: 0:08:32

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 709, in _update_entity_states
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 406, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 455, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 837, in state_attributes
    color_mode = self._light_internal_color_mode
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 687, in _light_internal_color_mode
    if COLOR_MODE_COLOR_TEMP in supported and self.color_temp is not None:
  File "/config/custom_components/miio_yeelink/__init__.py", line 456, in color_temp
    return self.translate_mired(self._color_temp)
  File "/config/custom_components/miio_yeelink/__init__.py", line 561, in translate_mired
    return round(1000000 / num)
ZeroDivisionError: division by zero

Paclanc avatar Jul 25 '21 05:07 Paclanc

Tried again with the fix on 26e3ba3, and the zero division error doesn't appear anymore. But the delay when turning it on remains, it's about 2 seconds, however, turning it off happens instantly. Is this normal behaviour?

Paclanc avatar Jul 25 '21 16:07 Paclanc

I also want to comment that this light bulb can only adjust its brightness, the color temperature is fixed to warm. I know I can customize the entity, but I wanted to specify that in case it can be added to the code to be properly recognized for other users when they try to add this same bulb (if that's something you are implementing to your project) .

Paclanc avatar Jul 25 '21 17:07 Paclanc

The attribute ct returned by your device is not an integer, show me the entity state attributes.

al-one avatar Jul 27 '21 03:07 al-one

Here they are:

min_mireds: 175
max_mireds: 370
supported_color_modes:
  - color_temp
model: yeelink.light.mono6
lan_ip: 192.168.1.155
mac_address: 54:48:E6:17:39:47
firmware_version: 2.0.8_0015
hardware_version: esp8266
entity_class: YeelightEntity
power: 'off'
nl_br: '0'
delayoff: '0'
bright: '100'
ct: ''
friendly_name: Xiaomi Yeelink
supported_features: 3
support_color_temp: 'false'  <--- I added this today

Paclanc avatar Jul 27 '21 03:07 Paclanc