Script and Automation

So i am trying to get this automation to work but i am struggling. My google home announces it the first time but I can’t get it to repeat with the second script. Am i missing something?

- alias: "Auto Turn Off Water Alert Switch"
  trigger:
    - platform: numeric_state
      entity_id: sensor.water_heater_water_sensor_flood
      below: 2
      
    - platform: numeric_state
      entity_id: sensor.sump_pump_water_sensor_flood
      below: 2
      
    - platform: numeric_state
      entity_id: sensor.laundry_room_water_sensor_flood
      below: 2
      
  action:
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.water_alert

- alias: "Alert - Water Heater"
  trigger: 
    - platform: numeric_state
      entity_id: sensor.water_heater_water_sensor_flood
      above: 1

  action: 
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.water_alert
        
    - service: notify.GrangerHome
      data:
        title: Water Heater Alert
        message: Your Water Heater is leaking in the basement
        data:
          priority: 2
          timestamp: true
          retry: 30
          expire: 43200

    - delay: 00:00:03

    - service: script.turn_on
      entity_id: script.water_alert_tts

- alias: "Alert - Sump Pump"
  trigger:
    - platform: numeric_state
      entity_id: sensor.sump_pump_water_sensor_flood
      above: 1

  action:
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.water_alert
        
    - service: notify.GrangerHome
      data:
        title: Sump Pump Alert
        message: Your Sump Pump is broken in the basement
        data:
          priority: 2
          timestamp: true
          retry: 30
          expire: 43200

    - delay: 00:00:03

    - service: script.turn_on
      entity_id: script.water_alert_tts
    
- alias: "Alert - Laundry Room"
  trigger:
    - platform: numeric_state
      entity_id: sensor.laundry_room_water_sensor_flood
      above: 1

  action:
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.water_alert
        
    - service: notify.GrangerHome
      data:
        title: Laundry Room Alert
        message: There is water in the laundry room
        data:
          priority: 2
          timestamp: true
          retry: 30
          expire: 43200

    - delay: 00:00:03

    - service: script.turn_on
      entity_id: script.water_alert_tts

1st script:

alias: Water Alert TTS
    sequence:
      - service: tts.google_say
        entity_id: media_player.living_room_home
        data_template:
          message: >
            {% if state.(sensor.water_heater_water_sensor_flood) | float > 1 %}
              Your basement has water in it.  Go check it out now
            {% elif state.(sensor.sump_pump_water_sensor_flood) | float > 1 %}
              Your Sump Pump is broken in the basement
            {% elif state.(sensor.laundry_room_water_sensor_flood) | float > 1 %}
              Your laundry room has water in it.  Go check it out now
            {% else %}
              Something water sensor has tripped but I cannot pinpoint where.
            {% endif %}
        
      - service: script.turn_on
        entity_id: script.loop_water_alert

2nd Script

alias: Loop Water Alert TTS
    sequence:
      - delay:
            # Delay for voice 
            seconds: 5
          
      - condition: state
        entity_id: input_boolean.water_alert
        state: 'on'
            
      - service: script.turn_on
        entity_id: script.water_alert_tts

Maybe Entity_id for script 2 is wrong in script 1:

entity_id: script.loop_water_alert_tts

Kr
J

Your spacing is way out on both scripts too, looks like you have four spaces at the start of the lines instead of two.

So I got a little closer. There was some things wrong in that first post. I guess I have been trying too many things. It appears that it will run the automation ok but never goes into the script to run.

- alias: "Auto Turn Off Water Alert Switch"
  trigger:
    - platform: numeric_state
      entity_id: sensor.water_heater_water_sensor_flood
      below: 2
      
    - platform: numeric_state
      entity_id: sensor.sump_pump_water_sensor_flood
      below: 2
      
    - platform: numeric_state
      entity_id: sensor.laundry_room_water_sensor_flood
      below: 2
      
  action:
    - service: input_boolean.turn_off
      data:
        entity_id: input_boolean.water_alert

- alias: "Alert - Water Heater"
  trigger: 
    - platform: numeric_state
      entity_id: sensor.water_heater_water_sensor_flood
      above: 1

  action: 
    - service: notify.GrangerHome
      data:
        title: Water Heater Alert
        message: Your Water Heater is leaking in the basement
        data:
          priority: 2
          timestamp: true
          retry: 30
          expire: 43200

- alias: "Alert - Sump Pump"
  trigger:
    - platform: numeric_state
      entity_id: sensor.sump_pump_water_sensor_flood
      above: 1

  action:
    - service: notify.GrangerHome
      data:
        title: Sump Pump Alert
        message: Your Sump Pump is broken in the basement
        data:
          priority: 2
          timestamp: true
          retry: 30
          expire: 43200

    
- alias: "Alert - Laundry Room"
  trigger:
    - platform: numeric_state
      entity_id: sensor.laundry_room_water_sensor_flood
      above: 1

  action:
    - service: notify.GrangerHome
      data:
        title: Laundry Room Alert
        message: There is water in the laundry room
        data:
          priority: 2
          timestamp: true
          retry: 30
          expire: 43200

- alias: "Alert - Water Sensor Tripped"
  trigger:
    - platform: numeric_state
      entity_id: sensor.water_heater_water_sensor_flood
      above: 1

    - platform: numeric_state
      entity_id: sensor.sump_pump_water_sensor_flood
      above: 1

    - platform: numeric_state
      entity_id: sensor.laundry_room_water_sensor_flood
      above: 1
 
    - platform: state
      entity_id: input_boolean.water_alert
      to: 'on'

  action:
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.water_alert
    
    - service: media_player.turn_on
      entity_id: media_player.living_room_home

    - service: media_player.volume_set
      entity_id: media_player.living_room_home
      data:
        volume_level: 0.65

    - service: script.turn_on
      entity_id: script.water_alert_tts

1st Script:

alias: Water Alert TTS
sequence:
  - service: tts.google_say
    entity_id: media_player.living_room_home
    data_template:
      message: >
        {% if state.(sensor.water_heater_water_sensor_flood) | float > 1 %}
          Your basement has water in it.  Go check it out now
        {% elif state.(sensor.sump_pump_water_sensor_flood) | float > 1 %}
          Your Sump Pump is broken in the basement
        {% elif state.(sensor.laundry_room_water_sensor_flood) | float > 1 %}
          Your laundry room has water in it.  Go check it out now
        {% else %}
          Something water sensor has tripped but I cannot pinpoint where.
        {% endif %}
    
  - service: script.turn_on
    entity_id: script.loop_water_alert

2nd Script

alias: Loop Water Alert
sequence:
  - delay:
        # Delay for voice 
        seconds: 5
      
  - condition: state
    entity_id: input_boolean.water_alert
    state: 'on'
        
  - service: script.turn_on
    entity_id: script.water_alert_tts

Any ideas on this?

I would do…

  - service: script.water_alert_tts

and 
  - service: script.loop_water_alert
  - service: script.water_alert_tts

I’m not sure it will make much difference tho’ as I think you can use both ways, however you might have to format it differently…

  - service: script.turn_on
    data:
      entity_id: script.loop_water_alert

So i tried it all three of these ways and none of them work. I must be missing something. I know it is executing the automation because I can hear the google home beep.

I couldn’t get your data template to work in dev tools, however if it’s like this it works…

        {% if states.sensor.bedmaxtemp.state | float > 1 %}
          Your basement has water in it.  Go check it out now
        {% elif states.sensor.bedmintemp.state | float > 1 %}
          Your Sump Pump is broken in the basement
        {% else %}
          Something water sensor has tripped but I cannot pinpoint where.
        {% endif %}

Obviously I’ve used my own sensors :stuck_out_tongue:

As for the scripts, mine work either way that I posted, however I don’t think you can mix and match. I think if you use script.turn_on you need the data part and if you use the service call directly you don’t add enitity_id below it.