ok is there any other way to test it without my wife and i leaving the house ?
Run the automation from Developer Tools > Services like this:
What’s important is to add:
skip_condition: false
you are the KING!!! masive thanks
Thanks. I know that friendly_name would fix it but I also use it sending sms through email2sms service and polish letter like ą,ś,ć etc. are problematic. Open windows integration is used by Google home są in this case polish letters are good to go.
Hey guys,
I’m trying to do something similar, but my syntax is complete rubbish lol. How would I do an AND OR
What I’m looking for is
If state of balcony door AND bedroom window is set to open, then say: please close both of them
If its only one OR the other, address them individually.
This is what ive got, but its very wrong lol
service: notify.alexa_media
data_template:
target:
- media_player.bedroom_echo_show
- media_player.bathroom
- media_player.kitchen
data:
type: announce
message: {{% if is_state('binary_sensor.balcony_door_contact', 'open') and if is_state('binary_sensor.bedroom_window_contact', 'open') %} Please close the balcony door and bedroom window? {%- else -%} {% if is_state('binary_sensor.bedroom_window_contact', 'open')Please close the bedroom window} {%- else -%}{{% if is_state('binary_sensor.balcony_door_contact', 'open')Please close the Balcony Door}{% endif %}
You can make your life easier by spreading the template out over several lines.
service: notify.alexa_media
data_template:
target:
- media_player.bedroom_echo_show
- media_player.bathroom
- media_player.kitchen
data:
type: announce
message: >
{% set door = is_state('binary_sensor.balcony_door_contact', 'open') %}
{% set window = is_state('binary_sensor.bedroom_window_contact', 'open') %}
{% if door and window %} Please close the balcony door and bedroom window?
{% elif window %} Please close the bedroom window.
{% elif door %} Please close the balcony door.
{% else %} Everything is closed.
{% endif %}
I totally missed this, sorry lol
I’m been on about three other threads trying to work this out for days now HAHA!
This is the closest i’ve been, it kinda almost works! Thank you even for that
But its not quite right for some reason that I cant see
alias: Close Doors
sequence:
- service: notify.alexa_media
data_template:
target:
- media_player.bedroom_echo_show
- media_player.bathroom
- media_player.kitchen
data:
type: announce
message: >
{% set door = is_state('binary_sensor.balcony_door_contact', 'open') %}
{% set window = is_state('binary_sensor.bedroom_window_contact', 'open') %}
{% if door and window %} Please close the balcony door and bedroom window?
{% elif window %} Please close the bedroom window.
{% elif door %} Please close the balcony door.
{% else %} Everything is closed.
{% endif %}
It just tells me that everything is closed (both the window and door are open as I execute it)
If I check the template, I get this.
Mate, thank you again!
alias: Close Doors
sequence:
- service: notify.alexa_media
data_template:
target:
- media_player.bedroom_echo_show
- media_player.bathroom
- media_player.kitchen
data:
type: announce
message: >
Everything is closed.
The real state of a binary sensor should be “on” or “off”:
It’s unlikely that the binary_sensor’s state is open
(although I have seen one rare case that was due to an error in a custom integration) and should be on
(as mentioned by dennis84de). Try this corrected version:
service: notify.alexa_media
data_template:
target:
- media_player.bedroom_echo_show
- media_player.bathroom
- media_player.kitchen
data:
type: announce
message: >
{% set door = is_state('binary_sensor.balcony_door_contact', 'on') %}
{% set window = is_state('binary_sensor.bedroom_window_contact', 'on') %}
{% if door and window %} Please close the balcony door and bedroom window?
{% elif window %} Please close the bedroom window.
{% elif door %} Please close the balcony door.
{% else %} Everything is closed.
{% endif %}
You sir are a fing champion!!! HAHA
When I look at the sensor info it says open… I assumed, should have checked the entity ID.
Thank you so much, this has been frying my brain for days LOL
Hi 123
I want add sensor name and state are changed on dorr or window
When I add the first part before blank It will not send the message.
Do you have a idé about what’s wrong, is there any documentations?
service: notify.mobile_app_skynet_mobile
data:
title: dorr window
message: “{{ name(“entity”) }} blank has been {{ states(“entity”) }}”
There’s lots of documentation. I suggest you review this section: Templating
This template has many errors:
message: "{{ name("entity") }} blank has been {{ states("entity") }}"
- If you use double-quotes outside of the template, you must use single-quotes inside the template (or vice-versa). You can’t use the same quotes inside and outside of the template.
- There is no
name()
function so I don’t know where you got that from. - This part
"entity"
means it is simply the wordentity
and nothing else. Passing the word"entity"
to thestates()
function is invalid and accomplishes nothing.
Based on just the example you posted, I don’t know where it is used (automation or a script?) or which entities it is attempting to use. Please explain how you intend to use it.
Its in a automation that my doors and windows changes state are the triggers and the notification is the action
Post it and please format it correctly. The previous example you posted was unformatted and makes it difficult to determine if it has syntax errors (like incorrect indentation).
alias: notification windows and dorr
description: ‘’
trigger:
- platform: state
entity_id: switch.mqtt_front_dorr - platform: state
entity_id: switch.garage_door - platform: state
entity_id: binary_sensor.tv_dorr_temp - platform: state
entity_id: switch.cinema_left_dorr - platform: state
entity_id: binary_sensor.living_right_door - platform: state
entity_id: binary_sensor.livingroom_left_dorr - platform: state
entity_id: binary_sensor.kitchen_right_window
condition: []
action: - service: notify.mobile_app_skynet_mobile
data:
title: dorr window
message: ‘{{ name(“entity”) }}blank has been {{ states(“entity”) }}’
mode: single
That’s not a properly formatted automation but at least I can now see how you intend to use the notification.
message: "{{ trigger.to_state.name }} is now {{ 'open' if trigger.to_state.state == 'on' else 'closed' }}"
I’ve been trying to add some more sensors to your code today, but if I try adding it to the automation, HA gives me an
"Message malformed: invalid template (TemplateSyntaxError: Encountered unknown tag ‘elif’.) for dictionary value @ data[‘action’][0][‘data’]"
error.
I’d be very greatful for anyone to help me.
Here is my code:
service: tts.google_translate_say
data:
entity_id: media_player.kinderzimmer_display
message: >
{% set e_schlafzimmer = is_state('binary_sensor.fensterkontakt_e_schlafzimmer', 'on') %}
{% set kinderz = is_state('binary_sensor.fensterkontakt_kinderz', 'on') %}
{% set kuche = is_state('binary_sensor.fensterkontakt_kuche', 'on') %}
{% set wc = is_state('binary_sensor.fensterkontakt_wc', 'on') %}
{% set wozimmer_links = is_state('binary_sensor.fensterkontakt_wozimmer_links', 'on') %}
{% set wozimmer_rechts = is_state('binary_sensor.fensterkontakt_wozimmer_rechts', 'on') %}
{% elif e_schlafzimmer %} Please close the schlafzimmer window.
{% elif kinderz %} Please close the kinderzimmer window.
{% elif kuche %} Please close the kueche window.
{% elif wc %} Please close the wc window.
{% elif wozimmer_links %} Please close the wohnzimmer links window.
{% elif wozimmer_rechts %} Please close the wohnzimmer rechts window.
{% else %} Everything is closed.
{% endif %}
You are using a chain of if-elif-elif-elif-else statements but you forgot to make the first one if
.
Change this:
{% elif e_schlafzimmer %} Please close the schlafzimmer window.
to this:
{% if e_schlafzimmer %} Please close the schlafzimmer window.
EDIT
If you wish, you can have all the open windows reported in a single sentence.
service: tts.google_translate_say
data:
entity_id: media_player.kinderzimmer_display
message: >
{% set fenster = [
states.binary_sensor.fensterkontakt_e_schlafzimmer,
states.binary_sensor.fensterkontakt_kinderz,
states.binary_sensor.fensterkontakt_kuche,
states.binary_sensor.fensterkontakt_wc,
states.binary_sensor.fensterkontakt_wozimmer_links,
states.binary_sensor.fensterkontakt_wozimmer_rechts ]
| 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 %}
EDIT
Correction. Added missing comma.
Thank you so much! It workes flawlessly now!