jheling / freeathome

Free@Home component for Home Assistant
103 stars 37 forks source link

support for dali devices #182

Open jheling opened 3 months ago

jheling commented 3 months ago

Add extra function_id's

cweyer commented 2 months ago

First of all, a big thank you for great work here! It is really appreciated.

I downloaded and installed this branch via git as a custom component in my Home Assistant setup and ran it. Unfortunately the DALI controlled lights do not show up. I assume this is because lights are entities which are exposed by a device. For my regular lights those devices are named like Sensor/ Schaltaktor 8/8fach, REG and in turn expose the lights connected to them as entities. I was wondering if the same must be done with DALI? So the DALI controller is exposed in HA as a device which in turn exposes the lights as it's entities. Otherwise there would be no hierarchy path to the lights themselves? I hope this answer makes sense, I am pretty new to HA and haven't wrapped my head around all the concepts yet, but since all my other lights don't show up directly but through their device I was wondering if the same must be done with the DALI controller?

jheling commented 2 months ago

Yes, the dali controller should appear as a device and the controlled lights (channels) should appear as entities. I assume you don't see any errors in Settings/System/Logs?

Could you adjust the logging level in your configuration.yaml like this? :

logger:
  default: warning
  logs:
    custom_components.freeathome: info

This should show more information in the log about the available entities.

cweyer commented 2 months ago

Ah okay, since I didn't see any code related to that I assumed it was omitted.

Anyhow, this might be helpful (I renamed the integration freeathome-dev to be able to run the stable version and branch on the same system)

Looks like the return value for self.rgb_color is not an integer

2024-04-05 17:03:51.100 ERROR (MainThread) [homeassistant.components.light] Error while setting up freeathome-dev platform for light
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
await asyncio.shield(awaitable)
File "/config/custom_components/freeathome-development/light.py", line 23, in async_setup_entry
async_add_devices([FreeAtHomeLight(device_object)])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/freeathome-development/light.py", line 63, in __init__
self._rgb_color = self.light_device.get_rgb_color()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/freeathome-development/fah/devices/fah_light.py", line 164, in get_rgb_color
blue = self.rgb_color & 255
~~~~~~~~~~~~~~~^~~~~
TypeError: unsupported operand type(s) for &: 'str' and 'int'
2024-04-05 17:03:56.439 DEBUG (MainThread) [custom_components.freeathome-development.fah.pfreeathome] received datapoint 807A7F04E8CD/ch0013/idp0007 = 0
2024-04-05 17:03:56.439 DEBUG (MainThread) [custom_components.freeathome-development.fah.pfreeathome] received datapoint 807A7F04E8CD/ch0013/idp000A = 65
2024-04-05 17:03:56.439 DEBUG (MainThread) [custom_components.freeathome-development.fah.pfreeathome] received datapoint 807A7F04E8CD/ch008B/idp0007 = 0
2024-04-05 17:03:56.440 DEBUG (MainThread) [custom_components.freeathome-development.fah.pfreeathome] received datapoint 807A7F04E8CD/ch008B/idp000A = 65
2024-04-05 17:03:56.440 DEBUG (MainThread) [custom_components.freeathome-development.fah.pfreeathome] received datapoint 807A7F04E8CD/ch00B9/idp0000 = 0
2024-04-05 17:03:56.440 DEBUG (MainThread) [custom_components.freeathome-development.fah.pfreeathome] received datapoint 807A7F04E8CD/ch00B9/odp0009 = 65
2024-04-05 17:03:56.440 DEBUG (MainThread) [custom_components.freeathome-development.fah.pfreeathome] FahThermostat Wohnzimmer: received datapoint 807A7F04E8CD/ch00B9/odp0009 = 65
2024-04-05 17:03:56.440 INFO (MainThread) [custom_components.freeathome-development.fah.devices.fah_thermostat] thermostat Wohnzimmer (807A7F04E8CD/ch00B9) dp odp0009 ecomode 65
2024-04-05 17:03:56.440 DEBUG (MainThread) [custom_components.freeathome-development.fah.pfreeathome] received datapoint 807A7F04E8CD/ch00B9/odp000A = 0
cweyer commented 2 months ago

Ok, so typecasting it to int worked, now it shows up. I can control on/off and brightness (with a bit strange feedback though), but not colour. The colour map is all black and selecting a colour brings up this error message:

Screenshot 2024-04-05 at 17 22 25

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2542, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2579, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 971, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1043, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 631, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/config/custom_components/freeathome-development/light.py", line 152, in async_turn_on
    self.rgb_color = kwargs[ATTR_RGB_COLOR]
    ^^^^^^^^^^^^^^
AttributeError: property 'rgb_color' of 'FreeAtHomeLight' object has no setter```
jheling commented 2 months ago

Hello, I have made some changes to light.py. Hope it now works better.

jheling commented 2 months ago

@cweyer, Did you have time to test it with the changes i made?

cweyer commented 2 months ago

@cweyer, Did you have time to test it with the changes i made?

Unfortunately I was pretty busy in the last couple of days, but I will be able to test it some time next week, sorry for the delay.

cweyer commented 1 month ago

Sorry for getting back just now, I had a lot of work the last couple of weeks.

So I applied your patches and there seems to be a wrongly named method, it's calling is_rgb_colour but there is only a is_rgb method. Also, since this patch, it only discovers one of my 4 DALI entities.

Screenshot 2024-05-12 at 20 53 28

(Sorry for the screenshot, the web UI terminal doesn't allow me to copy text)