Trigger an event then an alert based on power usage sonoff pow2

Hi All
I have a Sonoff pow2 connected to my soak away pump. I had an issue last year with a blockage which burnt out the pump as it was running 24/7 for I dont know how long. Id like to set the following
if running for > 15 mins at a time or

10 times a day

turn off the power to the pump and notify

notifications id like are email or an alexa message that can be played when home. I dont see the need for a push notifcation because if im not home there isnt anything to worry about till i do get home etc.

Thanks

What im struggling with is how to create the event based on power usage to make an entity that its running etc

The first part is a simple state trigger:

trigger:
  platform: state
  entity_id: switch.your_pump
  to: 'on'
  for:
    minutes: 15
action:
  service: switch.turn_off
  entity_id: switch.your_pump

The count is probably best done with a history stats sensor and a numeric state trigger:

superb many thanks ill give that a try

Just looking into that and it appears

trigger:
  platform: state
  entity_id: switch.your_pump
  to: 'on'
  for:
    minutes: 15
action:
  service: switch.turn_off
  entity_id: switch.your_pump

is based on the switch status, but that is always on else the pump cant run. What i need is to turn a status switch to show the pump is running if there is more than 200 watts being drawn?

Use a numeric state trigger then:

Thanks Tom
Ive found a page similar to what i want to do, which to start with is get the fact its running or not as a switch
I found this
Monitoring your Sump Pump with Home Assistant (brentsaltzman.com)

```
sensor sumppumpstate:  
  - platform: template
    sensors:
      sumppumpstate:
        value_template: '{% if 
            is_state("binary_sensor.ecolink_door_sensor_9_0", "off") %}
            Running
            {% else %}
            In Standby
            {% endif %}'
        friendly_name: 'Emergency Sump Pump'
```

and tried modifying to

sensor sumppumpstate:  
  - platform: template
    # unique_id: 10010321e9
    sensors:
      # unique_id: 10010321e9
      sumppumpstate:
        value_template: '{% if 
            is_state("sensor.sonoff_1000cd83d9_power") | float > 100 %}
            Running
            {% else %}
            In Standby
            {% endif %}'
        friendly_name: 'Soak Away Pump Status'
        unique_id: 10010321e9

However its showing as unavailable

i have updated the config and have found this is close to working

sensor sumppumpstate:  
  - platform: template
    sensors:
      sumppumpstate:
        value_template: '{% if 
            is_state("sensor.sonoff_1000cd83d9_power", "0.0")  %}
            In Standby
            {% else %}
            Running
            {% endif %}'
        friendly_name: 'Soak Away Pump Status'

However i cant work out how to get it use the value of greater than, ie > 300 watts. It reports the value in developer tools.
Im assuming its the ‘is_state’ as im assuming thats a string value, i need to read the integer so i can check if its greater than less than etc.

Many Thanks

Try, e.g.

states('sensor.sonoff_1000cd83d9_power') | float > 300

Absolutly ####### fantastic Thankyou

This is the code I have now working perfectly

sensor sumppumpstate:  
  - platform: template
    sensors:
      sumppumpstate:
        value_template: '{% if 
            states("sensor.sonoff_1000cd83d9_power") | float < 300 %}
            In Standby
            {% else %}
            Running
            {% endif %}'
        friendly_name: 'Soak Away Pump Status'