Trying to get an automation to run

Background: I have used SmartThings and have been using Hubitat for quite a few years.

Have recently started dabbling with HA.

I am trying to setup an automation/rule so that when my Litter Robot gets a status code interruption and after 10 minute it turns off a switch.

The rule doesn’t seem to be running when this happens.

But if I click on run actions manually it works.

I’ve attached a screen shot of my automation.

The When statement may not be correct, but not really sure.

We need to see the yaml of that automation posted inside a code block </>.
And also from developer tools on that sensor when it has that specified error code.
It could be that the error code has a beautified state in the frontend, but what you actually need is something different

1 Like

Whole new learning curve… :slight_smile:

alias: New automation
description: “”
triggers:

  • trigger: state
    entity_id:
    • sensor.penny_litter_3_status_code
      conditions:
  • condition: trigger
    id: “”
  • condition: state
    entity_id: sensor.penny_litter_3_status_code
    state: csi
    for:
    hours: 0
    minutes: 10
    seconds: 0
    actions:
  • action: switch.turn_off
    metadata: {}
    data: {}
    target:
    device_id: c7dc841f37b0c4b7e8711f64930987e1
    mode: single

Status code is CSI

You didn’t press the code block button so the code is very hard to read.
But the issue is obvious for us that has used HA for a while.

Triggers trigger immediately, then it reads the condition and if that fails then everything fails untill the trigger triggers again.
It will NOT wait for a condition to be true.

So with that in mind we see that your trigger will work but fail every time on the condition since the state can’t just have turned to something new but also been csi for 10 minutes.

You need to remove the condition and make the trigger trigger on to: csi and then for: 10 minutes.

I can’t help you with correcting the code since it is not in a code block, if I copy it then it will contain characters that makes it not possible to copy back in to HA.
But I hope my explanation was good enough

1 Like

This might be closer to what you want to achieve. It is what Hellis81 suggested.

alias: New automation
description: ""
triggers:
  - trigger: state
    entity_id: sensor.penny_litter_3_status_code
    to: 'csi'
    for:
      minutes: 10
conditions: []
actions:
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      device_id: c7dc841f37b0c4b7e8711f64930987e1
mode: single

The automation uses a State Trigger to monitor the state of sensor.penny_litter_3_status_code. It’s looking for the sensor’s state to change to csi from any other value and then maintain it for at least 10 minutes. Then, and only then, it will trigger the automation.

It’s important to keep in mind that a State Trigger detects changes in an entity’s state value. The example I posted is looking for the sensor’s state to change from some other value to csi.

That’s to be expected because it only executes the automation’s actions, it doesn’t test the automation’s triggers and conditions.

Reference

Troubleshooting your automation

1 Like

Thanks everyone for your information.

I was trying to start if When the device, instead of the entity which is why I ended up creating a When, And if and a then do statement.

Working great now.

So glad I figured this out. Now I don’t have to tell Alexa to reset the KittyLitter outlet to power cycle the Litter Robot.

Love my LR3, but this was a design flaw. And thank god for warranties. I have about 3 bases that had the same problem (cat sensor interrupt) until I figured out if I power off the unit and turn it back on that it would finish the cycle.