Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug - Phillips Hue (24131092621) Does not pass it's first conditions #558

Open
1 task
trashdaddy opened this issue Aug 3, 2023 · 2 comments
Open
1 task
Labels
blueprint An issue related to a blueprint bug Something isn't working

Comments

@trashdaddy
Copy link

Blueprint name

24131092621

Home Assistant Core Version

2023.7.3

Home Assistant Installation Type

Home Assistant Operating System

Description

When using this BP with Zigbee2MQTT, the automation never gets past the first condition, as shown in the automation's trace page. I am not skillful enough to determine the exact cause when looking at the code.

Automation YAML config

blueprint:
  name: Controller - Philips 324131092621 Hue Dimmer switch
  description: "# Controller - Philips 324131092621 Hue Dimmer switch\n\nController
    automation for executing any kind of action triggered by the provided Philips
    324131092621 Hue Dimmer switch. Allows to optionally loop an action on a button
    long press.\nSupports deCONZ, ZHA, Zigbee2MQTT.\n\nAutomations created with this
    blueprint can be connected with one or more [Hooks](https://epmatt.github.io/awesome-ha-blueprints/docs/blueprints/hooks)
    supported by this controller.\nHooks allow to easily create controller-based automations
    for interacting with media players, lights, covers and more.\nSee the list of
    [Hooks available for this controller](https://epmatt.github.io/awesome-ha-blueprints/docs/blueprints/controllers/philips_324131092621#available-hooks)
    for additional details.\n\n\U0001F4D5 Full documentation regarding this blueprint
    is available [here](https://epmatt.github.io/awesome-ha-blueprints/docs/blueprints/controllers/philips_324131092621).\n\n\U0001F680
    This blueprint is part of the **[Awesome HA Blueprints](https://epmatt.github.io/awesome-ha-blueprints)
    project**.\n\nℹ️ Version 2022.08.08\n"
  source_url: https://github.com/EPMatt/awesome-ha-blueprints/blob/main/blueprints/controllers/philips_324131092621/philips_324131092621.yaml
  domain: automation
  input:
    integration:
      name: (Required) Integration
      description: Integration used for connecting the remote with Home Assistant.
        Select one of the available values.
      selector:
        select:
          options:
          - deCONZ
          - ZHA
          - Zigbee2MQTT
          custom_value: false
          multiple: false
    controller_device:
      name: (deCONZ, ZHA) Controller Device
      description: The controller device to use for the automation. Choose a value
        only if the remote is integrated with deCONZ, ZHA.
      default: ''
      selector:
        device: {}
    controller_entity:
      name: (Zigbee2MQTT) Controller Entity
      description: The action sensor of the controller to use for the automation.
        Choose a value only if the remote is integrated with Zigbee2MQTT.
      default: ''
      selector:
        entity:
          domain:
          - sensor
          multiple: false
    helper_last_controller_event:
      name: (Required) Helper - Last Controller Event
      description: Input Text used to store the last event fired by the controller.
        You will need to manually create a text input entity for this, please read
        the blueprint Additional Notes for more info.
      default: ''
      selector:
        entity:
          domain:
          - input_text
          multiple: false
    action_button_on_short:
      name: (Optional) On button short press
      description: Action to run on short on button press.
      default: []
      selector:
        action: {}
    action_button_on_long:
      name: (Optional) On button long press
      description: Action to run on long on button press.
      default: []
      selector:
        action: {}
    action_button_on_release:
      name: (Optional) On button release
      description: Action to run on on button release after long press.
      default: []
      selector:
        action: {}
    action_button_on_double:
      name: (Optional) On button double press
      description: Action to run on double on button press.
      default: []
      selector:
        action: {}
    action_button_off_short:
      name: (Optional) Off button short press
      description: Action to run on short off button press.
      default: []
      selector:
        action: {}
    action_button_off_long:
      name: (Optional) Off button long press
      description: Action to run on long off button press.
      default: []
      selector:
        action: {}
    action_button_off_release:
      name: (Optional) Off button release
      description: Action to run on off button release after long press.
      default: []
      selector:
        action: {}
    action_button_off_double:
      name: (Optional) Off button double press
      description: Action to run on double off button press.
      default: []
      selector:
        action: {}
    action_button_up_short:
      name: (Optional) Up button short press
      description: Action to run on short up button press.
      default: []
      selector:
        action: {}
    action_button_up_long:
      name: (Optional) Up button long press
      description: Action to run on long up button press.
      default: []
      selector:
        action: {}
    action_button_up_release:
      name: (Optional) Up button release
      description: Action to run on up button release after long press.
      default: []
      selector:
        action: {}
    action_button_up_double:
      name: (Optional) Up button double press
      description: Action to run on double up button press.
      default: []
      selector:
        action: {}
    action_button_down_short:
      name: (Optional) Down button short press
      description: Action to run on short down button press.
      default: []
      selector:
        action: {}
    action_button_down_long:
      name: (Optional) Down button long press
      description: Action to run on long down button press.
      default: []
      selector:
        action: {}
    action_button_down_release:
      name: (Optional) Down button release
      description: Action to run on down button release after long press.
      default: []
      selector:
        action: {}
    action_button_down_double:
      name: (Optional) Down button double press
      description: Action to run on double down button press.
      default: []
      selector:
        action: {}
    button_on_long_loop:
      name: (Optional) On button long press - loop until release
      description: Loop the on button action until the button is released.
      default: false
      selector:
        boolean: {}
    button_on_long_max_loop_repeats:
      name: (Optional) On button long press - Maximum loop repeats
      description: Maximum number of repeats for the custom action, when looping is
        enabled. Use it as a safety limit to prevent an endless loop in case the corresponding
        stop event is not received.
      default: 500
      selector:
        number:
          min: 1.0
          max: 5000.0
          mode: slider
          step: 1.0
    button_off_long_loop:
      name: (Optional) Off button long press - loop until release
      description: Loop the off button action until the button is released.
      default: false
      selector:
        boolean: {}
    button_off_long_max_loop_repeats:
      name: (Optional) Off button long press - Maximum loop repeats
      description: Maximum number of repeats for the custom action, when looping is
        enabled. Use it as a safety limit to prevent an endless loop in case the corresponding
        stop event is not received.
      default: 500
      selector:
        number:
          min: 1.0
          max: 5000.0
          mode: slider
          step: 1.0
    button_up_long_loop:
      name: (Optional) Up button long press - loop until release
      description: Loop the up button action until the button is released.
      default: false
      selector:
        boolean: {}
    button_up_long_max_loop_repeats:
      name: (Optional) Up button long press - Maximum loop repeats
      description: Maximum number of repeats for the custom action, when looping is
        enabled. Use it as a safety limit to prevent an endless loop in case the corresponding
        stop event is not received.
      default: 500
      selector:
        number:
          min: 1.0
          max: 5000.0
          mode: slider
          step: 1.0
    button_down_long_loop:
      name: (Optional) Down button long press - loop until release
      description: Loop the down button action until the button is released.
      default: false
      selector:
        boolean: {}
    button_down_long_max_loop_repeats:
      name: (Optional) Down button long press - Maximum loop repeats
      description: Maximum number of repeats for the custom action, when looping is
        enabled. Use it as a safety limit to prevent an endless loop in case the corresponding
        stop event is not received.
      default: 500
      selector:
        number:
          min: 1.0
          max: 5000.0
          mode: slider
          step: 1.0
    button_on_double_press:
      name: (Optional) Expose on button double press event
      description: Choose whether or not to expose the virtual double press event
        for the on button. Turn this on if you are providing an action for the on
        button double press event.
      default: false
      selector:
        boolean: {}
    button_off_double_press:
      name: (Optional) Expose off button double press event
      description: Choose whether or not to expose the virtual double press event
        for the off button. Turn this on if you are providing an action for the off
        button double press event.
      default: false
      selector:
        boolean: {}
    button_up_double_press:
      name: (Optional) Expose up button double press event
      description: Choose whether or not to expose the virtual double press event
        for the up button. Turn this on if you are providing an action for the up
        button double press event.
      default: false
      selector:
        boolean: {}
    button_down_double_press:
      name: (Optional) Expose down button double press event
      description: Choose whether or not to expose the virtual double press event
        for the down button. Turn this on if you are providing an action for the down
        button double press event.
      default: false
      selector:
        boolean: {}
    helper_double_press_delay:
      name: (Optional) Helper - Double Press delay
      description: Max delay between the first and the second button press for the
        double press event. Provide a value only if you are using a double press action.
        Increase this value if you notice that the double press action is not triggered
        properly.
      default: 500
      selector:
        number:
          min: 100.0
          max: 5000.0
          unit_of_measurement: milliseconds
          mode: box
          step: 10.0
    helper_debounce_delay:
      name: (Optional) Helper - Debounce delay
      description: Delay used for debouncing RAW controller events, by default set
        to 0. A value of 0 disables the debouncing feature. Increase this value if
        you notice custom actions or linked Hooks running multiple times when interacting
        with the device. When the controller needs to be debounced, usually a value
        of 100 is enough to remove all duplicate events.
      default: 0
      selector:
        number:
          min: 0.0
          max: 1000.0
          unit_of_measurement: milliseconds
          mode: box
          step: 10.0
variables:
  integration: !input integration
  button_on_long_loop: !input button_on_long_loop
  button_on_long_max_loop_repeats: !input button_on_long_max_loop_repeats
  button_on_double_press: !input button_on_double_press
  button_off_long_loop: !input button_off_long_loop
  button_off_long_max_loop_repeats: !input button_off_long_max_loop_repeats
  button_off_double_press: !input button_off_double_press
  button_up_long_loop: !input button_up_long_loop
  button_up_long_max_loop_repeats: !input button_up_long_max_loop_repeats
  button_up_double_press: !input button_up_double_press
  button_down_long_loop: !input button_down_long_loop
  button_down_long_max_loop_repeats: !input button_down_long_max_loop_repeats
  button_down_double_press: !input button_down_double_press
  helper_last_controller_event: !input helper_last_controller_event
  helper_double_press_delay: !input helper_double_press_delay
  helper_debounce_delay: !input helper_debounce_delay
  integration_id: '{{ integration | lower }}'
  adjusted_double_press_delay: '{{ [helper_double_press_delay - helper_debounce_delay,
    100] | max }}'
  actions_mapping:
    deconz:
      button_on_short:
      - '1000'
      button_on_long:
      - '1001'
      button_on_release:
      - '1003'
      button_off_short:
      - '4000'
      button_off_long:
      - '4001'
      button_off_release:
      - '4003'
      button_up_short:
      - '2000'
      button_up_long:
      - '2001'
      button_up_release:
      - '2003'
      button_down_short:
      - '3000'
      button_down_long:
      - '3001'
      button_down_release:
      - '3003'
    zha:
      button_on_short:
      - on_short_release
      button_on_long:
      - on_hold
      button_on_release:
      - on_long_release
      button_off_short:
      - off_short_release
      button_off_long:
      - off_hold
      button_off_release:
      - off_long_release
      button_up_short:
      - up_short_release
      button_up_long:
      - up_hold
      button_up_release:
      - up_long_release
      button_down_short:
      - down_short_release
      button_down_long:
      - down_hold
      button_down_release:
      - down_long_release
    zigbee2mqtt:
      button_on_short:
      - on_press
      button_on_long:
      - on_hold
      button_on_release:
      - on_hold_release
      button_off_short:
      - off_press
      button_off_long:
      - off_hold
      button_off_release:
      - off_hold_release
      button_up_short:
      - up_press
      button_up_long:
      - up_hold
      button_up_release:
      - up_hold_release
      button_down_short:
      - down_press
      button_down_long:
      - down_hold
      button_down_release:
      - down_hold_release
  button_on_short: '{{ actions_mapping[integration_id]["button_on_short"] }}'
  button_on_long: '{{ actions_mapping[integration_id]["button_on_long"] }}'
  button_on_release: '{{ actions_mapping[integration_id]["button_on_release"] }}'
  button_off_short: '{{ actions_mapping[integration_id]["button_off_short"] }}'
  button_off_long: '{{ actions_mapping[integration_id]["button_off_long"] }}'
  button_off_release: '{{ actions_mapping[integration_id]["button_off_release"] }}'
  button_up_short: '{{ actions_mapping[integration_id]["button_up_short"] }}'
  button_up_long: '{{ actions_mapping[integration_id]["button_up_long"] }}'
  button_up_release: '{{ actions_mapping[integration_id]["button_up_release"] }}'
  button_down_short: '{{ actions_mapping[integration_id]["button_down_short"] }}'
  button_down_long: '{{ actions_mapping[integration_id]["button_down_long"] }}'
  button_down_release: '{{ actions_mapping[integration_id]["button_down_release"]
    }}'
  controller_entity: !input controller_entity
  controller_device: !input controller_device
  controller_id: '{% if integration_id=="zigbee2mqtt" %}{{controller_entity}}{% else
    %}{{controller_device}}{% endif %}'
mode: restart
max_exceeded: silent
trigger:
- platform: event
  event_type: state_changed
  event_data:
    entity_id: !input controller_entity
- platform: event
  event_type:
  - deconz_event
  - zha_event
  event_data:
    device_id: !input controller_device
condition:
- condition: and
  conditions:
  - '{%- set trigger_action -%} {%- if integration_id == "zigbee2mqtt" -%} {{ trigger.event.data.new_state.state
    }} {%- elif integration_id == "deconz" -%} {{ trigger.event.data.event }} {%-
    elif integration_id == "zha" -%} {{ trigger.event.data.command }} {%- endif -%}
    {%- endset -%} {{ trigger_action not in ["","None"] }}'
  - '{{ integration_id != "zigbee2mqtt" or trigger.event.data.new_state.state != trigger.event.data.old_state.state
    }}'
action:
- delay:
    milliseconds: !input helper_debounce_delay
- variables:
    trigger_action: '{%- if integration_id == "zigbee2mqtt" -%} {{ trigger.event.data.new_state.state
      }} {%- elif integration_id == "deconz" -%} {{ trigger.event.data.event }} {%-
      elif integration_id == "zha" -%} {{ trigger.event.data.command }} {%- endif
      -%}'
    trigger_delta: '{{ (as_timestamp(now()) - ((states(helper_last_controller_event)
      | from_json).t if helper_last_controller_event is not none and (states(helper_last_controller_event)
      | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")) else as_timestamp("1970-01-01
      00:00:00"))) * 1000 }}'
- service: input_text.set_value
  data:
    entity_id: !input helper_last_controller_event
    value: '{{ {"a":trigger_action,"t":as_timestamp(now())} | to_json }}'
- choose:
  - conditions: '{{ trigger_action | string in button_on_short }}'
    sequence:
    - choose:
      - conditions: '{{ button_on_double_press }}'
        sequence:
        - choose:
          - conditions: '{{ trigger_action | string in states(helper_last_controller_event)
              and trigger_delta | int <= helper_double_press_delay | int }}'
            sequence:
            - service: input_text.set_value
              data:
                entity_id: !input helper_last_controller_event
                value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json
                  }}'
            - event: ahb_controller_event
              event_data:
                controller: '{{ controller_id }}'
                action: button_on_double
            - choose:
              - conditions: []
                sequence: !input action_button_on_double
          default:
          - delay:
              milliseconds: '{{ adjusted_double_press_delay }}'
          - event: ahb_controller_event
            event_data:
              controller: '{{ controller_id }}'
              action: button_on_short
          - choose:
            - conditions: []
              sequence: !input action_button_on_short
      default:
      - event: ahb_controller_event
        event_data:
          controller: '{{ controller_id }}'
          action: button_on_short
      - choose:
        - conditions: []
          sequence: !input action_button_on_short
  - conditions: '{{ trigger_action | string in button_on_long }}'
    sequence:
    - event: ahb_controller_event
      event_data:
        controller: '{{ controller_id }}'
        action: button_on_long
    - choose:
      - conditions: '{{ button_on_long_loop }}'
        sequence:
        - repeat:
            while: '{{ repeat.index < button_on_long_max_loop_repeats | int }}'
            sequence: !input action_button_on_long
      default: !input action_button_on_long
  - conditions: '{{ trigger_action | string in button_on_release }}'
    sequence:
    - event: ahb_controller_event
      event_data:
        controller: '{{ controller_id }}'
        action: button_on_release
    - choose:
      - conditions: []
        sequence: !input action_button_on_release
  - conditions: '{{ trigger_action | string in button_off_short }}'
    sequence:
    - choose:
      - conditions: '{{ button_off_double_press }}'
        sequence:
        - choose:
          - conditions: '{{ trigger_action | string in states(helper_last_controller_event)
              and trigger_delta | int <= helper_double_press_delay | int }}'
            sequence:
            - service: input_text.set_value
              data:
                entity_id: !input helper_last_controller_event
                value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json
                  }}'
            - event: ahb_controller_event
              event_data:
                controller: '{{ controller_id }}'
                action: button_off_double
            - choose:
              - conditions: []
                sequence: !input action_button_off_double
          default:
          - delay:
              milliseconds: '{{ adjusted_double_press_delay }}'
          - event: ahb_controller_event
            event_data:
              controller: '{{ controller_id }}'
              action: button_off_short
          - choose:
            - conditions: []
              sequence: !input action_button_off_short
      default:
      - event: ahb_controller_event
        event_data:
          controller: '{{ controller_id }}'
          action: button_off_short
      - choose:
        - conditions: []
          sequence: !input action_button_off_short
  - conditions: '{{ trigger_action | string in button_off_long }}'
    sequence:
    - event: ahb_controller_event
      event_data:
        controller: '{{ controller_id }}'
        action: button_off_long
    - choose:
      - conditions: '{{ button_off_long_loop }}'
        sequence:
        - repeat:
            while: '{{ repeat.index < button_off_long_max_loop_repeats | int }}'
            sequence: !input action_button_off_long
      default: !input action_button_off_long
  - conditions: '{{ trigger_action | string in button_off_release }}'
    sequence:
    - event: ahb_controller_event
      event_data:
        controller: '{{ controller_id }}'
        action: button_off_release
    - choose:
      - conditions: []
        sequence: !input action_button_off_release
  - conditions: '{{ trigger_action | string in button_up_short }}'
    sequence:
    - choose:
      - conditions: '{{ button_up_double_press }}'
        sequence:
        - choose:
          - conditions: '{{ trigger_action | string in states(helper_last_controller_event)
              and trigger_delta | int <= helper_double_press_delay | int }}'
            sequence:
            - service: input_text.set_value
              data:
                entity_id: !input helper_last_controller_event
                value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json
                  }}'
            - event: ahb_controller_event
              event_data:
                controller: '{{ controller_id }}'
                action: button_up_double
            - choose:
              - conditions: []
                sequence: !input action_button_up_double
          default:
          - delay:
              milliseconds: '{{ adjusted_double_press_delay }}'
          - event: ahb_controller_event
            event_data:
              controller: '{{ controller_id }}'
              action: button_up_short
          - choose:
            - conditions: []
              sequence: !input action_button_up_short
      default:
      - event: ahb_controller_event
        event_data:
          controller: '{{ controller_id }}'
          action: button_up_short
      - choose:
        - conditions: []
          sequence: !input action_button_up_short
  - conditions: '{{ trigger_action | string in button_up_long }}'
    sequence:
    - event: ahb_controller_event
      event_data:
        controller: '{{ controller_id }}'
        action: button_up_long
    - choose:
      - conditions: '{{ button_up_long_loop }}'
        sequence:
        - repeat:
            while: '{{ repeat.index < button_up_long_max_loop_repeats | int }}'
            sequence: !input action_button_up_long
      default: !input action_button_up_long
  - conditions: '{{ trigger_action | string in button_up_release }}'
    sequence:
    - event: ahb_controller_event
      event_data:
        controller: '{{ controller_id }}'
        action: button_up_release
    - choose:
      - conditions: []
        sequence: !input action_button_up_release
  - conditions: '{{ trigger_action | string in button_down_short }}'
    sequence:
    - choose:
      - conditions: '{{ button_down_double_press }}'
        sequence:
        - choose:
          - conditions: '{{ trigger_action | string in states(helper_last_controller_event)
              and trigger_delta | int <= helper_double_press_delay | int }}'
            sequence:
            - service: input_text.set_value
              data:
                entity_id: !input helper_last_controller_event
                value: '{{ {"a":"double_press","t":as_timestamp(now())} | to_json
                  }}'
            - event: ahb_controller_event
              event_data:
                controller: '{{ controller_id }}'
                action: button_down_double
            - choose:
              - conditions: []
                sequence: !input action_button_down_double
          default:
          - delay:
              milliseconds: '{{ adjusted_double_press_delay }}'
          - event: ahb_controller_event
            event_data:
              controller: '{{ controller_id }}'
              action: button_down_short
          - choose:
            - conditions: []
              sequence: !input action_button_down_short
      default:
      - event: ahb_controller_event
        event_data:
          controller: '{{ controller_id }}'
          action: button_down_short
      - choose:
        - conditions: []
          sequence: !input action_button_down_short
  - conditions: '{{ trigger_action | string in button_down_long }}'
    sequence:
    - event: ahb_controller_event
      event_data:
        controller: '{{ controller_id }}'
        action: button_down_long
    - choose:
      - conditions: '{{ button_down_long_loop }}'
        sequence:
        - repeat:
            while: '{{ repeat.index < button_down_long_max_loop_repeats | int }}'
            sequence: !input action_button_down_long
      default: !input action_button_down_long
  - conditions: '{{ trigger_action | string in button_down_release }}'
    sequence:
    - event: ahb_controller_event
      event_data:
        controller: '{{ controller_id }}'
        action: button_down_release
    - choose:
      - conditions: []
        sequence: !input action_button_down_release

To Reproduce

  1. Create automation using Zigbee2MQTT
  2. Locate the created automation in 'Automations and Scenes"
  3. Right Click on 'Traces'
  4. Click on 'Step Details' tab or 'Trace Timeline' tab.
  5. See error in Trace Timeline tab:

'Stopped because a condition failed at Month, Date, Year at time (runtime: 0.00 seconds)'

image

  1. Or see error in Step Details tab:

Executed: August 2, 2023 at 10:52:46 PM
Result:
result: false
conditions/0
Executed: August 2, 2023 at 10:52:46 PM
Result:
result: false
entities: []

image

Expected behavior

When a button is pressed on the controller, the action as prescribed in the automation made from the blueprint should activate.

Actual Behaviour

When a button is pressed on the controller, it is accepted and logged within the device, and the automation, but does not activate the command.

Additional Details

  • I'd like to help developing a fix for this issue.

Screenshots

No response

Additional context

No response

@trashdaddy trashdaddy added blueprint An issue related to a blueprint bug Something isn't working labels Aug 3, 2023
@jhueppauff
Copy link

I am seeing the same issue. Did you manage to solve this?

@jhueppauff
Copy link

Seems like there is already a PR for this issue, which fixes this for me ;-)
#542

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blueprint An issue related to a blueprint bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants