openhab-scripters / openhab-helper-libraries

Scripts and modules for use with openHAB
Eclipse Public License 1.0
88 stars 69 forks source link

[Area Triggers and Actions] Configurable brightness method for light_action #326

Closed theiding closed 3 years ago

theiding commented 4 years ago

The current implementation of light_action determines the brightness to be set as a function of lux level and mode. In more complex use cases other external factors need to be taken into account to determine brightness: Example 1: Emphasize/boost a light if a neighboring light is on as described here Example 2: Let an override item override the default brightness if it is set as described here

The ask is to support optional configuration of a brightness function that takes brightness, hue, saturation, item, active as input and returns a new brightness value. The passed in brightness/hue/saturation are the currently computed values; item and active are the values that light_action was invoked with. This then allows a concise implementation of additional brightness logic. If the method is configured it will be invoked and its return brightness will be applied to the item. This proposal allows clean customization without having to duplicate the entire light_action method while introducing minimal complexity.

@openhab-5iver had responded to the original proposal of specific support for example 2 that the functionality is too narrow to warrant the additional complexity. This proposal is significantly more generic and addresses a wide range of use cases, but the same concern of unneeded complexity may of course still be raised, in which case the same workaround would apply of customizing the entire light_action method.

5iver commented 3 years ago

I do not feel the need to add more complexity to the light_action function. If you implement a custom action, please submit it as an example. If it is useful, I'll consider adding it into light_action. BTW, check out the latest version, as I added in a bit of functionality recently (#361) and have yet to updated the docs.