hi taras
I am trying to adapt the following code to my automation.
I have 2 problems.
if i simply paste your code to the developers tools - template
I got the following
TemplateRuntimeError: No test named 'eqon'.
I am not sure that this is a problem.
but when I try to change the bianary sensors with mine
like this
message: >
{% set fenster = [
states.binary_sensor.8_erker_tzami,
states.binary_10_ypnodomatia_tzami,
states.binary_5_trapezaria_tzami,
states.binary_sensor.13_mpanio_wc ]
| selectattr('state', 'eq' 'on')
| map(attribute='name') | list %}
{% set qty = fenster | count %}
{% if qty == 0 %}
Everything is closed.
{% else %}
Please close the following window{{ 's' if qty > 1 else ''}}: {{ fenster | join(', ') }}
{% endif %}
Yes, now the first problem is eliminated. If I paste your code i get “Everything is closed.”
but
in the same code if I try to replace the first sensor with a mine one
like this
message: >
{% set fenster = [
states.binary_sensor.10_ypnodomatia_tzami,
the binary sensor name is 10_ypnodomatia_tzami
is there any chance that HA template can’t work with this kind of naming in the binary sensors (if they have a number for example?)
my 4 sensors names are
binary_sensor.10_ypnodomatia_tzami,
binary_sensor.5_trapezaria_tzami,
binary_sensor.13_mpanio_wc
binary_sensor.8_erker_tzami
I’m struggling with the templating here; I put all the window sensors into a group, but I can’t get the automation to parse. I get the error: Error rendering data template: TypeError: argument of type ‘NoneType’ is not iterable
Can anyone suggest what is wrong and how to fix it?
alias: Status Automation
description: ""
trigger:
- platform: state
entity_id:
- input_boolean.status
from: "off"
to: "on"
condition: []
action:
- service: notify.alexa_media_bedroom
data:
message: >-
{% set open_windows = states | selectattr('entity_id','in', state_attr('group.windows','entity_id')) | selectattr('state','eq','on') | map(attribute='name') | list %}
{% if open_windows | length == 0 %}
All windows are closed.
{% elif open_windows | length == 1 %}
There is a window open in the {{ open_windows | join('') }}.
{% else %}
There are windows open in the {{ open_windows[:-1] | join(', ') }}{{',' if open_windows | length > 2 else ''}} and {{ open_windows[-1]}}.
{% endif %}
mode: single
You are right! I put the window sensors in a group, but the group is showing as binary_sensor.windows. I will just change the name to binary_sensor.windows and see if that helps.
I have the following script working as a notification
alias: "Windows open notification 2 "
sequence:
- service: notify.mobile_app_imrans_pixel
data_template:
message: >
{{ states | selectattr('entity_id','in', state_attr('group.windows','entity_id')) | selectattr('state','eq','on') | map(attribute='name') | join(', ') }}
title: "Window still open: "
data:
priority: 1
mode: single
icon: mdi:window-open-variant
Can anyone help to get this working as tts. I have tried the following but I just get a voice saying null. If I change the string to simple text then it works.
Can anyone help me finish this off. So far Alexa announces the specific windows that are open (great!), but I would like her to finish the very end of the sentence with “is open”. At the moment she says, Dining Room Window, Living Room Window etc (depending which window is open). But it would be great if I could get her to say “[entity name] is open”