Skip to content

Commit

Permalink
fix model id change breaking script
Browse files Browse the repository at this point in the history
- Update forum URL
  • Loading branch information
zanix committed Nov 1, 2023
1 parent 735e0fc commit 56a7711
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

Set LED effects for Inovelli VZM31-SN Blue Series 2-1 Switches

[Forum](https://community.home-assistant.io/t/z2m-inovelli-vzm31-sn-blue-series-2-1-switch-led-notification-script/489620)
[Forum](https://community.home-assistant.io/t/z2m-inovelli-blue-series-switch-led-notification-script-vzm31-sn-vzm35-sn/489620)
| [YAML](https://github.com/zanix/home-assistant-blueprints/blob/main/script/inovelli_blue_led_zigbee2mqtt.yaml)

[![Import Blueprint][blueprint-import]](https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fgithub.com%2Fzanix%2Fhome-assistant-blueprints%2Fblob%2Fmain%2Fscript%2Finovelli_blue_led_zigbee2mqtt.yaml)
Expand Down
33 changes: 20 additions & 13 deletions script/inovelli_blue_led_zigbee2mqtt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ blueprint:
- Inovelli 2-in-1 switch + dimmer (VZM31-SN)
- Inovelli Fan Controller (VZM35-SN)
Forum: https://community.home-assistant.io/t/z2m-inovelli-vzm31-sn-blue-series-2-1-switch-led-notification-script/489620
Forum: https://community.home-assistant.io/t/z2m-inovelli-blue-series-switch-led-notification-script-vzm31-sn-vzm35-sn/489620
GitHub: https://github.com/zanix/home-assistant-blueprints
ℹ️ Version: 2023.10.2
ℹ️ Version: 2023.10.3
domain: script
source_url: https://github.com/zanix/home-assistant-blueprints/blob/main/script/inovelli_blue_led_zigbee2mqtt.yaml

Expand Down Expand Up @@ -217,7 +217,7 @@ variables:
{# Convert to a list #}
{% if ',' in area %}
{% set areanum = area.split(',') | count %}
{% for i in range(0,areanum) %}
{% for i in range(0, areanum) %}
{% set areas.areas = areas.areas + [area.split(',')[i]|string|trim ] %}
{% endfor %}
{% elif area[0]|count == 1 %}
Expand All @@ -229,9 +229,11 @@ variables:
{# Detect switches #}
{% for area in areas.areas %}
{% for ent in area_entities(area) %}
{% if device_attr(ent, 'model') in models and ent.split('.')[0] in domains %}
{% set switch.entities = switch.entities + [ent|string|trim] %}
{% endif %}
{% for model in models %}
{% if model in device_attr(ent, 'model') | default('', true) and ent.split('.')[0] in domains %}
{% set switch.entities = switch.entities + [ent|string|trim] %}
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endif %}
Expand All @@ -242,7 +244,7 @@ variables:
{# Convert to a list #}
{% if ',' in device %}
{% set devicenum = device.split(',') | count %}
{% for i in range(0,devicenum) %}
{% 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 #}

Check warning on line 250 in script/inovelli_blue_led_zigbee2mqtt.yaml

View workflow job for this annotation

GitHub Actions / 🧹 YAML Lint

line too long
Expand All @@ -253,9 +255,11 @@ variables:
{# Detect switches #}
{% for device in devices.devices %}
{% for ent in device_entities(device) %}
{% if device_attr(ent, 'model') in models and ent.split('.')[0] in domains %}
{% set switch.entities = switch.entities + [ent|string|trim] %}
{% endif %}
{% for model in models %}
{% if model in device_attr(ent, 'model') | default('', true) and ent.split('.')[0] in domains %}
{% set switch.entities = switch.entities + [ent|string|trim] %}
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endif %}
Expand All @@ -276,9 +280,11 @@ variables:
{% endif %}
{# Detect switches #}
{% for ent in entities.entities %}
{% if device_attr(ent, 'model') in models and ent.split('.')[0] in domains %}
{% set switch.entities = switch.entities + [ent|string|trim] %}
{% endif %}
{% for model in models %}
{% if model in device_attr(ent, 'model') | default('', true) and ent.split('.')[0] in domains %}
{% set switch.entities = switch.entities + [ent|string|trim] %}
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
Expand Down Expand Up @@ -439,6 +445,7 @@ sequence:
notification_id: 'inovelli_blue_led'
title: 'DEBUG: script.inovelli_blue_led'
message: |-
target list: {{ target }}
entity list: {{ entity_list }}
entity count: {{ entity_list|count }}
led: {{ led }} ({{ led_value }})
Expand Down

0 comments on commit 56a7711

Please sign in to comment.