Novice / Dumb Question

I have the HASS up running bunch of stuff configured, and ready to take on the next challenges, and have a knowledge gap.

Reading the documentation, I come to a halt around items like this;

Google TTS

I get the configurations in the configuration.yaml, and follow the logic of this;

service: tts.google_translate_say
entity_id: "all"
data:
  message: 'May the Force be with you.'

what I do not understand is where that would go? Meaning, lets say I want the above code to be triggered when “binary_sensor.i_o_linc_15_e4_70_sensor” transitions from open to closed.

is this an automation? I assume so,

Trigger is the sensor, with a state change of ‘open’ to ‘close’
then, use the above code as a ‘call service’???

In general, the knowledge gap is when I see code examples like the above, where do you put them. Answering the specific example, or pointing me to a URL would help,

Thank You in advance

An automation would be correct based your description. In your example, a basic automation would be:

- id: whatever you want
  trigger: 
    - platform: state
      entity_id: binary_sensor.i_o_linc_15_e4_70_sensor
      from: 'on'
      to: 'off'
  action: 
    - service: tts.google_translate_say
      entity_id: "all"
      data:
        message: 'May the Force be with you.'

If you are using a binary sensor, the state will be on/off (not open/closed) unless you put it in a template.

1 Like

Thank You - where would that code go? configuration.yaml?

most likely for your set up in automations.yaml. That file would be in same folder as your configuration.yaml

1 Like

Yes, but no.

Your configuration.yaml file should have a line like this in it by default:

automation: !include automations.yaml

So any automation configuration actually goes in your automations.yaml file.

If for some reason your configuration.yaml file does not have that line, or if you want to put everything in one big file, you can validly put your automations under

automation:
  <here>

in your configuration.yaml file.

See:

1 Like