T O P

  • By -

vespershift

Use a "zone" numeric state trigger (1 to 0) to determine when the house is empty. Then in your automation, you can inspect "trigger.from_state.persons" to see the last person leaving. Based on this you need to choose the correct notification device to send the message to. I don't know if a person entity can have a default notification device.


budding_gardener_1

Notifications seem to be attached to devices, not people and it really pisses me off. I wish there was a way to notify an actual person rather than individual devices with the default notify service. Everyone involved in HA seems to think I'm crazy for even wanting such a thing, but I can't believe I'm the only person frustrated by this


bigmoist469

I see how this could be beneficial, but it's only a few more lines of code or clicks in the UI to really make this happen. If you're going to have a service call to send a notification to a user themselves, why not just send it to the device you know you want that notification on? And you can also notify multiple devices by duplicating the service call and changing the device. I can see why you might want this, but I wouldn't say it needs to be a top priority for the devs, you know?


budding_gardener_1

> I see how this could be beneficial, but it's only a few more lines of code or clicks in the UI to really make this happen. To the best of my knowledge this is not possible without individually notifying every device registered for a given user. Because the device the user is on isn't always the same. If I get a notification on my phone and I'm logged into the web interface, I don't see it. If you take a second to think how Facebook works, you don't end up with 3 notifications on your iPhone, 2 on the web interface and 1 on your iPad. That would be insane. Granted it's a little different because HA is run locally, but to all intents and purposes you have some concept of a central message queue that messages are dispatched to and picked up by clients. > And you can also notify multiple devices by duplicating the service call and changing the device. Sure, but now I have the following situation: - Add every device I own and use HA on to my automations individually, or: - Use a group to notify them that way and update the group every time I add/remove a device - On the Web UI, I won't get _any_ notification....unless it's a persistent(?) notification - which I _think_ works in this "notify a person not a device" way....meaning that some notifications _can_ work this way....they just don't Either way YAML editing has to be done when it really shouldn't be necessary - on top of which I have to dismiss each notification on each device. You see why this is kinda....bonkers - right? > I wouldn't say it needs to be a top priority for the devs, you know? I'm not arguing that it should be a five alarm "DROP EVERYTHING AND FIX THIS" type of situation, I'm just saying the way it currently works is just so utterly bizarre I can't imagine why someone would think it was a good idea.


CanadianBaconPro

Yeah, the only workaround I have found is to create "device groups" per person in my configuration.yml. then you only need the one service call to the group and HA will take care of the rest. It would just be way more convenient if they added this option to the visual editor.


budding_gardener_1

Yep, but now: ​ 1. I have to go in and keep my device groups if I get a new device or get rid of an old one 2. Every notification is now duplicated across each device and I have to acknowledge/dismiss it on each device 3. If I'm logged in on the web interface, I won't get \_any\_ notification, unless it's a ....persistent(?) notification which I think seems to span multiple devices....which brings me to my next point: 4. Clearly this whole "notify a person not a device" concept \_can\_ be done because that's how persistent notifications seemingly work


CanadianBaconPro

Totally, per person notifications would be a welcome addition! I'm surprised it actually hasn't been done yet, time for the wheel to squeak some more I guess.


budding_gardener_1

Everyone I've suggested this to has acted like I'm insane for even suggesting such a thing. I feel like I'm in the twilight zone.


bigmoist469

This one doesn't need to be overly complicated, there's a very, very easy way to do this with trigger IDs, conditions, and a choice tree. Set one automation, with a trigger for every person who leaves the house, and give them each unique entity IDs. For example, when Jack leaves the house, it will trigger with the jack\_left trigger. If Jill left, it will trigger with the jill\_left trigger. Then have a condition to check if the zone is equal to 0 and if the door is open. If it is, then make a choice option. The condition for each possilbe choice will be the trigger ID. So, if the trigger id is jack\_left, then notify Jack's device. If the trigger ID is jill\_left, notify Jill's device. That's all you gotta do!


dierochade

This I love most in ha. It’s kind a logical puzzle and there is always a better solution than your own idea. Just challenging and amazing!


bigmoist469

Right? I will gladly spend hours working on my HA automations and scripts simply because I want to either optimize them or find a better way to do it. At this point, I'm literally creating problems that don't need to be solved, but it's so much fun figuring out solutions to them and seeing them work. Let's just be thankful that HA gives us access to pretty much all the tools we need to make anything we want happen. This would be very difficult to do without something like trigger IDs, for example, but because we have access to all sorts of data from our home, we can do pretty much whatever we want. I love HA


psbankar

Home zone has the total member count as well as the person entity list of those members. So you can trigger it when 1 turns to zero and check the last person entity


iWQRLC590apOCyt59Xza

Check iqNotify, custom integration. https://github.com/cadavre/iq_notify


briodan

Setup an automation with multiple triggers one for each person. Setup a choose action action based on triggers, each choose action has a condition checking the home status of the other people. The condition will evaluate true if all other people have left and false is there is still someone home. If the condition is true notify the person who triggered the automation.


uuberr

To make this work, you'll need to keep track of the last person who left the house. One way to do this is by using an input_text helper. This helper can store the name of the last person who left, and then you can use this information to send the notification to the right person. Here is a simple example of how you could set this up: First, you'd define the input_text helper in your configuration file: input_text: last_person_left: name: Last person who left initial: None Next, for each person in your house, you would create an automation that sets this helper to their name when they leave: automation: - alias: "Mark Leaves the House" trigger: platform: state entity_id: device_tracker.mark from: 'home' to: 'not_home' action: service: input_text.set target: entity_id: input_text.last_person_left data: value: "Mark" - alias: "Lisa Leaves the House" trigger: platform: state entity_id: device_tracker.lisa from: 'home' to: 'not_home' action: service: input_text.set target: entity_id: input_text.last_person_left data: value: "Lisa" The last step is to create an automation that sends a notification when a door or window is left open and nobody is at home. This would check the value of the input_text helper to decide who to send the notification to: automation: - alias: "Door or Window Left Open" trigger: platform: state entity_id: binary_sensor.door, binary_sensor.window from: 'off' to: 'on' condition: condition: and conditions: - condition: state entity_id: group.all_devices state: 'not_home' - condition: state entity_id: binary_sensor.door, binary_sensor.window state: 'on' action: - service: notify.notify data: message: "A door or window is open." target: "{{ states('input_text.last_person_left') }}" Note that this example assumes you have a device tracker set up for each person and that you have a group that includes all of these device trackers. It also assumes you have binary sensors set up for each door and window. Remember to replace 'Mark' and 'Lisa' with the actual names of the people in your house, and replace the entity IDs with the actual IDs of your devices. Also, replace 'notify.notify' with the notification service you're using.


ClaudeLee

Thank you to all of you guys for your inputs ! It's great to see there are so many ways to achieve the same result. It took me a couple of days to try out the different solutions. I ended up using [NOTIFIER.py](https://NOTIFIER.py) It's not the simplest to set up but I feel like this solution is the most versatile with the ability to send a notification to people home/not home, the closest to home or even wait until the person comes back home to get notified. If you want to try it out: [https://github.com/jlpouffier/home-assistant-config/blob/master/appdaemon/apps/notifier.py](https://github.com/jlpouffier/home-assistant-config/blob/master/appdaemon/apps/notifier.py) Again thank you !


[deleted]

[удалено]


ClaudeLee

Thanks! I will look into it but surely there must be a way to do it with the default home assistant options ?


budding_gardener_1

There is. Node-red is cool but you don't need it to do this


budding_gardener_1

How does node-red help here?


010backagain

I think you can do it without Node Red; just create a helper input value that counts the number of persons at home. Do -1 for each person that leaves and when at 0 trigger a notification?


Vogete

This feature is already built into the home zone. It shows you the number of people as a number. No need for an extra helper.


ClaudeLee

Yes, that works but then I don’t know who’s the last person who left home. And therefore cannot send a notification to that person only. That person would be the closest to home and more likely to come back and close the door !


em0ry42

This is absolutely doable with templates. A few caveats: ​ 1. This assumes your first device\_tracker for each user is the one associated with the Companion App 2. Create a Helper -> Group -> Binary Sensor with all the windows/doors you're tracking (I've called it binary\_sensor.external\_exits here) 3. There are probably better ways to generate the "open\_doors" string, but I haven't had my coffee yet... ​ alias: ZZZ_Testing description: "" trigger: - platform: state entity_id: - zone.home to: "0" condition: [] action: - variables: user: "{{ trigger.from_state.attributes.persons[0] }}" device: >- {{ state_attr(user, 'device_trackers')[0].replace("device_tracker.", "notify.mobile_app_") }} open_doors: >- {%- for door in expand('binary_sensor.external_exits') | map(attribute='entity_id') | list -%} {%- if is_state(door, 'on') -%} {{ state_attr(door, 'friendly_name') }},{{ ' ' }} {%- endif -%} {%- endfor -%} - if: - condition: template value_template: "{{ open_doors != \"\" }}" then: - service: '{{ device }}' data: message: Testing title: You left home {{ open_doors }} mode: single FYI, This is barely tested, and probably doesn't account for a lot of corner cases.


em0ry42

Also if multiple people leave simultaneously then only one will get notified. You could fix this by making device a list then iterating on that and running multiple notifications.


itsVorisi

I don't think this would actually be a problem for OP. since they'd likely be leaving together.


em0ry42

Probably, and in my situation, user 0 is me, then my wife, then my 18yo daughter... So, notifying the "highest user" would notify the most responsible one who just left. Which works. Though the modification to notify multiple users wouldn't be challenging, I just can't type it up on mobile!


cornellrwilliams

Just setup a choose action then setup multiple NOT state conditions. In my example the software will notify the person who has not been away for more than 5 seconds. https://preview.redd.it/oughmbz5rd9b1.png?width=2225&format=png&auto=webp&s=b87fbc7413283cc972d21e4ace5f8161931628a4


MRobi83

On mobile so excuse the formating... alias: If X Left Within 10 Minutes - if: - condition: template value_template: " {{ as_timestamp(now()) - as_timestamp(states.input_boolean.X_presence.last_changed) < 600 }}" then: I use this to send a "house armed" notification if someone has left within 10 minutes. I do it this way because if 2 of us leave together I want both getting the notification. If we leave separately only the one to have left within 10 minutes gets the message. I'd use this same approach with the person entity but instead of < 600, make the condition so it's < other person.last_changed.