Hi out there
I have a script that looks like this
{%- for state in states.binary_sensor
|selectattr('attributes.device_class', 'defined')
|selectattr('attributes.device_class', '==', 'lock') -%}
{% if state.state == 'off' %}
{% set ns.sensors = ns.sensors + [dict(name = state.name | replace(', dag/nat', '') | replace(', status', ''), state =state.state)] %}
{% endif %}
{%- endfor -%}
{%- set door = ns.sensors | sort(attribute='state') %}
{%- set ns = namespace(door='') -%}
{%- for state in door -%}
{% set ns.door= ns.door + (state.name ~ ' (' ~ state.state ~')' ~ "\n") %}
{%- endfor -%}```
Running it in Template, it return exactly what I am looking for.
But:
Intregrate it into configuration.yaml
``` - name: "Døre nat status"
icon: >
mdi:door-closed-lock
state: >
{%- set ns = namespace(sensors=[]) -%}
{%- for state in states.binary_sensor
|selectattr('attributes.device_class', 'defined')
|selectattr('attributes.device_class', '==', 'lock') -%}
{% if state.state == '0' %}
{% set ns.sensors = ns.sensors + [dict(name = state.name | replace(', dag/nat', '') | replace(', status', ''), state =state.state)] %}
{% endif %}
{%- endfor -%}
{%- set door = ns.sensors | sort(attribute='state') %}
{%- set ns = namespace(door='') -%}
{%- for state in door -%}
{% set ns.door= ns.door + (state.name ~ ' (' ~ state.state ~')' ~ "\n") %}
{%- endfor -%}```
gives the following error:
```2023-01-05 11:52:32.466 WARNING (MainThread) [xknx.log] Can not process <Telegram direction="Incoming" source_address="1.5.82" destination_address="11/5/22" payload="<GroupValueResponse value="<DPTBinary value="42" />" />" /> for Udestue, dør vest, dag/nat, status - State: <CouldNotParseTelegram description="payload invalid" device_name="Udestue, dør vest, dag/nat, status" feature_name="State" payload="<DPTBinary value="42" />"/>```
Any one who has an idea??
It is a binary_sensor fra KNX that is shown as ON/OFF in HA, but it is send out as a 0/1
I even tried to change it to int and to 0, just to see if the error goes away, under the idea, that maybe in configuration.yaml, it sees it as numer and not character
Any ideas appriciated
Marinus