Automation - ZHA_EVENT value below a value or above a value

Hello all.

I have a Lutron Aurora that I have paired. I can’t get the thing to bind, which is probably good because I have read that it won’t report state back to HA anyways.

That being said, trying to set up an automation that when a zha_event occurs that it will read that event and based on a value range it will brighten or dim the bulb. However I can’t figure out how to have a trigger that is based on the event data being in a range.

In the below snippit, you will see args: with 2 values, I want to set a range based on the arg being less then 255 it would dim, but if above 0 it would brighten. How can i create a trigger on an automation for that?

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "ff:ff:00:0f:e7:fd:01:5d",
        "unique_id": "ff:ff:00:0f:e7:fd:01:5d:1:0x0008",
        "endpoint_id": 1,
        "cluster_id": 8,
        "command": "move_to_level_with_on_off",
        "args": [
            255,
            2
        ]
    },
    "origin": "LOCAL",
    "time_fired": "2020-10-13T16:21:24.980032+00:00",
    "context": {
        "id": "239b28850d7011eba74679a17a6e38b7",
        "parent_id": null,
        "user_id": null
    }
}

That doesn’t make sense. If args is 200, which is less than 255 AND above 0, what should it do? Dim or brighten the light?

Good point. Lets split the difference if it’s between 0 and 127 it dims, if it’s 127-255 it increases brightness.

You could try something like this:

automation:
  trigger:
    platform: event
    event_type: zha_event
    event_data:
      unique_id: ""ff:ff:00:0f:e7:fd:01:5d:1:0x0008"
  action:
    service: light.turn_on
    entity_id: light.YOUR_LIGHT
    data:
      brightness_step_pct: "{{ 10 if trigger.event.data.args[0] > 126 else -10 }}"

This should brighten the light by 10 % when the value is above 127 or higher and dim the light by 10% when the value is below 127.

Okay finally have this functioning a bit.

It will always dim but not rise. Is it possible since there are two arguments, one of which is always 2, that it’s not picking that argument?

 "args": [
            255,
            2

Using the above example the second argument “2” is always static, never changes, but the one that is 255 is the one that I want it to look at. Is there a way to make sure that it recognizes that argument and and when the second one is 2?

My proposed code already looks only at the first argument. I don’t understand what you want exactly.

I figured it out… But to answer your question the argument above has to values, so was trying to see how to pull the value of the 1st value, and make an action based on that. However, the second argument had to equal 2.

Apparently this can be done by using the [0] for the first value and [1] in the second value.

So {{trigger.event.data.args[0] > 127}} is for the top value, and {{trigger.event.data.args[1] == 2}} represents when the second value equals 2. This allows for you to use conditions to trigger the action like below.

alias: Test- Aurora Toggle Dim
description: ''
trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_ieee: 'ff:ff:00:0f:e7:fd:d0:ba'
      unique_id: 'ff:ff:00:0f:e7:fd:d0:ba:1:0x0008'
      device_id: 032f8a9579ee7cd63ca3a32d794c1f22
      endpoint_id: 1
      cluster_id: 8
      command: move_to_level_with_on_off
condition:
  - condition: state
    entity_id: light.hue_1
    state: 'on'
action:
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.args[0] > 127}}'
        sequence:
          - type: brightness_increase
            device_id: 0cc00b086685b74646fcc77da98a82f8
            entity_id: light.hue_1
            domain: light
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.args[0] < 127}}'
          - condition: template
            value_template: '{{ trigger.event.data.args[1] != 2}}'
          - condition: numeric_state
            entity_id: light.hue_1
            attribute: brightness
            above: '25'
        sequence:
          - type: brightness_decrease
            device_id: 0cc00b086685b74646fcc77da98a82f8
            entity_id: light.hue_1
            domain: light
    default: []
mode: single
max: 10

I’m sorry, but I didn’t understand what you wanted to do from your posts. At one place you wrote the second argument is always static, never changes and now suddenly it does xD
However, I’m glad that you figured it out.