I have a script to control the LED bar on Inovelli dimmers and other devices. In Home assistant 2022.5.3 I added functionality to receive an area ID, discover any Inovelli devices in the area, and configure the LED and LED effects on those devices according to other parameters I’d passed. After updating 2022.6.2 I started getting errors when passing areas to the script. I’ve been through the breaking changes for 2022.6 and I was already running the 6.11.0 zwavejs2mqtt Docker container. I don’t see anything else that would apply.
2022-06-05 14:28:48 ERROR (MainThread) [homeassistant.components.script.inovelli_led_zwavejs] Inovelli Dimmer and Switch LEDs ZwaveJS: Error executing script. Error rendering template for variables at pos 1: TemplateError: str: Must provide a device or entity ID
2022-06-05 14:28:48 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Error rendering template for call_service at pos 1: TemplateError: str: Must provide a device or entity ID
2022-06-05 14:28:48 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140441646101312] Error handling message: TemplateError: str: Must provide a device or entity ID (unknown_error)
I believe the issue is with the code that discovers Inovelli entities in an area because I can pass a device ID or entity and the script works fine. I’m not completely sure I’m looking in the right spot though. The two sections of code are nearly identical.
Code to discover dimmer entities from an AREA ID give me the errors above:
area_dimmer: >
{% set entities = namespace(areas=[]) %}
{% for dev in area %}
{% for ent in area_entities(dev) %}
{% if is_device_attr(device_id(ent),'model', 'LZW31-SN') and ent.split('.')[0] == 'light' %}
{% set entities.areas = entities.areas + [ent | string] %}
{% endif %}
{% endfor %}
{% endfor %}
{{ entities.areas|lower }}
Code to discover dimmer entities from a DEVICE ID works just fine:
device_dimmer: >
{% set entities = namespace(devices=[]) %}
{% for dev in device %}
{% for ent in device_entities(dev) %}
{% if is_device_attr(device_id(ent),'model', 'LZW31-SN') and ent.split('.')[0] == 'light' %}
{% set entities.devices = entities.devices + [ ent | string] %}
{% endif %}
{% endfor %}
{% endfor %}
{{ entities.devices|lower }}
In the templating sandbox, this code:
{% set area = ['62d97e01b9124f309bdf8a897547071d'] %}
{% set entities = namespace(areas=[]) %}
{% for dev in area %}
{% for ent in area_entities(dev) %}
{% if is_device_attr(device_id(ent),'model','LZW31-SN') and ent.split('.')[0] == 'light' %}
{% set entities.areas = entities.areas + [ent | string] %}
{% endif %}
{% endfor %}
{% endfor %}
{{ entities.areas|lower }}
gives me this error TemplateError: str: Must provide a device or entity ID
which seems related to the errors I get from the script. If I switch
{% if 'LZW31-SN' == device_attr(device_id(ent),'model') and ent.split('.')[0] == 'light' %}
to:
{% if ent.split('.')[0] == 'light' and 'LZW31-SN' == device_attr(device_id(ent),'model') %}
it renders just fine in the template sandbox. This doesn’t work in the script, however, so maybe I’m way off track. I’ve tried removing the if
statement entirely and even replacing [ent | string]
with ['light.outside_rear_lights_level' | string ]
but I’m still getting the three errors at the top.
I’m not a programmer or expert of any kind, but if you type real slowly I’ll try to keep up. I’d be thankful for any guidance.