diff --git a/README.md b/README.md index 6c37b87..1ded002 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Set LED effects for Inovelli VZM31-SN Blue Series 2-1 Switches **All files are edited with [Visual Studio Code](https://code.visualstudio.com).** -[github-linter-status-shield]: https://img.shields.io/github/workflow/status/zanix/home-assistant-blueprints/linters/master?style=flat-square&label=linters&logo=github-actions&logoColor=838B95 +[github-linter-status-shield]: https://img.shields.io/github/actions/workflow/status/zanix/home-assistant-blueprints/linters.yaml?branch=master&style=flat-square&label=linters&logo=github-actions&logoColor=838B95 [github-linter-status]: https://github.com/zanix/home-assistant-blueprints/actions/workflows/linters.yaml [github-last-commit]: https://img.shields.io/github/last-commit/zanix/home-assistant-blueprints/master?style=flat-square&logo=github&logoColor=838B95 diff --git a/script/inovelli_blue_led_zigbee2mqtt.yaml b/script/inovelli_blue_led_zigbee2mqtt.yaml index 7b7a2b2..4294ade 100644 --- a/script/inovelli_blue_led_zigbee2mqtt.yaml +++ b/script/inovelli_blue_led_zigbee2mqtt.yaml @@ -9,16 +9,13 @@ blueprint: - Selectors for LED Number, Color, Brightness Level, Effect, and Duration - LED Number, Color, Effect, and Duration can accept direct values or the “friendly name” listed in the dropdown - Debug info to diagnose issues - - Supports effects added in firmware v2.02 - - New effects require updated zigbee-herdsman-converters which is not in Zigbee2MQTT as of version 1.28.2. - This is likely to be added in the next version of Zigbee2MQTT. - - New effects: aurora, slow_falling, medium_falling, fast_falling, slow_rising, medium_rising, fast_rising, medium_blink, slow_chase, fast_chase, fast_siren, slow_siren + - Warning: Debug mode will create a persistent message for every entity called in the script plus 1 Forum: https://community.home-assistant.io/t/z2m-inovelli-vzm31-sn-blue-series-2-1-switch-led-notification-script/489620 GitHub: https://github.com/zanix/home-assistant-blueprints - ℹ️ Version: 2022.11.2 + ℹ️ Version: 2023.3.1 domain: script source_url: https://github.com/zanix/home-assistant-blueprints/blob/master/script/inovelli_blue_led_zigbee2mqtt.yaml @@ -47,7 +44,6 @@ fields: name: LED description: Choose which LED to control. Default is All. default: All - example: Led 3 selector: select: custom_value: true @@ -63,7 +59,6 @@ fields: color: name: LED Color default: Red - example: Yellow selector: select: custom_value: true @@ -93,7 +88,6 @@ fields: name: 'Effect' description: Choose LED effect to apply. default: Clear - example: Slow Blink selector: select: custom_value: true @@ -123,7 +117,6 @@ fields: name: Duration description: How long should the effect run? default: Indefinitely - example: 10 Seconds selector: select: custom_value: true @@ -188,9 +181,16 @@ fields: - Forever enable_debug: name: Enable debug output? - default: false selector: boolean: + command_path_map: + name: Command Path Map + description: >- + Map of Entity IDs with a MQTT command path map when HA and Z2M do not match up. + Enter a new row for each mapping: light.entity_name: "zigbee2mqtt/path/to/device/set"'. + You can also use a template but you need to use YAML mode to do so. + selector: + object: variables: # Set to true to create a "persistent_notification" with debugging information. @@ -202,6 +202,7 @@ variables: device: '{{ target.device_id|default([])|lower }}' entity: '{{ target.entity_id|default([])|lower }}' entity_id: '{{ entity_id|default([])|lower }}' + command_path_map: '{{ command_path_map|default([]) }}' entity_list: > {% set switch = namespace(entities=[]) %} @@ -211,14 +212,14 @@ variables: {# Convert to a list #} {% if ',' in area %} {% set areanum = area.split(',') | count %} - {% for i in range(0,areanum) %} - {% set areas.areas = areas.areas + [area.split(',')[i]|string|trim ] %} - {% endfor %} - {% elif area[0]|count == 1 %} - {# if the first item in the list has only a single character, it can't be a valid entity #} - {% set areas.areas = areas.areas + [area|string|trim] %} - {% else %} - {% set areas.areas = area %} + {% for i in range(0,areanum) %} + {% set areas.areas = areas.areas + [area.split(',')[i]|string|trim ] %} + {% endfor %} + {% elif area[0]|count == 1 %} + {# if the first item in the list has only a single character, it can't be a valid entity #} + {% set areas.areas = areas.areas + [area|string|trim] %} + {% else %} + {% set areas.areas = area %} {% endif %} {# Detect switches #} {% for area in areas.areas %} @@ -236,13 +237,13 @@ variables: {# Convert to a list #} {% if ',' in device %} {% set devicenum = device.split(',') | count %} - {% for i in range(0,devicenum) %} - {% set devices.devices = devices.devices + [device.split(',')[i]|string|trim ] %} - {% endfor %} - {% elif device[0]|count == 1 %} {# if the first item in the list has only a single character, it can't be a valid entity #} - {% set devices.devices = devices.devices + [device|string|trim] %} - {% else %} - {% set devices.devices = device %} + {% for i in range(0,devicenum) %} + {% set devices.devices = devices.devices + [device.split(',')[i]|string|trim ] %} + {% endfor %} + {% elif device[0]|count == 1 %} {# if the first item in the list has only a single character, it can't be a valid entity #} + {% set devices.devices = devices.devices + [device|string|trim] %} + {% else %} + {% set devices.devices = device %} {% endif %} {# Detect switches #} {% for device in devices.devices %} @@ -260,13 +261,13 @@ variables: {# Convert to a list #} {% if ',' in entity %} {% set entitynum = entity.split(',') | count %} - {% for i in range(0,entitynum) %} - {% set entities.entities = entities.entities + [entity.split(',')[i]|string|trim ] %} - {% endfor %} - {% elif entity[0]|count == 1 %} {# if the first item in the list has only a single character, it can't be a valid entity #} - {% set entities.entities = entities.entities + [entity|string|trim] %} - {% else %} - {% set entities.entities = entity %} + {% for i in range(0, entitynum) %} + {% set entities.entities = entities.entities + [entity.split(',')[i]|string|trim ] %} + {% endfor %} + {% elif entity[0]|count == 1 %} {# if the first item in the list has only a single character, it can't be a valid entity #} + {% set entities.entities = entities.entities + [entity|string|trim] %} + {% else %} + {% set entities.entities = entity %} {% endif %} {# Detect switches #} {% for ent in entities.entities %} @@ -282,13 +283,13 @@ variables: {# Convert to a list #} {% if ',' in entity_id %} {% set entitynum = entity_id.split(',') | count %} - {% for i in range(0,entitynum) %} - {% set entities.entities = entities.entities + [entity_id.split(',')[i]|string|trim ] %} - {% endfor %} - {% elif entity_id[0]|count == 1 %} {# if the first item in the list has only a single character, it can't be a valid entity #} - {% set entities.entities = entities.entities + [entity_id|string|trim] %} - {% else %} - {% set entities.entities = entity_id %} + {% for i in range(0, entitynum) %} + {% set entities.entities = entities.entities + [entity_id.split(',')[i]|string|trim ] %} + {% endfor %} + {% elif entity_id[0]|count == 1 %} {# if the first item in the list has only a single character, it can't be a valid entity #} + {% set entities.entities = entities.entities + [entity_id|string|trim] %} + {% else %} + {% set entities.entities = entity_id %} {% endif %} {# Detect switches #} {% for ent in entities.entities %} @@ -460,6 +461,7 @@ sequence: level: {{ level }} effect: {{ effect }} ({{ effect_value }}) duration: {{ duration }} ({{ duration_value }}) + command_path_map: {{ command_path_map }} # Do not continue if we don't have at least one entity - condition: template @@ -471,6 +473,13 @@ sequence: for_each: '{{ entity_list }}' sequence: - variables: + # Check for a command_path override. + command_path: >- + {% if repeat.item in command_path_map %} + {{ command_path_map[repeat.item] }} + {% else %} + zigbee2mqtt/{{ device_attr(repeat.item, "name") }}/set + {% endif %} # Construct the payload payload: |- {% if led_value == -1 %} @@ -507,13 +516,13 @@ sequence: message: |- entity: {{ repeat.item }} device name: {{ device_attr(repeat.item, "name") }} - topic: zigbee2mqtt/{{ device_attr(repeat.item, "name") }}/set + topic: {{ command_path }} payload: {{ payload }} # Send payload to the switch - service: mqtt.publish data: - topic: 'zigbee2mqtt/{{ device_attr(repeat.item, "name") }}/set' + topic: '{{ command_path }}' payload_template: "{{ payload }}" icon: mdi:led-on