Hi,
I’m fairly new in HA and automation and would like ask question to my automation and here my code. My end results would be like that Google mini would say once that sauna is ready.
which trigger type would be good for me: State or Numeric State and are condition requirement / usefully?
alias: Sauna TTS
description: ''
trigger:
- platform: state
entity_id: sensor.sauna_temperature
attribute: temperature
from: '50'
to: '60'
condition:
- condition: numeric_state
entity_id: sensor.sauna_temperature
attribute: temperature
above: '50'
action:
- service: tts.google_translate_say
data_template:
entity_id: media_player.olohuone_mini
message: Sauna is warm. Temperature is {{ states('sensor.sauna_temperature')
}} degrees.
mode: single
EDIT:
Seems that my automation do not work. Sauna’s temperature is over 50 which is requirement for automation trigger but at least my google mini has not said anything. By pressing manually “Run Action” it will work and say the temperature value
EDIT2: Actually got it working by changing code a bit but now it keeps triggering every few minutes because saunas temperature is over 50 (even if turned off it can stay hours above 50) and don’t want or need more than one time information about this.
alias: Sauna TTS
description: ''
trigger:
- platform: state
entity_id: sensor.sauna_temperature
condition:
- condition: numeric_state
entity_id: sensor.sauna_temperature
above: '50'
action:
- service: tts.google_translate_say
data_template:
entity_id: media_player.olohuone_mini
message: >-
Sauna is warm. Temperature is {{ states('sensor.sauna_temperature') }}
degrees.
mode: single
When do you want it to trigger and how many times?
It’s not clear exactly what you want to happen.
Do you want it to speak when above 50 only once?
In that case you need to know that it has run once, and that metric is not in your automation currently.
You could have a boolean that goes on when the TTS has been said, and this is a condition in your automation.
Then when the temperature goes below 40 again another automation resets the boolean so that the TTS automation can trigger again.
Your using the state change of the temp sensor to trigger the automation, so basically every time the temp change state the automation will trigger over and over again all the time it is above 50deg as per your condition.
As others have said you really need to have the state above 50 as the trigger, that way you don’t need to have the condition and it will only ever trigger on the transition crossing the 50 deg upwards.
So going from 49-51 would trigger but any subsequent change above 50 would not trigger it until it drops below 50 and rises again.
It will only trigger when it transitions from below 50 to above 50, so unless it drops below 59 and then back up again then it should only trigger once
In that case I would use trigger above 50 and and use the input boolean to make sure it won’t trigger again because opening the door temporary cooled the sensor.