Lutron Caseta Pico Remotes and Node-Red

There is a lot of complexity in my button press handler right now, which is specific to my setup and I am working to simplify. I wanted a generic automation that can work for multiple pico remotes dealing with multiple adaptive switches and multiple light switches through the use of configuration variables. So I am going to share an edited snippet of what should work for you, rather than my actual automation. It assumes some hard-coded entity IDs, rather than the variables that I use.

    ################################################################################
    # AUTOMATION: pico_light_buttonhandler
    # Handler for Pico light-controlling remotes
    ################################################################################
    - alias: pico_light_on_buttonpress
      mode: single
      trigger:
        platform: event
        event_type: pico_buttonpress
      action:
        - variables:
            pico_id: "{{ trigger.event.data.entity_id }}"
            button_pressed: "{{ trigger.event.data.button_pressed }}"
            press_type: "{{ trigger.event.data.press_type }}"
            # NOTE: Configure your own entity IDs for the AL switch and corresponding light below
            adaptivelighting_id:
            light_id:
        - choose:
            # On-Tap: Turn lights on with adaptive brightness & color
            - conditions: "{{ button_pressed == 'on' and press_type == 'tap' }}"
              sequence:
                # You cannot apply both brightness and color when turning a light on from an off state.
                # Manually apply the AL brightness first.  This prevents a light from briefly going to
                # its previous brightness before the AL component takes control. This way you don't blind
                # yourself in the middle of the night.
                - service: light.turn_on
                  data:
                    entity_id: "{{ light_id }}"
                    brightness_pct: "{{ state_attr(adaptivelighting_id, 'brightness_pct') }}"
                - service: light.turn_on
                  data:
                    entity_id: "{{ light_id }}"
                    color_temp: "{{ state_attr(adaptivelighting_id, 'color_temp_mired') }}"
            # On-DoubleTap: Turn lights on at max brightness, keep color
            - conditions: "{{ button_pressed == 'on' and press_type == 'doubletap' }}"
              sequence:
                - service: light.turn_on
                  data:
                    entity_id: "{{ light_id }}"
                    brightness_pct: 100
            # Off-Tap: Turn lights off
            - conditions: "{{ button_pressed == 'off' and press_type == 'tap' }}"
              sequence:
                - service: light.turn_off
                  data:
                    entity_id: "{{ light_id }}"
            # Off-DoubleTap: Turn light on at min brightness, keep color
            - conditions: "{{ button_pressed == 'off' and press_type == 'doubletap' }}"
              sequence:
                - service: light.turn_on
                  data:
                    entity_id: "{{ light_id }}"
                    brightness_pct: 1
            # Up-Hold: Increase brightness at each interval
            - conditions: "{{ button_pressed == 'up' }}"
              sequence:
                - service: light.turn_on
                  data:
                    entity_id: "{{ light_id }}"
                    brightness_step_pct: 15
            # Down-Hold: Decrease brightness at each interval
            - conditions: "{{ button_pressed == 'down' }}"
              sequence:
                - choose:
                    # Don't allow dimming below a value of 1, which would turn off the light
                    - conditions: "{{ (1-(255 - state_attr(light_id, 'brightness')|int)/255)*100 <= 15 }}"
                      sequence:
                        - service: light.turn_on
                          data:
                            entity_id: "{{ light_id }}"
                            brightness: 1
                  default:
                    - service: light.turn_on
                      data:
                        entity_id: "{{ light_id }}"
                        brightness_step_pct: -15
            # Action-Tap: 
            - conditions: "{{ button_pressed == 'action' and press_type == 'tap' }}"
              # NOTE: This sequence has been removed as it was heavily customized to iterate through multiple lighting 'profiles'
              sequence: []
            # Action-DoubleTap: Restore adaptive lighting
            - conditions: "{{ button_pressed == 'action' and press_type == 'doubletap' }}"
              sequence:
                # Remove the light from manual control
                - service: adaptive_lighting.set_manual_control
                  data:
                    entity_id: "{{ adaptivelighting_id }}"
                    lights: "{{ light_id }}"
                    manual_control: false
2 Likes

@MizterB Awesome much thanks. I assume this is per pico remote right? I have different remotes for different rooms so figure this would be per pico to set of lights so to speak? Also assuming https://github.com/basnijholt/adaptive-lighting for the AL? I want to make the switch from Node-Red to native and get the components right until AL is natively baked in. I really appreciate all the help!

Yes on all fronts. The automation as I shared it would need to be copied for each Pico/set of lights.

I have a Lutron Caseta Pro hub and a bunch of pico remotes and hue lights. Iā€™ve figured out how to make them turn on/off and toggle with the middle button (using the home assistant automations). However, Iā€™m a total beginner. Iā€™ve got node red installed, and I can import the json @MizterB has created, but I have not idea really what Iā€™m looking at or how to apply it to my lights. Any suggestions of where someone like me could go to learn enough to be able to understand and implement this for myself? Alternatively, Iā€™d be willing to pay for some support via web conference if someone is willing to help me get this implemented and get me started on understanding how it works.

I know you have moved on to use the native automations for your pico remotes now. But I would like to see if you could help me figure this out.

In your ā€œConfig Flowā€ node for your ā€˜msg.service_action_tap_singleā€™ you use this json code to switch scenes.

[
    {
        "domain": "hue",
        "service": "hue_activate_scene",
        "data": {
            "group_name": "FamilyRoom Ceiling",
            "scene_name": "Bright"
        }
    },
    {
        "domain": "hue",
        "service": "hue_activate_scene",
        "data": {
            "group_name": "FamilyRoom Ceiling",
            "scene_name": "Dimmed"
        }
    },
    {
        "domain": "hue",
        "service": "hue_activate_scene",
        "data": {
            "group_name": "FamilyRoom Ceiling",
            "scene_name": "Relax"
        }
    }
]

I do not have the ā€œHueā€ integration and would like to use scenes I have setup via the ā€œScene Editorā€ in HA. Here is my code (and Iā€™ve tried various approaches) but cannot get it to work with your sub flow.

[
    {
        "domain": "scence",
        "service": "scene.turn_on",
        "target": {
            "entity_id": "scene.my_bedroom_bright"
        }
    },
    {
        "domain": "scence",
        "service": "scene.turn_on",
        "target": {
            "entity_id": "scene.my_bedroom_relax"
        }
    },
    {
        "domain": "scence",
        "service": "scene.turn_on",
        "target": {
            "entity_id": "scene.my_bedroom_red"
        }
    }
]

Could you help me out if you get a chance?

I believe you have a typo in your domain name - should be ā€œsceneā€. Additionally service should just be ā€œturn onā€.

    {
        "domain": "scene",
        "service": "turn_on",
        "target": {
            "entity_id": "scene.my_bedroom_red"
        }
    }

I am literally going to die lmao. Iā€™m going to fix that when I get home and if it was a simple typo :exploding_head:. Thanks for reaching back out though.

I didnā€™t enclose the code in [ ] that was my error on top of the typo. Thank you for your help

Can you help me out with 2 questions please? My new HA Blue appliance is arriving today and I really wanted to do a clean install of everything since there are issues with entities reappearing in the core registry.
I have always used the custom component GitHub - upsert/lutron-caseta-pro: Custom Home Assistant Component for Lutron Caseta Smart Bridge PRO / RA2 Select for my integration along with your Node-Red json flows beautifully. If I use the new Lutron Caseta integration found in HA core, will that break your Node-Red flow design?
One other questionā€¦ your Node-Red flows are so amazing; why did you drop Node-Red and switch to native HA automations? Really curious as the Node-Red flows you created are just amazing.
Thanks for helping me out and thanks for helping be the guy that controls my lights! :grin:

Yes, using the HA core integration will break the Node Red flows, as the flows were triggered by a button sensor state change, which is not produced by the new integration. The new integration raises events instead. Unfortunately, I am so far removed from Node Red these days that I canā€™t really help update those old flows. But there is no reason you canā€™t continue to use the custom component either.

Regarding Node Red versus nativeā€¦I have a general approach of trying to stick with HAā€™s native features wherever possible these days. I think it keep things simpler and easier to support. Back when I started playing with automations, there was a lot of logic I wanted to apply, but it didnā€™t appear that HA could support it - thatā€™s why I went with Node Red. But now, with improvements to Jinja templates, variables, and conditional logic, I am able to do pretty much anything I want within HA.

Awesome. Cannot thank you enough for getting back in touch so quickly. If you were willing and able to do some ā€œconsultingā€ work for my HA instance, like changing over to native HA control for Lutron, can you PM me your hourly rate? There may be some other things I could have you do, if you are available. Understand if you are not.
Thanks again :pray:

Thanks for sharing your code, it has helped immensely. It appears only Picos can be used as triggers? I would love if the core integration could detect button presses on the wired Caseta wall switches too. Are you aware if this is possible? Itā€™s either not available or Iā€™m missing it somehow.

Sorry, donā€™t know anything about the wall switches - I only have Picos. I also have not had an opportunity to migrate my solution to the core integration - itā€™s still based on the the custom integration.

Iā€™m still using this code. I noticed that despite sending a ā€œbrightnessā€ value of 255, when I send random RGB colors, the brightness of the actual light varies as well. Any suggestions?