What are the trigger/action fields for specific device/entity?

Hi there,
I wonder if anyone could help with following dummy question about automation please:
Where can find what can be a trigger and an action for specific component and entity?
For example, if i want google home to say ‘Hello Alex’ when i come home, what should be the trigger for device_tracker and what can be an action for media_player.living_room_home?

Is there any resource available online explaining how it works?

Thanks,
Alex

Other than the documentation, there’s a list of examples.

In this case, you’d have something like:

automation:
  trigger:
    # https://home-assistant.io/docs/automation/trigger/
    platform: state
    entity_id: device_tracker.your_phone
    to: 'home'
  action:
    # https://home-assistant.io/docs/automation/action/
    service: tts.something
    date:
      message: "Hello Alex"
      entity_id: media_player.living_room_home

You’ll need to chose and configure a TTS platform, and update the above to use your actual entity for the device tracker, and the TTS platform of your choice.

Thanks a lot for this!
That’s really helpful.

But how should i go about when i need something else? For example, if i want to dim the lights when google chromecast starts casting or when it is casting something specific? Generally, where do i find specific fields that i can use in actions and triggers for a specific platform/entity like chrome cast, device_state, etc?

What i mean is that here in docs there is nothing about how to make chromecast to trigger something:

I assume im looking into a wrong place. But where should i look then?

Did you read the documentation links on triggers, and actions? It explains what the various platforms you can use are.

You don’t make the chromecast trigger anything. No device is responsible for triggering anything. What you do is define an automation, that says that when (say) media_player.chromecast goes from off to playing, with the condition that the state of lights.room are on, then you turn_on those lights with a brightness 50.

It sounds like you skipped the getting started guide, so I’d suggest you read that first, then read the automation section of the main documentation, and the examples section.

Hey Tinkerer,
really appreciate your help with this.
I tried to follow your advice and manuals and set this script in configuration.yaml:
automation:
trigger:
platform: state
entity_id: media_player.big_screen
to: ‘playing’
action:
service: tts.google_say
entity_id: media_player.living_room_home
data:
message: ‘Something is playing’

I expected google home to say: ‘Something is playing’ but it doesn’t.
I feel im realy close now to understanding how automation works in hass and would really appreciate if someone could have a look at the above script and point me to what is wrong with it please?

I should say log file is empty and hass launches fine, so i don’t have any syntax errors i think.

Cheers,
Alex

Well, if you format it correctly (see the big blue box at the top - select the text and push </> on the formatting bar) we might be able to help you.

Have you selected the automation in the HA control panel and pushed Trigger to check that the TTS works?

automation:
  trigger:
    # https://home-assistant.io/docs/automation/trigger/
    platform: state
    entity_id: media_player.big_screen
    to: 'playing'
  action:
    # https://home-assistant.io/docs/automation/action/
    service: tts.google_say
    entity_id: media_player.living_room_home
    data:
      message: 'Chromecast started playing'

If you manually trigger the automation, does it work?

yeah, i was about to write. How can i manually push this?
Do you mean that i need to create similar rule to what i have in configration.yml but in Hass UI?

Go to the control panel, find your automation, click on it, then push Trigger

Do you mean here? (btw thanks a lot for helping me with this!)

In the pics above, ‘Test’ is something that i’ve just created that is a copy of automation from configuration.yaml. But i don’t see any option to puh the trigger there…

looks like im looking in a wrong place. What do you mean by ‘control panel’?

Sorry, if you go to the top left you’ve got States. In there you’ll find all your automations, sensors, switches etc. If you click on the automation you’ll get a box showing when it last triggered, and the option to manually trigger it.

It looks like when i set automation in configuration.yaml it doesn’t work, but when i set it in UI (and it is saved in automation.yaml) it kind of works. I’ll need to experiment with this now.