Need a way to detect change of power pattern for pool robot when it gets stuck

I have a pool robot that gets stuck on the stairs sometimes and I’d like to either power it off or receive a notification so that I can give it a nudge as quickly as possible to get it working again.
The good news is, when looking at the power pattern it’s easy to detect - for me as a human, that is.

From the image below it’s easy to see that the robot got stuck at around 10:21, and as soon as it did, it desperately tried to ‘free itself’ by franticly moving back and forth - without success. It just stayed in the same spot until the 2h of cleaning time ran out.

I already added a statistics sensor that looks at the average power usage over the last 5 minutes, but it doesn’t seem to be the right way to look at this because the value is not really outside the ordinary, it’s just more consistent at the top end of the normal values.

Anybody got an idea on how to tackle this?

What you want is the inverse of a missing pulse detector. I don’t know how I would do it in an automation, but I could in Node Red.
Basically, every pulse above 125W would restart a timer. The timeout on the timer would be 2X the period between the pulses when the sweeper is stuck. In normal operation that timer would be off most of the time. If it is stuck then the timer would be true most of the time. So if it’s true for 3X or 4X of the timeout period, then the sweeper is stuck.

If you do figure it out in an automation, please share it.

Edit.
If you average the power over a few minutes, it will be higher if the sweeper is stuck.

The way I’d do this is to count the number of times the power usage goes over 120-something within a 5 minute interval. If more than x times (experimentally determined, 6 could be a starting point), then the thingy is stuck.

No clue how to do this with a HA automation or with Jinja. But with something like pyscript it’s trivial.

Thanks for the suggestions - it would probably easier to check if the value drops below 25W; looks like when the robot is stuck, it doesn’t do that at all.
This might result in a numeric trigger with an above 25 value - still, finding the right ‘for’ value might be a challenge.

Statistics sensor could also work.
I believe the power consumption is slightly higher on average when it’s stuck.

I believe there is some value at least in the statistics sensor that is useful

Thanks, tried the 5min average but couldn’t find a value which would trigger reliably without too many fans positives.

Oh… I see now you wrote that.
Ok different tactic. Binary sensor turns on at 120. Then we use history stats sensor to count how often that occurs.

template:
  - trigger:
      - platform: numeric_state
        entity_id: sensor.sensor
        above: 120
    binary_sensor:
      - name: "more than 120 w"
        state: "{{ on }}"

I’m not at all sure this will work. But I hope it will.

Then set up a history stats counter on this binary sensor.

sensor:
  - platform: history_stats
    name: "count more than 120 w"
    entity_id: binary_sensor.more_than_120_w
    state: "on"
    type: count
    start: "{{ now() - timedelta(minutes = 5) }}"
    end: "{{ now() }}"

Thanks - this might lead to a quicker discovery than the ‘below 25W’ approach.
I’ve set it up and will keep an eye on it - might take a while, though, because sometimes the PoolBot runs a week without getting stuck :astonished:

Just set up the template sensor (had to change state: "{{ on }}" to state: 'on' for it to work) but once it got above 120W and the binary_sensor changed its state, it didn’t go back to ‘off’ - so I guess I either need another template sensor to turn it back off.
Unless there’s a way to get an ‘else’ into the existing one to turn it back off once the power consumption falls below 120W.
This also means, of course, that the counter got stuck at 1and never increased or decreased again.

I’d be grateful for some further hints.

Hmm… that was surprising.

Perhaps if we use a template trigger

{{ states('sensor.sensor') | int >= 120 }} 

This should return true or false.
Perhaps the template sensor should be a sensor and not binary.
That way it should toggle back and forth.

So…

sensor:
  - platform: template
    sensors:
      above_120_w:
        value_template: "{{ states('sensor.sensor') | int >= 120 }}"

and this needs to be feed to the history stats sensor.

Keep in mind this will probably return string true/false, so you might need to use "True"

Did a little re-jiggering, but this seems to work now:

- platform: template
  sensors:
    poolbot_exceeds_120w:
      friendly_name: Poolbot Exceeds 120W
      value_template: "{{ states('sensor.sonoff_power') | int >= 120 }}"


- platform: history_stats
  name: "PoolBot Count Exceeeds 120W"
  entity_id: sensor.poolbot_exceeds_120w
  state: "True"
  type: count
  end: "{{ now() }}"
  duration:
    minutes: 5

Thanks for your help, @Hellis81

1 Like