home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.04k stars 31.07k forks source link

Zone state change not triggering automation #127095

Open Toxicable opened 1 month ago

Toxicable commented 1 month ago

The problem

I've been trying to configure a notification when I leave home. I'm using the companion app on my iphone to provide updates. Which has both an internal and external url configured, along with all update sources enabled The updates are being logged in logbook but they are not triggering the automation. image

On top of that, History shows that the zone is still Home even though logbook showed a zone change detected image

I can force the automation to trigger by setting my gps coordinates on my iphone in the debug console, but when I set the state it does not trigger the automation.

There's a bit more detail in the Home Assistant discord thread I opened

What version of Home Assistant Core has the issue?

core-2024.9.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

alias: leave home test
description: ""
trigger:
  - platform: zone
    entity_id: person.fabian
    zone: zone.home
    event: leave
condition: []
action:
  - device_id: ...
    domain: mobile_app
    type: notify
    message: test
    title: fabian left
mode: single

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 month ago

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (automation) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `automation` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign automation` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


automation documentation automation source (message by IssueLinks)

gjohansson-ST commented 1 month ago

On your automation select yaml mode and then copy it and paste here in a code-block 👍

Toxicable commented 1 month ago

@gjohansson-ST Ah yeah, here's that automation:

alias: leave home test
description: ""
trigger:
  - platform: zone
    entity_id: person.fabian
    zone: zone.home
    event: leave
condition: []
action:
  - device_id: ...
    domain: mobile_app
    type: notify
    message: test
    title: fabian left
mode: single

Also I have the track device setup here

image
dhoeben commented 1 month ago

Your automation action is not correct. Try this:

alias: leave home test
description: ""
trigger:
  - platform: zone
    entity_id: person.fabian
    zone: zone.home
    event: leave
condition: []
action:
  - action: notify.fabian
    data:
      title: "Fabian left"
      message: "test"
mode: single

If you are using this automation to see run automations based on if your house is empty or not, I recommend adding more triggers, just because phones don't always update that quick imho.

This is my trigger for presence home:

trigger:
  - platform: zone
    entity_id:
    - person.a
    - person.b
    zone: zone.home
    event: enter
  - platform: state
    entity_id: zone.home
    from: '0'

And this for presence away:

 trigger:
  - platform: state
    entity_id: zone.home
    to: '0'
Toxicable commented 1 month ago

Your automation action is not correct.

@dhoeben This was configured via the UI, so the yaml is generated. I verified this by triggering the notification, which has been successful so I don't think the issue is in the action.

If you are using this automation to see run automations based on if your house is empty or not

The end goal is just for when the one person leaves home, it's not relevant for others

dhoeben commented 1 month ago

Still it does not correspondent to the docs. https://www.home-assistant.io/integrations/notify/

Might be worth trying as the rest looks correct.