Hi all,
I’m using the code below to notify me when some of the devices go unavailable (happens every so often).
action: input_text.set_value
target:
entity_id: input_text.tts_text_en
data:
value: >-
Beware!
{% for state in states.switch|rejectattr('entity_id','contains','esp32') %}
{% if state.state == "unavailable" %}
Switch {{[state.name]}} is unavailable.
{% endif %}
{% endfor %}
{% for state in states.light|rejectattr('entity_id','contains','jastuk')|rejectattr('entity_id','contains','onkyo')|rejectattr('entity_id','contains','esp32') %}
{% if state.state == "unavailable" %}
Light {{[state.name]}} is unavailable.
{% endif %}
{% endfor %}
{% for state in states.binary_sensor|rejectattr('entity_id','contains','esp32') %}
{% if state.state == "unavailable" %}
Sensor {{[state.name]}} is unavailable.
{% endif %}
{% endfor %}
The problem is, as you can see below, the answer contains a lot of empty spaces and lines:
Light ESP32CAM-3D_A1 LED Light is unavailable.
Light Trigger ON-OFF is unavailable.
As I’m using it in input_text (for voice response) which has a limit of 256 characters, it generally does not work - the input text entity just remains blank.
Is there a simple way to remove all those empty lines? Or maybe a better solution that has the same output?
(I’m not good with programming, I just managed to put this together using given solutions from this and other forums)
Thanks in advance!