🔌 Light Hook - Control any light (RGB, color temp, brightness) with one of the supported controllers

Hi @napalmz, sorry for my late response. Happy to hear that everything runs smoothly. :+1:

So now I have another request: is there any way to specify the initial brightness of the light? Now I have seen that at any brightness I turn it off it turns on again to a minimum and then I can increase it.
Could you record the last brightness in a variable and then be able to restore it the next time you turn it on? Or establish a “default brightness”?

Thank you for your suggestion :slight_smile: I’ve just published an update which includes the following, as stated in the changelog:

  • set minimum and maximum light brightness
  • specify number of steps from min to max brightness, both for short and long actions, when controlling the light
  • allow to force brightness to a specific value when turning on the light

This is not a breaking change: many inputs have been added to the blueprint, but all of them have default values already assigned to them.

The feature you requested should now be implemented. Please let me know if everything runs as expected.

Happy automating!

Good morning @epmatt,
i just tried it and it works perfectly!
Now I beg to ask you a new request: is it possible to parameterize a variable where to save the last brightness value that the light had before turning it off so that it can be restored when turned on?
Maybe with a series of steps: restore the last value, if there is no force one (if required a fixed value by parameter) or start at the minimum as it once was.

After that I can also pay you a coffee! :smile:

Good morning @napalmz, happy to hear that!

In my experience, lights generally maintain the same brightness level they had before being turned off. Just for asking, which devices are you using?

By the way, it’s definitely an interesting feature which might be useful for users in the same situation as yours. I think the best option is to make it an optional input, so if the light already saves the “last brightness” value, we can avoid providing an input which would be useless. :slight_smile:

Thank you for the suggestion!

Thank you, would be great!

My device is a “IKEA Tradfri LED Driver for Wireless Control 10 W” that comes also in 30W variant (and i need to replace it soon as my OMLOPP lights are 3 of 7.7W each and puts driver in “panic mode” as they absorb too much power).

Hi @napalmz,

Oh great, that’s probably a really common device, so this feature might be useful to many other users.

Thank you, I’ll let you know as soon as the feature gets implemented. :+1:

I am having trouble using this. the first step in setting it up says…

Integration Select Required
Integration used for connecting the remote with Home Assistant. Select one of the available values.

where is this done? it seems to be missing?

am I understanding correctly that this blueprint will add additional functionality to the blueprint I am using to dim my lights…

Hi @applesauce, I’m sorry for my late response.
First of all thank you for checking out these blueprints and for reporting here. :slight_smile:

Integration used for connecting the remote with Home Assistant. Select one of the available values

This input is part of one of the Controller blueprints, there’s no such input in the Light Hook. The Integration input is used in Controller blueprints to provide the integration you used to connect the controller with Home Assistant (Zigbee2MQTT, deCONZ, ZHA), which is required by the blueprint to correctly parse the RAW messages received from the device.

am I understanding correctly that this blueprint will add additional functionality to the blueprint I am using to dim my lights…

Not exactly, to use the light Hook you’ll need to setup a Controller blueprint first, as stated in documentation. Each Controller blueprint provides functionality for a different controller model; you can check out the full list of supported controllers in the documentation, which currently includes 6 devices mostly from IKEA.

The complete setup comprises two automations: one created with a Controller blueprint, the other one created with the Light Hook blueprint.
I highly suggest you to take a look at the Controllers-Hooks Ecosystem documentation, which describes how the two blueprint categories interact together, and lists different features you can achieve by configuring Controllers and Hooks in different ways, with clear YAML configuration examples.

If you have any additional doubts or you need further guidance to setup automations created with these blueprints I’d be happy to assist you, just let me know. :slight_smile:

Thank you!

1 Like

HI @epmatt

Thanks for these amazing blueprints.
You really saved us a lot of time figuring out how all these devices work with HA.

I have one issue, here is my setup:
I used your controller blueprint to create an automation for my IKEA ICTC-G-1 TRADFRI wireless dimmer, with no custom actions on it.
Then used your light hook to control my Ikea Tradri bulb.
When I rotate the dimmer, it starts to gradually increase/decrease until it reaches the max setting (1/255), depending on the “(Optional) Light brightness steps - long actions” value that is set.
I cannot set it to my preferred brightness. As long I start to rotate it, it will not stop until it reaches the max setting.

How can I stop this?
All I want is to have the dimmer work as it was intended: smoothly increase/decrease the brightness when rotating slowly, on/off when rotating it fast.
Is it possible to achieve that result with your blueprints and hooks?
Is it also possible to adjust the smoothness/steps of the brightness when slowly rotating the dimmer in order to achieve the perfect result?

Thanks again for your contributions

I see I can have multiple hooks using the same controller how to I differentiate what button goes to what hook? IE when I press center button it toggles a light but when I press brightness up it turns volume up on a media player.

Thanks

Craig

I am having difficulties setting up the light hook to work with my E1744 controller:
Controller yaml:

alias: Controller - IKEA E1744 SYMFONISK Rotary Remote
description: ''
use_blueprint:
  path: EPMatt/ikea_e1744.yaml
  input:
    controller_entity: sensor.symfonisk_action
    integration: Zigbee2MQTT
    helper_last_controller_event: input_text.symfonisk_text

Light hook yaml:

alias: Hook - Light
description: ''
use_blueprint:
  path: EPMatt/light.yaml
  input:
    light_color_mode: Auto
    controller_entity: sensor.symfonisk_action
    controller_model: IKEA E1744 SYMFONISK rotary remote
    light: light.bedroom_one

My light.bedroom_one is an E27 yeelight colour bulb, if that matters.

I am pretty certain that the controller automation is working because when I display the symfonisk_text entity on lovelace, the text updates without issues. The hook however never gets triggered.

Any clue what might have gone wrong?

Hey there @epmatt,

I hope you are well and healthy.

Do you have any advice regarding the issue I mentioned?

Thanks :slight_smile:

Hi @manosioa, sorry for the huge delay.

I’m happy to hear these blueprints are useful for you. :tada:

How can I stop this?

The controller should send the corresponding rotate_stop event when you stop the rotation. This might be an issue with how the blueprint manages rotation events.

Is it possible to achieve that result with your blueprints and hooks?

Unfortunately this is not possible due to the not standard interface the controller exposes to deCONZ, ZHA and Zigbee2MQTT. Moreover, Zigbee2MQTT removed support for fast rotation events with the new, more stable, non-legacy integration for this device. Since the blueprint should be as general as possible and targeting multiple integrations, I had to choose a restricted set of features which are supported by all the available integrations.
By the way, this is an issue we should consider addressing in the future, since I see many controllers don’t expose the same set of actions to all integrations.

Is it also possible to adjust the smoothness/steps of the brightness when slowly rotating the dimmer in order to achieve the perfect result?

Yes, it’s possible to adjust the controller-hook setup sensivity by providing a custom value for the brightness_steps_long light hook input, which represents the number of steps from min to max brightness when rotating/long pressing the mapped button. A higher value will result in less sensivity and finer brightness control.

This operation might also solve your first issue: if you’re able to rotate the controller just for a short amount of time, you should notice the automation stopping increasing/decreasing the brightness as soon as you stop rotating the controller. If this is not the case, we probably have to debug the rotation handling related code.

Thank you! :slight_smile:

1 Like

Hi @iscraigh, thank you for reaching out.

Unfortunately there’s currently no way to “route” certain actions to a specific hook automation: currently all hooks linked to the same controller automation receive all the device events.

By the way this feature is definitely something we might plan adding in the future.
If you have some time you can submit a feature request by creating a new issue on the project’s GitHub repository, so we can better discuss this suggestion and track its development.

Thank you!

Hi @thedrinkeno, thank you for reporting.

Do you notice any entries in the HA logs related to either the Controller or Hook blueprint?

Moreover, you can check whether the controller blueprint is correctly firing ahb_controller_event events when triggered by a controller interaction. These events are used to implement communication between controllers and hooks.

You can navigate to Developer Tools → Events in your Home Assistant UI, then in the Listen to events form on the bottom of the page type ahb_controller_event and click on Start Listening.

You should then see events appear on the event list while interacting with your E1744 controller.

Thank you!

I actually got this set up, it was an issue with the events coming out of my E1744 name. The events fired are different from what is documented on z2m. I replied on the E1744 thread describing what I did to get it to work.

1 Like

Hi Matteo,

Thank you for your work with the blueprint!

I really hope you won’t find my question rude - if you do - please say.

So, how would I use this line (brightness down, with minimum value to prevent light off). I understand to change the light to light.entity but how would I change the '-step_short, min bright etc etc?

brightness: '{{ [ [state_attr(light,"brightness")-step_short, min_brightness] | max, max_brightness] | min }}

in standalone automation? I have different devices controlling lights around the house (aqara opple) and I also utilise different buttons in different ways, this is why it would be better for me to just use it in separate automation.

Once again - I hope you won’t feel offended by me asking this question.

Thank you!

Hi @bednim,

thank you for reaching out. No reason to feel offended at all - I’m happy to see people using the blueprints’ code in other ways than what’s intended for. :slight_smile:

You can replicate the service call you find in the brightness_down or brightness_down_repeat step, getting rid of the min_brightness and max_brightness variables, which are used to constraint the light brightness to the desired range:

- service: light.turn_on
  data:
    brightness: '{{ state_attr(light,"brightness")-step_short }}'
    transition: 0.25
    entity_id: <light_entity>

Moreover, if you’d like to request a blueprint for a currently unsupported controller, you can always open a feature request in the project’s GitHub repository. We’re in the process of extending the number of supported controllers, thanks also to the community feedback, so new devices will be added in the upcoming weeks. :slight_smile:

Thank you! If you have any additional doubts I’d be glad to help.

Hi @epmatt! thank you for your response - I would like to use min_brightness so when i dim the light to the max - it won’t turn off but stay at level 1 - would you be kind to tell me how to achieve this? I believe this is one of the constraint to use in your script/automation.

Thank you for suggesting feature request - I sure will do it!

And also - thank you for taking your time to respond.

edit:
OMG I got it!!!

here it is:

                  data:
                    brightness: '{{  state_attr("light.ikea_tradfri_30w_kuchnia","brightness")-10  }}'
                    transition: 0.5
                  target:
                    entity_id:
                      - light.ikea_tradfri_30w_kuchnia

plus

variables:
  min_brightness: 1
  max_brightness: 255
  brightness_steps_short: 1
  brightness_steps_long: 10

  step_short: '{{ (max_brightness-min_brightness)/brightness_steps_short }}'
  step_long: '{{ (max_brightness-min_brightness)/brightness_steps_long }}'

at the bottom of the automation :smiley:

I’m super happy now! thanks!

edit2:

nope - something still ain’t right :smile:

edit3:

                    brightness: '{{  [state_attr("light.ikea_tradfri_30w_kuchnia","brightness")|int - 10, 1]|max  }}'

that seems to be correct syntax :slight_smile:

Hi there @epmatt thank you for your work on all these controller/hooks blueprints! I have had great success with the Ikea controller/hooks up to this point! I am having a bit of issues with the light hook and using my Philips Remote Controller. The controller automation shows it’s updating with presses, and I am seeing them in my zigbee2mqtt log, but no changes on the light hook. Below is the error log, and the configuration of both the controller and the hook. Any Suggestions?

Error from Log:

Error while executing automation automation.hook_light: UndefinedError: 'dict object' has no attribute 'event'
12:35:46 PM – (ERROR) Automation - message first occurred at 12:22:06 PM and shows up 3 times
Hook - Light: Error executing script. Error rendering template for variables at pos 1: UndefinedError: 'dict object' has no attribute 'event'
12:35:46 PM – (ERROR) Automation - message first occurred at 12:22:06 PM and shows up 3 times
Template variable error: 'dict object' has no attribute 'event' when rendering '{{ trigger.event.data.action }}'
12:35:46 PM – (ERROR) helpers/template.py - message first occurred at 12:22:06 PM and shows up 3 times 

Controller

alias: Controller - Philips Hue Dimmer switch
description: ''
use_blueprint:
  path: EPMatt/philips_324131092621.yaml
  input:
    integration: Zigbee2MQTT
    controller_entity: sensor.bedroom_switch_action
    helper_last_controller_event: input_text.philips_remote_bedroom
    controller_device: 3d6df33420b0ed52eabeb488e3ec9bf0

Hook- Light

alias: Hook - Light
description: ''
use_blueprint:
  path: EPMatt/light.yaml
  input:
    light_color_mode: Auto
    controller_device: 3d6df33420b0ed52eabeb488e3ec9bf0
    controller_entity: sensor.bedroom_switch_action
    controller_model: Philips Hue Dimmer switch
    light: light.bedroom_lamp

Have the same error and no solution. Help?