djtimca / haomnilogic

Hayward Omnilogic integration for Home Assistant available through HACS
Apache License 2.0
18 stars 6 forks source link

Color Logic V2 brightness control #25

Open cryptk opened 2 years ago

cryptk commented 2 years ago

Hello,

I recently upgraded to the HACS integration to gain all of the extra functionality, and I noticed a few issues related to brightness control.

The light reports a supported_color_modes of "onoff", this prevents normal dimming controls from working. It looks like the light should return a supported_color_mode and a color_mode of ColorMode.BRIGHTNESS according to the developer docs at https://developers.home-assistant.io/docs/core/entity/light/.

The integration exposes the brightness as a value between 0-4, which maps to 20%,40%,60%,80%,100% on the light itself. It seems like everything in Home Assistant expects light brightness values to be a value between 0-255 with 0 being "off" and 255 bring "full brightness". This causes things like brightness control sliders to not work well because they expect to call a turn_on service and pass in a brightness parameter within the range of 0-255. Passing a brightness parameter does not currently seem to work at all (likely because of the previous issue related to color_mode settings), but even if that was fixed, brightness sliders in the dashboard likely would not work properly unless you only used the first few positions of the slider. Ideally, the integration would map 0-255 values, perhaps along the following mapping:

0: off 51: 20% 102: 40% 153: 60% 204: 80% 255: 100%

If the turn_on service receives a value other than those in the mapping, then it should either select the closest valid step, or perhaps move to the next highest step. I am not sure if there is already guidance over which of these options should be selected, but my fans appear to always move to the next highest step (so requesting a value of 52 would go to 40% rather than to 20%).

I have not yet looked into the speed control, but dashboard sliders in the custom:light-entity-card don't currently seem to work for that either, but I'll work on figuring out what is going on there after the brightness controls are working properly.

I read that one of your issues is that you do not have a ColorLogic V2 light with brightness/speed control to test with. I do, and I am more than happy to assist with testing/integration of these features as needed.

djtimca commented 2 years ago

The brightness and speed controls don't map well to the Home Assistant entities so we opted for custom services to control those in this case.

This is all explained on the main documentation / main page: https://github.com/djtimca/haomnilogic#light-platform

We can look at a "mapped" version of brightness, but our first cut at that felt non-intuitive since the slider would move with no impact except at some specific steps. There is also a potential to use a number entity in HA, but have't been able to look at that yet.

For the time being, we'll have to live with the custom service - I can mark this as a feature request, but will require some discussion on the best entity mapping for speed/brightness in Home Assistant and it will likely fall behind things like moving to the local API in terms of priority.