Area for zha_event in automations

Is it possible to access the area of the corresponding device for an zha_event in automations? Something like this non functioning mockup:

alias: Test Automation
mode: parallel
trigger:
  - device_id: 0968dc895d8d1f9b8c5ea30f41e6ff40
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: remote_button_short_press
  - device_id: a3785e7fac259630f83e091d67eae5a6
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: remote_button_short_press
action:
  - service: light.toggle
    data:
      entity_id: >
        light.bla_{{area}}

The zha_events I’m interested in are carrying the following data - available for automation templating in the trigger variable. Unfortunately for me the configured area isn’t one of them.

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:02:83:cf:50",
        "unique_id": "00:15:8d:00:02:83:cf:50:1:0x0012",
        "device_id": "0968dc895d8d1f9b8c5ea30f41e6ff40",
        "endpoint_id": 1,
        "cluster_id": 18,
        "command": "single",
        "args": {
            "press_type": "single",
            "attr_id": 85,
            "value": 1
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-01-11T04:06:11.286121+00:00",
    "context": {
        "id": "15a2ddcaeb2e74a2b892457bff3ff10f",
        "parent_id": null,
        "user_id": null
    }
}

Any workarounds?

You can’t currently get the area from a device/entity in an automation/script.

1 Like