Automation is crashing

Can someone tell me why the automation is crashing?

{
  "trace": {
    "last_step": "action/0",
    "run_id": "c4e50fd317ace3c2c4f9f2c752a1607d",
    "state": "stopped",
    "script_execution": null,
    "timestamp": {
      "start": "2023-09-24T11:46:13.056973+00:00",
      "finish": "2023-09-24T11:46:13.058889+00:00"
    },
    "domain": "automation",
    "item_id": "1674394349151",
    "trigger": null,
    "trace": {
      "trigger": [
        {
          "path": "trigger",
          "timestamp": "2023-09-24T11:46:13.057033+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.robby_zuruck_basis_oder_ausleeren",
              "state": "on",
              "attributes": {
                "id": "1674394349151",
                "last_triggered": "2023-09-21T13:05:11.400313+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Robby - Zurück Basis oder ausleeren"
              },
              "last_changed": "2023-09-23T15:55:12.992086+00:00",
              "last_updated": "2023-09-23T15:55:12.992086+00:00",
              "context": {
                "id": "01HB1C12Q0ZG7C1SZ55DRRK207",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "platform": null
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2023-09-24T11:46:13.057401+00:00",
          "changed_variables": {
            "context": {
              "id": "01HB3G5VY0CWHR5BAH3Y2KDKMH",
              "parent_id": "01HB3DHRK87Z0QCEV4C5ST0MD1",
              "user_id": null
            }
          },
          "result": {
            "params": {
              "domain": "automation",
              "service": "turn_off",
              "service_data": {
                "stop_actions": true,
                "entity_id": [
                  "automation.robby_eg_alle_weg"
                ]
              },
              "target": {
                "entity_id": [
                  "automation.robby_eg_alle_weg"
                ]
              }
            },
            "running_script": false
          }
        }
      ]
    },
    "config": {
      "id": "1674394349151",
      "alias": "Robby - Zurück Basis oder ausleeren",
      "description": "",
      "trigger": [],
      "condition": [],
      "action": [
        {
          "service": "automation.turn_off",
          "data": {
            "stop_actions": true
          },
          "target": {
            "entity_id": [
              "automation.robby_eg_alle_weg"
            ]
          }
        },
        {
          "if": [
            {
              "condition": "state",
              "entity_id": "vacuum.valetudo_robby",
              "state": "cleaning"
            }
          ],
          "then": [
            {
              "service": "vacuum.return_to_base",
              "data": {},
              "target": {
                "entity_id": "vacuum.valetudo_robby"
              }
            }
          ]
        },
        {
          "if": [
            {
              "condition": "numeric_state",
              "entity_id": "sensor.valetudo_robby_current_statistics_area",
              "above": 100000
            }
          ],
          "then": [
            {
              "wait_for_trigger": [
                {
                  "platform": "numeric_state",
                  "entity_id": "vacuum.valetudo_robby",
                  "attribute": "battery_level",
                  "above": 50
                }
              ],
              "continue_on_timeout": false
            },
            {
              "if": [
                {
                  "condition": "state",
                  "entity_id": "vacuum.valetudo_robby",
                  "state": "returning"
                }
              ],
              "then": [
                {
                  "service": "vacuum.stop",
                  "data": {},
                  "target": {
                    "entity_id": "vacuum.valetudo_robby"
                  }
                }
              ]
            },
            {
              "service": "mqtt.publish",
              "data": {
                "topic": "homeassistant/robby/GoToLocationCapability/go/set",
                "payload": "{   \"coordinates\": {     \"x\": 2097,     \"y\": 3231   } }",
                "qos": "1"
              }
            },
            {
              "service": "notify.matrix_haus_xyz",
              "data": {
                "message": "Robby ist fertig mit saugen, bitte Behälter ausleeren!"
              }
            }
          ],
          "else": [
            {
              "service": "vacuum.return_to_base",
              "data": {},
              "target": {
                "entity_id": "vacuum.valetudo_robby"
              }
            }
          ]
        },
        {
          "service": "automation.turn_on",
          "data": {},
          "target": {
            "entity_id": "automation.robby_eg_alle_weg"
          }
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01HB3G5VY0CWHR5BAH3Y2KDKMH",
      "parent_id": "01HB3DHRK87Z0QCEV4C5ST0MD1",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Robby - Zurück Basis oder ausleeren",
      "message": "triggered",
      "source": null,
      "entity_id": "automation.robby_zuruck_basis_oder_ausleeren",
      "context_id": "01HB3G5VY0CWHR5BAH3Y2KDKMH",
      "when": 1695555973.057111,
      "domain": "automation"
    },
    {
      "when": 1695555973.059298,
      "state": "off",
      "entity_id": "automation.robby_eg_alle_weg",
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "Robby - Zurück Basis oder ausleeren",
      "context_message": "triggered",
      "context_entity_id": "automation.robby_zuruck_basis_oder_ausleeren"
    }
  ]
}

No, since there you have not provided an error code or a link to the actual code.

Please read this over again and try again.

This is the code:

alias: Robby - Zurück Basis oder ausleeren
description: ""
trigger: []
condition: []
action:
  - service: automation.turn_off
    data:
      stop_actions: true
    target:
      entity_id:
        - automation.robby_eg_alle_weg
  - if:
      - condition: state
        entity_id: vacuum.valetudo_robby
        state: cleaning
    then:
      - service: vacuum.return_to_base
        data: {}
        target:
          entity_id: vacuum.valetudo_robby
  - if:
      - condition: numeric_state
        entity_id: sensor.valetudo_robby_current_statistics_area
        above: 100000
    then:
      - wait_for_trigger:
          - platform: numeric_state
            entity_id: vacuum.valetudo_robby
            attribute: battery_level
            above: 50
        continue_on_timeout: false
      - if:
          - condition: state
            entity_id: vacuum.valetudo_robby
            state: returning
        then:
          - service: vacuum.stop
            data: {}
            target:
              entity_id: vacuum.valetudo_robby
      - service: mqtt.publish
        data:
          topic: homeassistant/robby/GoToLocationCapability/go/set
          payload: "{   \"coordinates\": {     \"x\": 2097,     \"y\": 3231   } }"
          qos: "1"
      - service: notify.matrix_haus_xyz
        data:
          message: Robby ist fertig mit saugen, bitte Behälter ausleeren!
    else:
      - service: vacuum.return_to_base
        data: {}
        target:
          entity_id: vacuum.valetudo_robby
  - service: automation.turn_on
    data: {}
    target:
      entity_id: automation.robby_eg_alle_weg
mode: single

Docker
Home Assistant 2023.9.3

1, There is no trigger
2, You can’t have 2 if’s at the same level. This needs to be restructured into a choose statement.

  1. It’s triggered by other automations.
  2. Deleted one of the If’s and will test if it works.

An automation will not work without a trigger. At all.

Maybe you are thinking about a script, That’s a different thing.That can be called from Automations.

I suggest you do a bit more reading of the HA docs. There are a few fundamentals that you need to understand.

1 Like

I think about avoiding double code maintenance.
The automation was working for months without triggers.

What do you meant with script?
I want to use the HA gui and not some text editor to maintain it…

I have several automations without triggers that get triggered by other automations. It works.

description: ""
trigger: []
condition: []
action:
  - service: climate.set_temperature
    data:
      entity_id: climate.loftstue
      temperature: "{{ states.climate.loftstue.attributes.temperature - 2 }}"

Executed: September 30, 2023 at 18:00:00

Result:
params:
  domain: climate
  service: set_temperature
  service_data:
    entity_id: climate.loftstue
    temperature: -2
  target: {}
running_script: false

Then you are running something completely different than me when I run HA, and I am not going to be able to help you.
Also I have not seen anything to do with blueprints, only some form of automations, and this is the blueprint topic. Perhaps remove the blueprint tag in the topic and try in another topic.

(BTW, scripts also have a gui editor.)

1 Like

It might work but it is not best practice.

If you want to use a sequence of actions in seperate automations, call a script.

Can you make the script within HA?

Which is an anti-pattern. That’s jargon for a “bad practice”.

It’s only a “good practice” if the goal is to create the software equivalent of a Rube Goldberg machine.

(Heath Robinson for those in the UK)

crashed again:

alias: Robby - Zurück Basis oder ausleeren
description: ""
trigger: []
condition: []
action:
  - service: automation.turn_off
    data:
      stop_actions: true
    target:
      entity_id:
        - automation.robby_eg_alle_weg
  - if:
      - condition: numeric_state
        entity_id: sensor.valetudo_robby_current_statistics_area
        above: 100000
    then:
      - if:
          - condition: numeric_state
            entity_id: vacuum.valetudo_robby
            attribute: battery_level
            below: 50
        then:
          - service: vacuum.return_to_base
            data: {}
            target:
              entity_id: vacuum.valetudo_robby
          - wait_for_trigger:
              - platform: numeric_state
                entity_id: vacuum.valetudo_robby
                attribute: battery_level
                above: 49
            continue_on_timeout: false
      - if:
          - condition: or
            conditions:
              - condition: state
                entity_id: vacuum.valetudo_robby
                state: returning
              - condition: state
                entity_id: vacuum.valetudo_robby
                state: cleaning
        then:
          - service: vacuum.stop
            data: {}
            target:
              entity_id: vacuum.valetudo_robby
        enabled: true
      - service: mqtt.publish
        data:
          topic: homeassistant/robby/GoToLocationCapability/go/set
          payload: "{   \"coordinates\": {     \"x\": 2097,     \"y\": 3231   } }"
          qos: "1"
      - service: notify.matrix_haus_xyz
        data:
          message: Robby ist fertig mit saugen, bitte Behälter ausleeren!
    else:
      - service: vacuum.return_to_base
        data: {}
        target:
          entity_id: vacuum.valetudo_robby
  - service: automation.turn_on
    data: {}
    target:
      entity_id: automation.robby_eg_alle_weg
mode: single

Yes:

1 Like

thanks, transformed it into a script and will test if this change anything (i doubt it)

Same Problem with it as a script:


Shall I open another Thread because it’s now a script?

No, post your script here.

Also, it might be helpful if you just post the whole trace json which is available for download by clicking the three-dot menu at the top right if the trace tool.

1 Like
alias: Robby - Zurück Basis oder ausleeren
sequence:
  - service: automation.turn_off
    data:
      stop_actions: true
    target:
      entity_id:
        - automation.robby_eg_alle_weg
        - automation.robby_heinrich_ist_wach
  - if:
      - condition: numeric_state
        entity_id: sensor.valetudo_robby_current_statistics_area
        above: 100000
    then:
      - if:
          - condition: numeric_state
            entity_id: vacuum.valetudo_robby
            attribute: battery_level
            below: 50
        then:
          - service: vacuum.return_to_base
            data: {}
            target:
              entity_id: vacuum.valetudo_robby
          - wait_for_trigger:
              - platform: numeric_state
                entity_id: vacuum.valetudo_robby
                attribute: battery_level
                above: 49
            continue_on_timeout: false
      - if:
          - condition: or
            conditions:
              - condition: state
                entity_id: vacuum.valetudo_robby
                state: returning
              - condition: state
                entity_id: vacuum.valetudo_robby
                state: cleaning
        then:
          - service: vacuum.stop
            data: {}
            target:
              entity_id: vacuum.valetudo_robby
        enabled: true
      - service: mqtt.publish
        data:
          topic: homeassistant/robby/GoToLocationCapability/go/set
          payload: "{   \"coordinates\": {     \"x\": 2097,     \"y\": 3231   } }"
          qos: "1"
      - service: notify.matrix_haus_xyz
        data:
          message: Robby ist fertig mit saugen, bitte Behälter ausleeren!
    else:
      - service: vacuum.return_to_base
        data: {}
        target:
          entity_id: vacuum.valetudo_robby
  - service: automation.turn_on
    data: {}
    target:
      entity_id:
        - automation.robby_eg_alle_weg
        - automation.robby_heinrich_ist_wach
mode: single
{
  "trace": {
    "last_step": "sequence/0",
    "run_id": "94b57e7eeb2dc407f426ae646b8db30e",
    "state": "stopped",
    "script_execution": null,
    "timestamp": {
      "start": "2023-10-03T08:49:11.647884+00:00",
      "finish": "2023-10-03T08:49:11.650366+00:00"
    },
    "domain": "script",
    "item_id": "robby_zuruck_basis_oder_ausleeren",
    "trace": {
      "sequence/0": [
        {
          "path": "sequence/0",
          "timestamp": "2023-10-03T08:49:11.648299+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "script.robby_zuruck_basis_oder_ausleeren",
              "state": "off",
              "attributes": {
                "last_triggered": "2023-10-02T18:42:11.444165+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Robby - Zurück Basis oder ausleeren"
              },
              "last_changed": "2023-10-02T18:42:11.479004+00:00",
              "last_updated": "2023-10-02T18:42:11.479004+00:00",
              "context": {
                "id": "01HBRTG16CZ00BSDVC74H95G53",
                "parent_id": "01HBRTG165D4WEXY3GKXBNKE29",
                "user_id": null
              }
            },
            "context": {
              "id": "01HBT8FX0YE81M4PGTBWDA6VKM",
              "parent_id": "01HBT8FX0VH17C0WTWRW3FNVS7",
              "user_id": null
            }
          },
          "result": {
            "params": {
              "domain": "automation",
              "service": "turn_off",
              "service_data": {
                "stop_actions": true,
                "entity_id": [
                  "automation.robby_eg_alle_weg",
                  "automation.robby_heinrich_ist_wach"
                ]
              },
              "target": {
                "entity_id": [
                  "automation.robby_eg_alle_weg",
                  "automation.robby_heinrich_ist_wach"
                ]
              }
            },
            "running_script": false
          }
        }
      ]
    },
    "config": {
      "alias": "Robby - Zurück Basis oder ausleeren",
      "sequence": [
        {
          "service": "automation.turn_off",
          "data": {
            "stop_actions": true
          },
          "target": {
            "entity_id": [
              "automation.robby_eg_alle_weg",
              "automation.robby_heinrich_ist_wach"
            ]
          }
        },
        {
          "if": [
            {
              "condition": "numeric_state",
              "entity_id": "sensor.valetudo_robby_current_statistics_area",
              "above": 100000
            }
          ],
          "then": [
            {
              "if": [
                {
                  "condition": "numeric_state",
                  "entity_id": "vacuum.valetudo_robby",
                  "attribute": "battery_level",
                  "below": 50
                }
              ],
              "then": [
                {
                  "service": "vacuum.return_to_base",
                  "data": {},
                  "target": {
                    "entity_id": "vacuum.valetudo_robby"
                  }
                },
                {
                  "wait_for_trigger": [
                    {
                      "platform": "numeric_state",
                      "entity_id": "vacuum.valetudo_robby",
                      "attribute": "battery_level",
                      "above": 49
                    }
                  ],
                  "continue_on_timeout": false
                }
              ]
            },
            {
              "if": [
                {
                  "condition": "or",
                  "conditions": [
                    {
                      "condition": "state",
                      "entity_id": "vacuum.valetudo_robby",
                      "state": "returning"
                    },
                    {
                      "condition": "state",
                      "entity_id": "vacuum.valetudo_robby",
                      "state": "cleaning"
                    }
                  ]
                }
              ],
              "then": [
                {
                  "service": "vacuum.stop",
                  "data": {},
                  "target": {
                    "entity_id": "vacuum.valetudo_robby"
                  }
                }
              ],
              "enabled": true
            },
            {
              "service": "mqtt.publish",
              "data": {
                "topic": "homeassistant/robby/GoToLocationCapability/go/set",
                "payload": "{   \"coordinates\": {     \"x\": 2097,     \"y\": 3231   } }",
                "qos": "1"
              }
            },
            {
              "service": "notify.matrix_haus_xyz",
              "data": {
                "message": "Robby ist fertig mit saugen, bitte Behälter ausleeren!"
              }
            }
          ],
          "else": [
            {
              "service": "vacuum.return_to_base",
              "data": {},
              "target": {
                "entity_id": "vacuum.valetudo_robby"
              }
            }
          ]
        },
        {
          "service": "automation.turn_on",
          "data": {},
          "target": {
            "entity_id": [
              "automation.robby_eg_alle_weg",
              "automation.robby_heinrich_ist_wach"
            ]
          }
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01HBT8FX0YE81M4PGTBWDA6VKM",
      "parent_id": "01HBT8FX0VH17C0WTWRW3FNVS7",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "when": 1696322951.648054,
      "state": "on",
      "entity_id": "script.robby_zuruck_basis_oder_ausleeren"
    },
    {
      "when": 1696322951.649406,
      "state": "off",
      "entity_id": "automation.robby_heinrich_ist_wach",
      "context_state": "on",
      "context_entity_id": "script.robby_zuruck_basis_oder_ausleeren"
    },
    {
      "when": 1696322951.650278,
      "state": "off",
      "entity_id": "script.robby_zuruck_basis_oder_ausleeren",
      "context_state": "on",
      "context_entity_id": "script.robby_zuruck_basis_oder_ausleeren"
    },
    {
      "when": 1696322951.650742,
      "state": "off",
      "entity_id": "automation.robby_eg_alle_weg",
      "context_state": "on",
      "context_entity_id": "script.robby_zuruck_basis_oder_ausleeren"
    }
  ]
}

any idea? happens every execution =(