Automation not triggering, easy answer?

Hey Everyone,

I’m writing an automaton to send a notification when my cats use our litter robot. They each weigh different weights, so when the robot reports a cat’s weight, I know who it is. Here is a graph showing the three cat weight bands over the last few days:

The one extra-low 5lb weight is when a cat touches the robot with its paws, peeks in, and then goes away. I’ve written the trigger to only respond for weights between the focus range of 8<x<16.

My automaton goes like this:

alias: Kitchen Litter Robot User Message
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.litter_robot_4_pet_weight
    above: 8
    below: 16
condition: []
action:
  - if:
      - condition: numeric_state
        entity_id: sensor.litter_robot_4_pet_weight
        below: 11
    then:
      - service: notify.mobile_app_dad_s_phone
        data:
          title: Litter Robot User
          message: Chloe
        alias: Notify it's Chloe
    else:
      - if:
          - condition: numeric_state
            entity_id: sensor.litter_robot_4_pet_weight
            above: 13
        then:
          - service: notify.mobile_app_dad_s_phone
            data:
              title: Litter Robot User
              message: Tiarra
            alias: Notify it's Tiarra
        else:
          - service: notify.mobile_app_dad_s_phone
            data:
              message: Star
              title: Litter Robot User
            alias: Notify it's Star
mode: single

I’ve received measurements within the desired range, but the automation doesn’t trigger. What’s could be wrong with the trigger?

Thanks in advance for your help!!

1 Like

The only time it would trigger based on your graph is during this transition.

image

All other state changes will not trigger the automation.

How do I change the trigger to fire when it receives a value within the desired range?

Make it a state trigger, then use a condition to only fire the automation when the value is inside the range.

trigger:
  - platform: state
    entity_id: sensor.litter_robot_4_pet_weight
condition:
  - condition: numeric_state
    entity_id: sensor.litter_robot_4_pet_weight
    above: 8
    below: 16

Would I be correct in assuming that this entity isn’t returning a weight when there is no cat? Ideally, the entity would return 0 for that scenario or something, but in any case, if there is no value returned for the entity, then perhaps this feature request I created is narrower than it should be (unless your litter robot is also a Z-Wave device).

That having been said, regardless of what the chart shows, maybe you can work around this by using that trigger as a condition. For instance, if the device provides any other indication of presence, that could be the trigger (with a delay added via the “for” piece if necessary to get the correct weight reading) and the weight could be the condition. Alternatively, if you only have the weight, perhaps the entity reflects a state other than the number (like unavailable), in which case the trigger could be when that state changes from unavailable (or whatever means there is no weight detected).

Another thought, since I know nothing about your device, if the weight is always accurate and includes the litter, you could have multiple triggers, one for each cat, but you’d have to maintain them as the unoccupied weight changes. You could also use helpers and automations to deal with that.

That FR makes no sense with battery devices. Instead you can poll the zwave device after a specific period to see if it’s dead. It will show up as unavailable.

Otherwise, if we were to go ahead with that FR, your battery devices would go unavailable if they didn’t periodically check in at a rate that HA expects.

Hey,

@petro Awesome! I had the right concept but not in the right places. Thanks!!

@The00Dustin The Litter Robot only reports a value when a cat is detected. Having the Home Assistant trigger platform “state” looking at the specific pet weight entity essentially translates the trigger into, “If you receive any value at any time, run this automation”, which is exactly what I need it to do.

Thank you for your help!!

@petro we can take this dicussion to my request or elsewhere if that would be better and there is any value in continuing it after this post, but I wasn’t sure where to reply.

I see what you mean about battery devices in general (and this is, in fact, why Z-Wave doesn’t ever report battery devices as dead), however, what I just stated in parenthesis also mean that no, I can’t do what you suggest. The feature request also suggests the timeouts be adjustable with reasonable timeouts, so I’m not sure how it is’t already addressing the things you suggest don’t make sense.

In case someone is looking for the corrected automation, here it is:

alias: Kitchen Litter Robot User Message
description: ""
trigger:
  - platform: state
    entity_id: sensor.litter_robot_4_pet_weight
    alias: Litter Robot pet weight value is received
condition:
  - condition: numeric_state
    entity_id: sensor.litter_robot_4_pet_weight
    above: 8
    below: 16
action:
  - if:
      - condition: numeric_state
        entity_id: sensor.litter_robot_4_pet_weight
        below: 11
    then:
      - service: notify.mobile_app_dad_s_phone
        data:
          title: Litter Robot User
          message: Chloe
        alias: Notify it's Chloe
    else:
      - if:
          - condition: numeric_state
            entity_id: sensor.litter_robot_4_pet_weight
            above: 13
        then:
          - service: notify.mobile_app_dad_s_phone
            data:
              title: Litter Robot User
              message: Tiarra
            alias: Notify it's Tiarra
        else:
          - service: notify.mobile_app_dad_s_phone
            data:
              message: Star
              title: Litter Robot User
            alias: Notify it's Star
mode: single