Error executing script

I’m getting the following error in my logs and can’t put my finger on the problem. Can anyone point me in the right direction?

Error
Amps - check amp status: Error executing script. Unexpected error for call_service at pos 1: 400: message cannot be blank

Script

alias: Amps - check amp status
description: ''
trigger:
  - platform: time_pattern
    minutes: /50
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: switch.relay2
        state: 'on'
      - condition: and
        conditions:
          - condition: template
            value_template: >-
              {{ ((as_timestamp(now()) -
              as_timestamp(states.switch.relay2.last_changed)) / 60) | int > 120
              }}
      - condition: state
        entity_id: switch.relay1
        state: 'on'
      - condition: and
        conditions:
          - condition: template
            value_template: >-
              {{ ((as_timestamp(now()) -
              as_timestamp(states.switch.relay1.last_changed)) / 60) | int > 120
              }}
action:
  - service: notify.pushover1
    data:
      title: HA
      target: James-iPhone
      message: |
        {% if (states.switch.relay2.state == 'on') and ((as_timestamp(now()) -
              as_timestamp(states.switch.relay2.last_changed)) / 60) | int > 120 and 
              (states.switch.relay1.state == 'on') and ((as_timestamp(now()) - 
              as_timestamp(states.switch.relay1.last_changed)) / 60) | int > 120 %}
          Indoor and Outdoor Amps have been on for more than 2 Hours
        {% elif (states.switch.relay2.state == 'on') and ((as_timestamp(now()) -
              as_timestamp(states.switch.relay2.last_changed)) / 60) | int > 120 %}
          Indoor Amp (Amp2) has been on for more than 2 Hours
        {% elif (states.switch.relay1.state == 'on') and ((as_timestamp(now()) -
              as_timestamp(states.switch.relay1.last_changed)) / 60) | int > 120 %}
          Outdoor Amp (Amp1) has been on for more than 2 Hours
        {% endif %}
mode: single

Thanks!

I’ve been tinkering with this a bit more, and even though both of my amps are off, it seems that the automation is running the action anyway. Since none of the if conditions in my template are being met, it’s sending a blank message and producing the error.

The goal is to send a notification if either (or both) amps have been one for more than two hours. Any ideas on what’s wrong with my condition statements?

Why not dispose of the complicated conditions and inefficient time pattern trigger and just trigger like this:

trigger:
  - platform: state
    entity_id: switch.relay1
    state: 'on'
    for:
      hours: 2
  - platform: state
    entity_id: switch.relay2
    state: 'on'
    for:
      hours: 2
action:
  - service: notify.pushover1
    data:
      title: HA
      target: James-iPhone
      message: "{{ trigger.to_state.name has been on for 2 hours }}"

Thanks Tom … way better. What’s the best way to expand this to check every hour to see if an amp has been on for more than two hours?

You could use two alerts (one for each amp) instead of an automation.

Perfect … thanks Tom!