Automation help needed on switch

Hello all…
Could someone help out for an automation
On a (shelly) or any (button) switch?
For now I made 2 automations
With tts.google_translate_say
The first says: Fountain is on
Second say: Fountain is off
Question is …
Can this be made in just 1 Automation?
And pls provide example?
Thnx!

If you post the 2 automations you want to combine then I am sure someone will provide what you need.

1 Like

Ok Rossk…ty!
Let’s try this then
Script 1

alias: Fontein aan
description: ""
trigger:
  - platform: device
    type: turned_on
    device_id: 149b9d6cdea56582735880d7a8a58aa4
    entity_id: ec85af3e05f8d66feda97c449146533e
    domain: light
condition: []
action:
  - service: tts.google_translate_say
    data:
      cache: false
      entity_id: media_player.nestmini2308
      message: "De Fontein is nu aangezet "
      language: nl
mode: single

Then the second one to turn it off

alias: Fontein uit
description: ""
trigger:
  - platform: device
    type: turned_off
    device_id: 149b9d6cdea56582735880d7a8a58aa4
    entity_id: ec85af3e05f8d66feda97c449146533e
    domain: light
condition: []
action:
  - service: tts.google_translate_say
    data:
      cache: false
      entity_id: media_player.nestmini2308
      message: "De Fontein is nu uitgezet "
      language: nl
mode: single

I hoped this could be merged
Or changed in just 1 Automation…
Thnx…

You can use trigger IDs to know what triggered your automation.

description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - light.ec85af3e05f8d66feda97c449146533e
    from: "off"
    to: "on"
    id: Turned on
  - platform: state
    entity_id:
      - light.ec85af3e05f8d66feda97c449146533e
    from: "on"
    to: "off"
    id: Turned off
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Turned on
        sequence:
          - service: tts.google_translate_say
            data:
              language: nl
              message: De Fontein is nu aangezet
              entity_id: media_player.office_echo_dot
              cache: false
      - conditions:
          - condition: trigger
            id:
              - Turned off
        sequence:
          - service: tts.google_translate_say
            data:
              language: nl
              message: De Fontein is nu uitgezet
              entity_id: media_player.office_echo_dot
              cache: false
1 Like

Thank You mekaneck!!!
This worked fine…
Your help is appreciated!

Good that you got help!

Please take the time to mark the answer as solution, you do that by selecting the three dots under the post:

image

Then select the check box:

image

This can be useful to other users as well and prevents that someone else steps in to try to help you.

1 Like

if i could find that buton i would, but it’s not shown anywhere!
only got share … flag… edit…bookmark…delete…post admin actions…

Hi, so you don’t get the ‘solution’ box?!?

1 Like

Now I have!!!
Wonder why this never showed up…
Thank you people!!

1 Like

Shorter version using templates:

trigger:
  - platform: state
    entity_id: light.ec85af3e05f8d66feda97c449146533e
    from:
      - "off"
      - "on"
    to:
      - "on"
      - "off"
action:
  - service: tts.google_translate_say
    data:
      language: nl
      message: De Fontein is nu {{ "aan" if trigger.to_state.state == "on" else "uit"}}gezet
      entity_id: media_player.office_echo_dot
      cache: false

If the light is reliably on or off and not unavailable or unknown, you can remove the to: and from: sections also.

1 Like

Also thnx to Troon!
Short as possible and effective…
Kuddo’s