home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.81k stars 30.51k forks source link

Limitation using blueprints with the `ozw.scene_activated` event #44544

Closed tprelog closed 3 years ago

tprelog commented 3 years ago

The problem

There is currently a limitation creating blueprints using the device selector, specifically when trying to use the ozw.scene_activated event from OpenZWave (beta).

Basically the problem is, there is no way to get the node_id of a device. The node_id is needed to determine which device has trigger the ozw.scene_activated event. Without the node_id, the scene is triggered from any device the fires the event.

The node_id is currently stored as an entity attribute however using the entity selector does not work.

Here are at least two reasons using the device selector is preferred.

  1. Some Z-Wave devices, such scene controllers and remotes do not create an entity that can be used for scene events
  2. The are Z-Wave devices, such as inovelli switches and dimmers, that require using the device selector and model filter, in order to limit the selector to the correct scene enabled devices

Environment

Problem-relevant configuration.yaml

Here is my generic blueprint for the Aeotec NanoMote - The does blueprint works, however the devices selector is only being used a a reference, to list valid devices. The node_id must still be looked up and entered manually.

blueprint:
  name: Aeotec ZWA003 NanoMote Quad
  description: Create automations for the Aeotec ZWA003 NanoMote Quad using the OZW integration. 
  domain: automation
  input:
    aeotec_nanomote:
      name: Aeotec NanoMote Quad
      description: "List of available NanoMote Quad remotes to configure. 
      This list is only a reference. At this time, it is not possible
      to obtain the node's id using the device selector."
      selector:
          device:
            integration: ozw
            manufacturer: Aeotec Limited
            model: ZWA003 NanoMote Quad
    ozw_node_id:
      name: Node ID
      description: "Enter the node id for an available NanoMote Quad you wish
      to configure. For now, this field is required. At this time, it is not
      possible to obtain the node's id when using the device selector."
    button_1:
      name: Press Button One
      description: Action to run on button press.
      default: []
      selector:
        action: {}
    button_2:
      name: Press Button Two
      description: Action to run on button press.
      default: []
      selector:
        action: {}
    button_3:
      name: Press Button Three
      description: Action to run on button press.
      default: []
      selector:
        action: {}
    button_4:
      name: Press Button Four
      description: Action to run on button press.
      default: []
      selector:
        action: {}
mode: single
max_exceeded: silent
variables:
  device_id: !input aeotec_nanomote
  ozw_node_id: !input ozw_node_id
trigger:
  - platform: event
    event_type: ozw.scene_activated
    event_data:
      scene_value_id: 1
condition: "{{ trigger.event.data.node_id == (ozw_node_id | int) }}"
action:
  - variables:
      scene_id: "{{ trigger.event.data.scene_id }}"
  - choose:
    - conditions: "{{ scene_id == 1 }}"
      sequence: !input button_1
    - conditions: "{{ scene_id == 2 }}"
      sequence: !input button_2
    - conditions: "{{ scene_id == 3 }}"
      sequence: !input button_3
    - conditions: "{{ scene_id == 4 }}"
      sequence: !input button_4

Traceback/Error logs

NA

Additional information

I'm not sure how difficult this is to solve. After several brief discussion on discord, I was asked to file an issue with the integration.

It's my understanding that a device does not have attributes so I'm not sure if it's possible to obtain the node_id in this manner.

I think the solution being implied, was to have the device_id added to the ozw.scene_activated - event_data. This would allow for the scene to be controlled based on the firing device, effectively providing an alternative control, instead of using the node_id.


Links to some the blueprints in the Home Assistant Forum that are effected by this.

probot-home-assistant[bot] commented 3 years ago

ozw documentation ozw source (message by IssueLinks)

MartinHjelmare commented 3 years ago

We should at least add the device id to the event data.

tprelog commented 3 years ago

It seems that it will not be possible to make a user friendly blueprint for OZW scene events until this is resolved.

Is there a suggestion for a workaround?

Is there anything I can do to help resolve this?

MartinHjelmare commented 3 years ago

A PR to add device id to event data is welcome.

tprelog commented 3 years ago

Ok Cool, I just need to learn Python first, but I'll give it a go.

tprelog commented 3 years ago

I'm just closing this. According to https://github.com/home-assistant/architecture/issues/483, it seems Home Assistant is moving away from ozwdaemon, and will instead use zwave-js moving forward.

Hopefully there will be more potential to see this addressed (if not already) in the next integration