cozylife / hass_cozylife_local_pull

home asstiant plugin
104 stars 43 forks source link

the integration is not functional #24

Closed kozfelipe closed 7 months ago

kozfelipe commented 1 year ago

I had issues to add this device to HA using this repo install tutorial. After a while I realize I can only manage to discover it once the device had learned the wifi credentials using the cozylife's app, so please inform in this tutorial the App is a requirement.

Once I had it discovered, I faced this issue on color sync:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 230, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 883, in entity_service_call
    await entity.async_update_ha_state(True)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 714, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 843, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 786, in _async_generate_attributes
    attr.update(self.state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 1073, in state_attributes
    data.update(self._light_internal_convert_color(color_mode))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 960, in _light_internal_convert_color
    if color_mode == ColorMode.HS and self.hs_color:
                                      ^^^^^^^^^^^^^
  File "/config/custom_components/hass_cozylife_local_pull/light.py", line 209, in hs_color
    self._refresh_state()
  File "/config/custom_components/hass_cozylife_local_pull/light.py", line 127, in _refresh_state
    self._attr_is_on = 0 < self._state['1']
                           ~~~~~~~~~~~^^^^^
KeyError: '1'

the color shows up as Red even if I use white

Also, the lamp is discovered as an entity rather than a device, so I can't use it in automation because there is no device to select

Also had issues when it is turned off

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 874, in _update_entity_states
    await entity.async_update_ha_state(True)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 714, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 843, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 784, in _async_generate_attributes
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 749, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1250, in state
    if (is_on := self.is_on) is None:
                 ^^^^^^^^^^
  File "/config/custom_components/hass_cozylife_local_pull/light.py", line 150, in is_on
    self._refresh_state()
  File "/config/custom_components/hass_cozylife_local_pull/light.py", line 125, in _refresh_state
    self._state = self._tcp_client.query()
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hass_cozylife_local_pull/tcp_client.py", line 259, in query
    return self._send_receiver(CMD_QUERY, {})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hass_cozylife_local_pull/tcp_client.py", line 208, in _send_receiver
    self._connect.send(self._get_package(cmd, payload))
OSError: [Errno 113] Host is unreachable

it does not get the real state

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 230, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 876, in entity_service_call
    response_data = 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/light/__init__.py", line 591, in async_handle_light_off_service
    await light.async_turn_off(**filter_turn_off_params(light, params))
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1273, in async_turn_off
    await self.hass.async_add_executor_job(ft.partial(self.turn_off, **kwargs))
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hass_cozylife_local_pull/light.py", line 198, in turn_off
    self._tcp_client.control({'1': 0})
  File "/config/custom_components/hass_cozylife_local_pull/tcp_client.py", line 251, in control
    self._only_send(CMD_SET, payload)
  File "/config/custom_components/hass_cozylife_local_pull/tcp_client.py", line 243, in _only_send
    self._connect.send(self._get_package(cmd, payload))
BrokenPipeError: [Errno 32] Broken pipe

when the lamp goes offline, it does not update HA to its unreachable state the script does not handle availability

I don't recommend this vendor to home assistant integration edit: I found a fix attempt of this buggy repository: https://github.com/yangqian/hass-cozylife no one answers here anyway

cozylife commented 10 months ago

Hello. You may need to restart your device multiple times.