Hi
I am trying to make an automation for google home and I am stuck a little in a template
- id: Morning Report
alias: Morning Report
trigger:
platform: state
entity_id: binary_sensor.3_radar_saloni
to: 'on'
condition:
condition: time
after: '05:00:00'
before: '11:00:00'
action:
- service: media_player.volume_set
data_template:
entity_id: media_player.living_room_speaker
volume_level: 0.4
- service: tts.google_translate_say
entity_id: media_player.living_room_speaker
data_template:
message: >
The weather for today is {{states.sensor.dark_sky_summary.state}}
{% if states.sensor.outdoor_temperature.state|int > 70 %}
High Humidity today at {{states.outdoor_temperature.state}
{% endif %}
{% if states.sensor.wind_speed_ss_90_m4.state|int > 15 %}
Be advised it is windy outside.
{% endif %}
Home temperature is {{states.sensor.living_room_temperature_2.state}
Bath temperature is {{states.sensor.bath_temp_2.state}
{% if states.sensor.temperature_purifier.state|int > 40 %}
There is available hot water for bath
{% endif %}
- delay:
seconds: 30
- service: media_player.volume_set
data_template:
entity_id: media_player.living_room_speaker
volume_level: 0.3
I can not find out whats wrong with it. (poor knowledge for sure)
Can someone explain?
Put the message part of your code into Developer Tools -> Templates and you’ll see the problem with your code. Your missing a lot of these } in your code, you start with two {{ but only have one } at the end.
I also recommend to use this notation states('sensor.xxx') instead of states.sensor.xxx for more invormation about this, take a look at the docs here.
I’d try something like this, I’m not sure whether you need some else statements as well:
data_template:
message: >-
The weather for today is {{ states('sensor.dark_sky_summary') }}
{% if states('sensor.outdoor_temperature') | int > 70 %}
High Humidity today at {{ states('sensor.outdoor_temperature') }}
{% endif %}
{% if states('sensor.wind_speed_ss_90_m4') | int > 15 %}
Be advised it is windy outside.
{% endif %}
Home temperature is {{ states('sensor.living_room_temperature_2') }}
Bath temperature is {{ states('sensor.bath_temp_2') }}
{% if states('sensor.temperature_purifier') | int > 40 %}
There is available hot water for bath
{% endif %}
Also in your first if statement, you probably want to check the humidity sensor and not the temperature sensor?
He’s been on that thread already, he didn’t read it he just asked.
The are are means of extracting ‘words’ to be spoken but I think he just wants an answer.
Sorry, but you are a little unfair with me here.
I did try several times and as I see I was close to solution at least for the second part of the formula (but probably never found it by myself)
I read this thread also, so I had many tries like the following
but I always changed the second part with timestamp. I didn’t realize something that seems obvious/logical now (to add timestamp in first part too) , and that’s why the result I was getting was always the same.
I am not a programmer or something like that and I really don’t know any kind of coding language.
Most of my coding is from other members of the forum and by this I am learning but up to a point. There are many times where I am reading a part of a code and I really don’t understand anything especially if it is the first time I am dealing with it, like this time. I never used a template with “ifs” which even now it seems very difficult to me. (most of this code I took it from here