How to prevent triggering automations at startup

Hi,

I have a couple of automations, f.e. notifications that are set to trigger when a certain state is reached or changed. F.e. when the shutters are changinging from open to closed, there should be a telegram message.

Now, all is woking fine, but every time I have to reboot HA for updates, these notifications are getting triggered.

Assuming that all entities are in an “unknown” state after reboot, they are then changing to a defined state. But why does this trigger then, when the trigger is set to the change between two distinctive values, i.e. CLOSED to OPEN or vice versa, but nor UNKNOWN to OPEN?

Did I missunderstand something here?

Thanks
Frank

No, you did not miss anything. That should not happen.

Check the automation trace to see what is going on.

Nothing special here. Unfortunately I cannot trace whats happening during boot.
Am I correct, that the entity / device is in state “unknown” after boot, until HA has fetched the actual state of these entities / devices?

Yes that is correct.

Specifying a from state (that is not “unknown”) should prevent that from triggering.

You should be able to see the trace fro the trigger after boot. Why cant you?

1 Like

Most possibly, because I don’t know where to look for :wink:
Where would I go to, so I can find that information please?

Included a link in my first reply to you.

Yes, I have seen this. But after reboot, the history shows only that the automation has been triggered. Which is why I am receiving a notification. Not sure what I would expect different in here?

When reloading the yaml files, the notification triggers and the result is attached

Can you download the full trace (three dots menu top right of that page) and paste it here please?

Also paste your automation config yaml. Correctly formatted for the forum.

Sure, here is the automation:

alias: Notify - Telegram Info Rolläden auf/zu
description: ""
trigger:
  - platform: state
    entity_id:
      - cover.rolladen_haus
    to: closed
    id: RLZU
    from: open
  - platform: state
    entity_id:
      - cover.rolladen_haus
    to: open
    id: RLAUF
    from: closed
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - RLZU
        sequence:
          - service: telegram_bot.send_message
            data:
              message: >-
                Rolläden Haus wurden um {{ now().strftime("%H:%M") }} Uhr
                geschlossen
              title: "Information: "
      - conditions:
          - condition: trigger
            id:
              - RLAUF
        sequence:
          - service: telegram_bot.send_message
            data:
              message: Rolläden Haus um {{ now().strftime("%H:%M") }} Uhr geöffnet
              title: "Information: "
mode: single

And this is the trace

{
  "trace": {
    "last_step": "action/0/choose/1/sequence/0",
    "run_id": "8221fb17ad7bcf10a7d2d60e91b8dbd0",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2023-12-05T19:57:07.623273+00:00",
      "finish": "2023-12-05T19:57:07.686006+00:00"
    },
    "domain": "automation",
    "item_id": "1677957988149",
    "trigger": "state of cover.rolladen_haus",
    "trace": {
      "trigger/1": [
        {
          "path": "trigger/1",
          "timestamp": "2023-12-05T19:57:07.623306+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.notify_telegram_info_rolladen_auf_zu",
              "state": "on",
              "attributes": {
                "id": "1677957988149",
                "last_triggered": "2023-12-05T19:51:39.855395+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Notify - Telegram Info Rolläden auf/zu"
              },
              "last_changed": "2023-12-05T19:44:32.668906+00:00",
              "last_updated": "2023-12-05T19:51:40.050449+00:00",
              "context": {
                "id": "01HGXRJG2FX7C7N36NB4H1BVA6",
                "parent_id": "01HGXRJG2CETAB7REHZ1NGJEH2",
                "user_id": null
              }
            },
            "trigger": {
              "id": "RLAUF",
              "idx": "1",
              "alias": null,
              "platform": "state",
              "entity_id": "cover.rolladen_haus",
              "from_state": {
                "entity_id": "cover.rolladen_haus",
                "state": "closed",
                "attributes": {
                  "current_position": 0,
                  "entity_id": [
                    "cover.rolladen_eg",
                    "cover.rolladen_og"
                  ],
                  "device_class": "shutter",
                  "friendly_name": "Rolläden Haus",
                  "supported_features": 15
                },
                "last_changed": "2023-12-05T19:57:07.364105+00:00",
                "last_updated": "2023-12-05T19:57:07.364105+00:00",
                "context": {
                  "id": "01HGXRWFX12XE32E9HBD71368C",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "cover.rolladen_haus",
                "state": "open",
                "attributes": {
                  "current_position": 1,
                  "entity_id": [
                    "cover.rolladen_eg",
                    "cover.rolladen_og"
                  ],
                  "device_class": "shutter",
                  "friendly_name": "Rolläden Haus",
                  "supported_features": 15
                },
                "last_changed": "2023-12-05T19:57:07.622708+00:00",
                "last_updated": "2023-12-05T19:57:07.622708+00:00",
                "context": {
                  "id": "01HGXRWG53J48J1W2417W26898",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of cover.rolladen_haus"
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2023-12-05T19:57:07.623913+00:00",
          "changed_variables": {
            "context": {
              "id": "01HGXRWG57KF9KMSSGEH5RZ5M5",
              "parent_id": "01HGXRWG53J48J1W2417W26898",
              "user_id": null
            }
          },
          "result": {
            "choice": 1
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2023-12-05T19:57:07.624377+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2023-12-05T19:57:07.624395+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/1": [
        {
          "path": "action/0/choose/1",
          "timestamp": "2023-12-05T19:57:07.624427+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/1/conditions/0": [
        {
          "path": "action/0/choose/1/conditions/0",
          "timestamp": "2023-12-05T19:57:07.624436+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/1/sequence/0": [
        {
          "path": "action/0/choose/1/sequence/0",
          "timestamp": "2023-12-05T19:57:07.624591+00:00",
          "result": {
            "params": {
              "domain": "telegram_bot",
              "service": "send_message",
              "service_data": {
                "message": "Rolläden Haus um 20:57 Uhr geöffnet",
                "title": "Information: "
              },
              "target": {}
            },
            "running_script": false
          }
        }
      ]
    },
    "config": {
      "id": "1677957988149",
      "alias": "Notify - Telegram Info Rolläden auf/zu",
      "description": "",
      "trigger": [
        {
          "platform": "state",
          "entity_id": [
            "cover.rolladen_haus"
          ],
          "to": "closed",
          "id": "RLZU",
          "from": "open"
        },
        {
          "platform": "state",
          "entity_id": [
            "cover.rolladen_haus"
          ],
          "to": "open",
          "id": "RLAUF",
          "from": "closed"
        }
      ],
      "condition": [],
      "action": [
        {
          "choose": [
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": [
                    "RLZU"
                  ]
                }
              ],
              "sequence": [
                {
                  "service": "telegram_bot.send_message",
                  "data": {
                    "message": "Rolläden Haus wurden um {{ now().strftime(\"%H:%M\") }} Uhr geschlossen",
                    "title": "Information: "
                  }
                }
              ]
            },
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": [
                    "RLAUF"
                  ]
                }
              ],
              "sequence": [
                {
                  "service": "telegram_bot.send_message",
                  "data": {
                    "message": "Rolläden Haus um {{ now().strftime(\"%H:%M\") }} Uhr geöffnet",
                    "title": "Information: "
                  }
                }
              ]
            }
          ]
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01HGXRWG57KF9KMSSGEH5RZ5M5",
      "parent_id": "01HGXRWG53J48J1W2417W26898",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Notify - Telegram Info Rolläden auf/zu",
      "message": "triggered by state of cover.rolladen_haus",
      "source": "state of cover.rolladen_haus",
      "entity_id": "automation.notify_telegram_info_rolladen_auf_zu",
      "context_id": "01HGXRWG57KF9KMSSGEH5RZ5M5",
      "when": 1701806227.623383,
      "domain": "automation"
    }
  ]
}

Cover cover.rolladen_haus changed from closed to open triggering your automation.

What integration is providing this entity?

At start up or reload that should not happen. It should change from unknown to open or closed.

Are there other automations that could be affecting the state of this entity?

The position also changed from 0 to 1.

These are KNX Entities
Correction: This specific entity is a group helper in HA. The shutters are KNX, but that cover.rolladen_haus is a helper.

Agreed, hence I don’t understand, how a reboot of HA can detect a change from CLOSED to OPEN, while the shutters are already open at that point in time.

The management of the shutters (so closing and opening) is entirely controlled on the KNX side. So HA is only showing the states or is used to manually control shutters if neccessary. No other automation is involved here if it comes to shutters.

Which leads me to the question, if maybe the KNX integration has kind of a preset status which might cause this ?
Edit2: Maybe the helper is OPEN on default after reboot, then collects the state of the KNX shutters and switches to CLOSED, which might explain why there is no “undefined” state detected…?

Can you sow the configuration of this?

Hm, not sure how to do this. No option to show the yaml code of the helper?
So there are several helpers:
Cover per Floor (cover_eg and cover_og), which derive their status from the KNX integration (so position_cover_wohnen, position_cover_kitchen, etc, you get the idea) and then are combined to cover.rolladen_haus.
Makes sense?

What sort of helper?

There is no cover helper. Is it a cover group?

Check the history of your individual covers and groups right after a restart (zoom in using the time controls in the history panel).

Sorry for not being specific enough. Yes, these are group helpers.
Will check the panels
Edit:

After a reboot, the three Helpers (First Floor = EG, Second Floor = OG)
look like this:



So to me it seems, that the state that has been read by the KNX integration is interpreted as a change after reboot. What I do not understand is, why the log stated “changed” and not “changed FROM state TO state”. This ignores the fact, that the automation should only trigger after the state has changed between two distinctive states, not just any change.

Edit 2:“wurde geöffnet” translates to “has been opened”, which was not the case. I just rebooted HA to see what would be in the log

Edit 3: On further inspection it seems, the state of the helper is being preserved during reboot? Does make even less sense then, as the state did not change then either.

No further ideas?

No sorry, I cant read that. Maybe try asking in the German forum, Home Assistant | heimnetz.de | Forum

I can translate.What is of particular interest for you?
Rolladen = Shutter
wurde geöffnet = has been opened
ausgelöst = triggered
Zustand = state
Rolländen OG wurde geöffnet ausgelöst durch Zustand von Büro Ost wurde geöffnet (quite bad grammar in German ;-)) = Shutters First Flor have been opened, triggert by state of Office East (a shutter) has been opened (bad grammar in english as well, lol)

What state would a Group helper have after a reboot? I would assume a “unknown” as well?