Help with blueprint!

Im trying to create a blueprint that executes a specific behavior controlling two lights with a lutron caseta remote.

  • For the On button Both lamps turn on.
  • For the raise button :
    I want to make sure that the brightness of the lamp that’s on is increased. If there 1 lamp on ,and the other off, I want the brightness to only increase on the one that’s on.

cases:

Both lamps are off: increase brightness by 2
Both lamps are on: increase brightness by 2%
Only 1 lamp is on: increate brightness by 2% on the one that’s ON

  • For the middle button, I want a custom action, and I also want a middle button hold action

  • For the lower button - raises brightness to both lamps, but I want to make it so that when a lamp brightness is above 15 brightness points (out of 255) then the step is 8 points. If the brightness is below 15, then the step is 2 points.

For the off button - Toggles both off

I created this blueprint but I am having a hard time making it work… If anyone feels like taking a look!

blueprint:
  name: Custom Lutron Pico 5 - Dual Lamp Control
  description: >
    Control two lamps with a Lutron Pico 5 Button remote, with custom logic for brightness adjustments and extended functionality for the middle button.
  domain: automation
  input:
    pico_1:
      name: Pico Device
      description: Pico remote to associate with light entity.
      selector:
        device:
          model: PJ2-3BRL-GXX-X01 (Pico3ButtonRaiseLower)
          multiple: false
    lamp_entity_1:
      name: First Lamp Entity
      description: First lamp entity to control.
      selector:
        entity:
          domain: light
    lamp_entity_2:
      name: Second Lamp Entity
      description: Second lamp entity to control.
      selector:
        entity:
          domain: light
    on_transition:
      name: On Transition Duration
      description: Duration in seconds for the lamps to transition on.
      selector:
        number:
          min: 0
          max: 15
          unit_of_measurement: seconds
          mode: slider
          step: 1
      default: 1
    off_transition:
      name: Off Transition Duration
      description: Duration in seconds for the lamps to transition off.
      selector:
        number:
          min: 0
          max: 15
          unit_of_measurement: seconds
          mode: slider
          step: 1
      default: 2
    middle_button_action:
      name: Middle Button Single Press Action
      description: Action to execute when the middle button is pressed.
      selector:
        action: {}
    middle_button_hold:
      name: Middle Button Hold Action
      description: Actions to execute when the middle button is held.
      selector:
        action: {}
    hold_duration:
      name: Hold Duration
      description: Duration in seconds to hold the middle button before the action takes place.
      selector:
        number:
          min: 1
          max: 10
          unit_of_measurement: seconds
          mode: slider
          step: 1
      default: 3

trigger:
  - platform: device
    device_id: !input pico_1
    domain: lutron_caseta
    type: press
    subtype: "on"
    id: on_pressed
  - platform: device
    device_id: !input pico_1
    domain: lutron_caseta
    type: press
    subtype: "off"
    id: off_pressed
  - platform: device
    device_id: !input pico_1
    domain: lutron_caseta
    type: press
    subtype: "raise"
    id: raise_pressed
  - platform: device
    device_id: !input pico_1
    domain: lutron_caseta
    type: release
    subtype: "raise"
    id: raise_released
  - platform: device
    device_id: !input pico_1
    domain: lutron_caseta
    type: press
    subtype: "lower"
    id: lower_pressed
  - platform: device
    device_id: !input pico_1
    domain: lutron_caseta
    type: release
    subtype: "lower"
    id: lower_released
  - platform: device
    device_id: !input pico_1
    domain: lutron_caseta
    type: press
    subtype: "middle"
    id: middle_pressed
  - platform: device
    device_id: !input pico_1
    domain: lutron_caseta
    type: hold
    subtype: "middle"
    id: middle_held

action:
  - choose:
      - conditions:
          - condition: trigger
            id: on_pressed
        sequence:
          - service: light.turn_on
            data:
              transition: !input on_transition
            target:
              entity_id:
                - !input lamp_entity_1
                - !input lamp_entity_2
      - conditions:
          - condition: trigger
            id: off_pressed
        sequence:
          - service: light.turn_off
            data:
              transition: !input off_transition
            target:
              entity_id:
                - !input lamp_entity_1
                - !input lamp_entity_2
      - conditions:
          - condition: trigger
            id: raise_pressed
        sequence:
          - repeat:
              while:
                - condition: state
                  entity_id: !input pico_1
                  state: 'on'
              sequence:
                - choose:
                    - conditions:
                        - condition: state
                          entity_id: !input lamp_entity_1
                          state: 'on'
                      sequence:
                        - service: light.turn_on
                          data:
                            brightness_step_pct: 2
                          target:
                            entity_id: !input lamp_entity_1
                    - conditions:
                        - condition: state
                          entity_id: !input lamp_entity_2
                          state: 'on'
                      sequence:
                        - service: light.turn_on
                          data:
                            brightness_step_pct: 2
                          target:
                            entity_id: !input lamp_entity_2
                - delay: 100ms
      - conditions:
          - condition: trigger
            id: lower_pressed
        sequence:
          - repeat:
              while:
                - condition: state
                  entity_id: !input pico_1
                  state: 'on'
              sequence:
                - choose:
                    - conditions:
                        - condition: state
                          entity_id: !input lamp_entity_1
                          state: 'on'
                      sequence:
                        - service: light.turn_on
                          data:
                            brightness_step_pct: -2
                          target:
                            entity_id: !input lamp_entity_1
                    - conditions:
                        - condition: state
                          entity_id: !input lamp_entity_2
                          state: 'on'
                      sequence:
                        - service: light.turn_on
                          data:
                            brightness_step_pct: -2
                          target:
                            entity_id: !input lamp_entity_2
                - delay: 100ms
      - conditions:
          - condition: trigger
            id: middle_pressed
        sequence:
          - choose:
              - conditions:
                  - condition: template
                    value_template: "{{ middle_button_action != none }}"
                sequence: !input middle_button_action
              default:
                - service: light.turn_on
                  data:
                    brightness_pct: 80
                    kelvin: 2700
                  target:
                    entity_id:
                      - !input lamp_entity_1
                      - !input lamp_entity_2
      - conditions:
          - condition: trigger
            id: middle_held
        sequence:
          - delay:
              seconds: !input hold_duration
          - choose:
              - conditions:
                  - condition: template
                    value_template: "{{ middle_button_hold != none }}"
                sequence: !input middle_button_hold

mode: restart

OK, you know what you want. Good.
Did you make simple versions of this work without the blueprint?
You SHOULD first write an automation or script that does exactly what you want to achieve then plug in the stuff to make it a blueprint. Getting the logic working is not always easy, and becomes obfuscated in all that variable substitution stuff, making everything frustrating.
Get what you want working, then make the blueprint out of that by adding the !inputs and variables and such. Try to avoid device triggers and selectors. You can make them work, but people tend to struggle with those when dealing with them outside of the GUI editor context.

In this case it looks to me like you may want to have a script that checks if a light is on from the list you send it and if it is do your brightness control on it. Then when you make the blueprint, service call that script with the field data sent along and it can do the thing.

2 Likes

Thank you so much for your reply Sir_Goodenough!! Ill go the automation route first!

1 Like