brianhanifin / Home-Assistant-Config

Home Assistant configuration files.
https://brianhanifin.com
123 stars 23 forks source link

Announce when father-in-law arrives at home (to prepare our nervous dog) #44

Closed brianhanifin closed 3 years ago

brianhanifin commented 4 years ago

Our little dog has shown that she recognizes when Alexa announces that my wife is almost home. She gets really excited and waits by the door.

Recently I have discovered that she doesn't act as nervous when I open the blinds and show her who is coming in the door. So, it is our hope that announcing when the tall, loud, scary old man is about to come in the front door, she might feel more comfortable with his arrival.

brianhanifin commented 4 years ago

Resolved with 05986825c62b2f5c46c82997daeb857d4e72eb14

CCOSTAN commented 4 years ago

That's a legit life improving automation. (specially for the doggy!) ..

Curious if it has the desired effect ..

awesome though..

brianhanifin commented 4 years ago

Yeah, I think it could be. Unfortunately, it announced his arrival about 2 minutes after he arrived, and randomly announced his arrival after 11pm last night. He was asleep in bed. Haha.

So, its disabled for now. Do you do device presence detection more than one way? I have Life360 my and my wife's phones. However, it feels weird enough to track your wife's movements, there is no way I'm going to ask my in-laws to allow me to track them.

CCOSTAN commented 4 years ago

I just use NMAP. That's the only presence detection I have ever used and it's rock solid for me. https://github.com/CCOSTAN/Home-AssistantConfig/blob/871981dd706e35d45a5c1a84ffc67e34cfc468db/config/device_tracker/nmap.yaml

CCOSTAN commented 4 years ago

I only need to know when people are home or not. and really just home pretty quickly. When we leave the system usually figures it out about 15 minutes later and shuts everything down.

brianhanifin commented 4 years ago

Commit eb80a4f357941d84cedda83045ec64ac77cc28af reenables the warning automation. I discontinued using the iphonedetect custrom component, and enabled the UniFi Integration. Lets see if this works any better.

Note: I unsuccessfully attempted to use the UniFi Integration shortly after converting to UniFi hardware. Now with the UniFi Controller softare hosted on my Unraid server, it worked like a charm. I'm not 100% sure why, except I understand things so much better now.

brianhanifin commented 4 years ago

Commit c4f10b7 stops announcements occurring upon every restart. But they haven't left and returned yet to see if the announcement occurs in time.

The fix was to add a short delay condition to my Extended Presence Update automation. Apparently the device_trackers state default to not_home and when they updated to home the users tracked by this automation were assumed to have Just Arrived, which triggered the nervous puppy announcement.

@CCOSTAN I'm sharing this condition for my and possibly your later reference. Essentially it does not allow the action to be executed if HA just restarted. It is a more elegant solution than disabling the automation by default, then delaying a minute at startup before enabling the automation.

condition:
  # Don't allow status change immediately at startup to avoid phantom changes.
  - condition: numeric_state
    entity_id: sensor.uptime
    above: 0.2
CCOSTAN commented 4 years ago

I like this condition test.

I haven't gone down the route of extended presence though. I don't reboot too often and when I do, they do redo the announcements. The fam is used to it. :)

brianhanifin commented 4 years ago

When I am working on an advanced template sensor I can restart hassio every 5 minutes for a half hour. It makes me cringe if it happens too many times because I feel like I am reminding my wife how unreliable she believes it is. 👀

Also I am in a cycle of challenging myself right now. I really enjoy trying to come up with a slicker way of doing something, that I have been doing in a mundane way in the past. For example, I just conquered some really complex code, that removes a bunch of for loops in favor of utilizing Jinja2 filters to the fullest capability. Sure I could have been done two hours sooner... but it was so satisfying when I conquered it! 😁

{% set idle_timers  = states.timer | selectattr('state','in',['idle']) | map(attribute='entity_id') | list %}
{% set away_state_timers = states.input_select | selectattr('state','in',['Away']) | map(attribute='entity_id') | join(',') | replace('input_select.','timer.xpresence_') %}
{% set idle_away_state_timers = states.timer | map(attribute='entity_id') | select('in',idle_timers) | select('in',away_state_timers) | list %}
CCOSTAN commented 4 years ago

I do have a speech boolean that I can flip if I want to turn text on or off. I guess I could default that to off and then run a startup script that turns it on after x amount of minutes.

https://github.com/CCOSTAN/Home-AssistantConfig/blob/7cf4a97e8b43be839e61bb271b6612d58ed8bb40/config/script/speech_processing.yaml#L41-L43

brianhanifin commented 4 years ago

Utilizing the Apple Shortcuts app on my father-in-law's iPhone, his phone can now trigger a webhook when he arrives at home.

This is ready to test the next time he leaves then returns. Commit f54570c24e5ab0b8c65fd10d0a62aa61b91750ae

brianhanifin commented 4 years ago

Well, shoot. It was a great idea in theory. The problem is Shortcuts prompts the user to execute the action. That's pointless.

shortcut_problem

brianhanifin commented 4 years ago

IFTTT is a possibility for the iPhone. I have ran it for a week and when I get near home I have Home Assistant send me a notification to confirm it is working. I may set my father-in-law up with IFTTT and see if we can be successful.

brianhanifin commented 3 years ago

I just can’t figure out how to get this to work without intrusively tracking my father-in-law. I’m closing this for now.