So i’ve tried to get this to work, but i’m having issues with using IF statement in my data template.
So i want a summary of the air quality sensor i poll, so if it’s < 50 “air quality is good” < 100 “air quality is ok” ETC.
I’m not sure if i’m suppose to double {{ the sensor or if that just to pass it tts.
script below.
air:
alias: 'Air Quality'
sequence:
- service: tts.google_say
data_template:
entity_id: media_player.living_room
message: >
{% if {{states.sensor.waqi_sutton__beddington_lane_north_united_kingdom.state}}|int < 50 %}
Air Quality is good.
{% elif {{states.sensor.waqi_sutton__beddington_lane_north_united_kingdom.state}}|int < 100 %}
Air Quality is moderate.
{% elif {{states.sensor.waqi_sutton__beddington_lane_north_united_kingdom.state}}|int < 150 %}
Air Quality is bad.
{% elif {{states.sensor.waqi_sutton__beddington_lane_north_united_kingdom.state}}|int > 149 %}
Your all going to die down here.
{% else %}
Not quite sure what happened here.
{% endif %}
This should do it. You didn’t need the double brackets before and after the sensors.
{% if states.sensor.waqi_sutton__beddington_lane_north_united_kingdom.state | int < 50 %}
Air Quality is good.
{% elif states.sensor.waqi_sutton__beddington_lane_north_united_kingdom.state | int < 100 %}
Air Quality is moderate.
{% elif states.sensor.waqi_sutton__beddington_lane_north_united_kingdom.state | int < 150 %}
Air Quality is bad.
{% elif states.sensor.waqi_sutton__beddington_lane_north_united_kingdom.state | int >= 150 %}
Your all going to die down here.
{% else %}
Not quite sure what happened here.
{% endif %}
It could, would that be best ?
I’ve got one that says time to day greeting, then weather, drive to work time if mon-fri, i suspect i could move that to an automation.
I just click the button in HA to run that script at the moment (moving soon, so will make it do other things)
Yes, using my SONOS as a speaker, but if i every get round to it will setup my MyCroft AI, and see if i can use that to trigger and pipe out the audio