Automation to set config parameters

Hi,

I’ve been searching for this and have yet to figure it out. I understand I can set config parameters in HA. What I haven’t figured out is how to template a list of entity id’s based on a zwave model so I can write the automation once and than bulk update config parameters without have to manually search entity id’s etc.

ie. I want to grab all the HS-WD100+ in HA, loop through them and set the config parameters without having to list the entity_id’s manually.

Here’s a pure template service call that I think does what you want.

service: zwave_js.set_config_parameter
data:
  parameter: 4
  value: 'No'
  device_id: >
    {% set ns = namespace(devices=[]) %}
    {% for id in integration_entities("zwave_js") %}
    {% if device_attr(id, "model") == "14294 / ZW3005" %}
    {% set ns.devices = ns.devices + [device_id(id)] %}
    {% endif %}
    {% endfor %}
    {{ ns.devices | unique | list }}

It loops through all of the entities for the Z-Wave JS integration and for each entity, queries the entity’s device model, and if it’s the desired model name ("14294 / ZW3005" in the example) adds the entity’s device ID to a list of device IDs. At the end, it reduces the list to the unique set of device IDs. That set is then the target of the service call.

Another non-template approach would be to just create a group consisting of one entity from each desired device, and just pass the group entity ID to the service call instead.

2 Likes

That’s amazing! Going to check this out. Thanks so much for the help.

1 Like

Was looking for a solution to simplify an automation where I update a ZWave parameter for a large number of devices and this worked PERFECTLY. Wanted to say THANK YOU to freshcoat for this snippet of code that made things a ton easier as I migrated some automations from HomeSeer to HomeAssistant!

1 Like

Wanted to share what I ended up with which loops over devices instead of doing it by param:

alias: HS-WD100+
sequence:
  - repeat:
      for_each: >
        {% set ns = namespace(devices=[]) %} {% for id in
        integration_entities("zwave_js") %} {% if device_attr(id, "model") ==
        "HS-WD100+" %} {% set ns.devices = ns.devices + [device_id(id)] %} {%
        endif %} {% endfor %} {{ ns.devices | unique | list }}
      sequence:
        - service: zwave_js.set_config_parameter
          data:
            parameter: "7"
            value: "1"
          target:
            device_id: "{{ repeat.item }}"
        - service: zwave_js.set_config_parameter
          data:
            parameter: "8"
            value: "1"
          target:
            device_id: "{{ repeat.item }}"
        - service: zwave_js.set_config_parameter
          data:
            parameter: "9"
            value: "1"
          target:
            device_id: "{{ repeat.item }}"
        - service: zwave_js.set_config_parameter
          data:
            parameter: "10"
            value: "1"
          target:
            device_id: "{{ repeat.item }}"
mode: single