Home Presence Appdaemon App

Thanks, almost, all errors are gone, still have one, maybe i did not understand how the app works.

Is it not using my existing binary_sensor.front_door_sensor?

home_presence_app:
  module: home_presence_app
  class: HomePresenceApp
  plugin: HASS
  hass_namespace: hass
  presence_topic: presence
  minimum_confidence: 100
  not_home_timeout: 15
  home_gateway_sensors:
    - binary_sensor.front_door_sensor
  scan_timeout: 20
  users_sensors:
    - binary_sensor.john_home_state


e_presence_app: Creating Binary Sensor for Everyone Not Home State
2019-03-03 09:12:47.998297 INFO AppDaemon: MQTT: Publishing Payload {"name": "Everyone Not Home State", "device_class": "presence", "state_topic": "homeassistant/binary_sensor/everyone_not_home_state/state"} to Topic homeassistant/binary_sensor/everyone_not_home_state/config Successful
2019-03-03 09:12:47.999645 INFO home_presence_app: Creating Binary Sensor for Everyone Home State
2019-03-03 09:12:48.000246 INFO AppDaemon: MQTT: Publishing Payload {"name": "Everyone Home State", "device_class": "presence", "state_topic": "homeassistant/binary_sensor/everyone_home_state/state"} to Topic homeassistant/binary_sensor/everyone_home_state/config Successful
2019-03-03 09:12:48.013247 WARNING AppDaemon: home_presence_app: Entity binary_sensor.front_door_sensor not found in AppDaemon
2019-03-03 09:12:48.014103 INFO AppDaemon: App initialization complete

The Everyone Home is created by default by the app. To tell if everyone is home or not. I have updated it so it works a bit differently now, but yet to upload until the new AD version is released.

It will only use the door sensor to start a Depart or Arrival scan. That you will know, by simply checking if the door is opened, if the scan starts.

Regards

do i need to modify the python script to conform to my home-assistant configuration? I was able to get monitor up and running but appdaemon stuff is still new to me, do i just paste this script into my appdaemon folder under apps?

Hello Odianosen25 - long time!

After having spent much time recently overseas, I will be back home in the next few weeks. Sadly, while I was away I had a catastrophic failure of my backup system and will have to fully re-build my home automation system. I just wanted to see if you are still keeping up with this app development?

Hello @PianSom,

I hope you had a great time overseas?

Unfortunately I haven’t actually been actively developing it, as I am yet to upgrade to the latest script.

Also I have been having an issue uploading my newest version, since I use the dev version of AD, so kind of an issue.

Once AD 4.0 is released (which I unfortunately have no clue when), then I will release an update.

Outside the above, its been great.

Hey @Odianosen25 - yes, I’m really enjoying spending time in a different environment!

OK, thanks for letting me know. I’m not fully back for another 6 weeks or so, so hopefully AD4 will come out in that timescale and you’ll have the opportunity and desire to update.

There’s certainly no need for me to have any presence detection before that, so I guess I’m lucky in that respect!

Hi @Odianosen25,
First, thanks for a great APP !. In the last couple of days, I have been using it with the latest 0.2.197 version of @andrewjfreyer 's monitor script, which does break your app.

The ‘RSSI’ messages from monitor.sh force an error on the line after ‘payload = json.loads(payload)’ as json.loads returns an INT and not a DICT - therefore any attempt to subsequently reference a member of the Dict throws an error. I brute force fixed this for myself by the following line of code:

if type(payload) != dict:
return

I also implemented a ‘somebody_is_home_state’ binary sensor too - as it simplifies some of my automations.

I’m not really a programmer these days and don’t really understand Github and all the associated jargon, but happy to share my code with you if you wish. Just let me know.
Looking forward to an ‘official’ version which supports the latest monitor.sh.

Cheers

Hello @bigblue, and welcome to the community :facepunch:t5:

Thanks for your suggestions, and I will look into it.

I have actually updated the app based on the latest script and it can be seen here. I had refrained from sharing for a while, as its based on AD 4.0 which is about to be released in beta.

You can check it out, as it has a lot of features integrated. I also have an app that integrates this script with OwnTracks. But yet to publish it. Should do all that, once AD 4.0 has been officially released.

Kind regards and thanks once for more the suggestions.

1 Like

Thanks for the link, I have had a quick look and it looks great. It might be a while before I can try the new script as I am using it on HASSIO, and am reliant upon the AD plugin being updated to 4.0. This will probably be a while if AD 4.0 is only just entering beta. In the meantime my hacked version of the script works great for me.
Regards

Hey @Odianosen25 - thanks for sharing this latest version. I am really looking forward to implementing it in a few weeks. Also, great suggestion of @bigblue to include the someone_is_home sensor - I make heavy use of this in OccuSim.

One question - as well as @andrewjfreyer’s great work, I use an additional sensor based on wifi connection to determine presence slightly earlier than a bluetooth check. (I use Unifi kit, and the excellent unifi2mqtt package to publish an MQTT message when a phone connects to my home network. Since wifi penetration is often better than bluetooth this means I can get detected earlier.) At the moment I have a simple HA automation which flips a person’s binary_sensor on when they connect. Do you think this will still work when I adopt your code? Or might I have issues with persistence of your sensors across restarts?

Hello @PianSom,

You welcome.

Yes it will be possible to combine all, it will just entail you writing apps for it. I have another app that combines the data from this project, with OwnTracks and all report to a single HA device_tracker per user.

I am also working on developing another app, that combines different devices to be used by a single user. Now such an app is what will profit you in this instance.

Once I am able to put it together, I will hola you on how to get it. And I have added the binary_sensor.somebody_is_home as suggested by @bigblue.

Regards

1 Like

Hello @Odianosen25, thanks a lot for this great app. Would you mind sharing your code for the “all-in-one-device-tracker” you mentioned? Would be very interesting, to see how you solved this, as I’m trying to get something similar. :slight_smile:

Thank you! :slight_smile:

Hello @paddy0174,

Unfortunately I never got around to completing that app as I would have loved, and just abandoned the project since I have no Beacons and we just use our phones only now.

If I ever get around to it, will share it also.

Regards

1 Like

Hi @Odianosen25! :slight_smile:
Thanks a lot for your answer! I know this as well, sometimes projects start great, but while working on it, things change. :smiley: :smiley: :smiley:

But, if you have already thought that through (at least a little), may I ask for your thoughts about the following idea(s)?

My setup (short version): we are living in a rented appartment, so it’s not that easy to get control over all things I’d like to have, like the main door. Next thing is the size of the appartment… I do get a BT signal from my beacons in front of the house, than loosing the signal in the elevator, to get it back immediately after stepping out of the elevator… Device tracker with WLAN works reliable, but in a wide area. Depending on the location outside the house, I sometimes get WLAN coverage around 100 meters away from the house… To sum it up, monitor, as well as your ADapp is a great start, but it needs to be a little different to work for me.

So I did setup a Pi (with monitor.sh) near the entrance door to the appartment. I have a door contact sensor, and right in front of the door I managed to hide a motion sensor. The idea behind is to have two sensors, so I can try to guess the direction (arriving or leaving). For arriving it is: motion sensor -> door contact -> check WLAN and BT beacon -> start “arriving automations” (light on, things like that).
For departure I use the other way around: door contact -> motion sensor -> delay -> check departure.

So far so good. As I want to include the great ideas from Phil Hawthorne about beeing “not so binary”, I’m trying to set one of five different “residence states” (we_are_home, someone_is_home, no_one_is_home, on_vacation and alarm). And here comes the thing: if I could set up one device_tracker, that has the combined information in it, it would be way easier to set the states for persons and the residence.

For now I’m trying to re-write your app code to fit these needs (hope you don’t mind, but your code is great - structured, good to read and understandable). If you want, I can upload the file, if I ever get it running the way I want it to… :slight_smile:

Thanks again, and if I may ask a few questions on the way, I’d very much appreciate it. :slight_smile:

Hello @paddy0174,

I hope I was able to answer your question, but do let me know I didn’t as I honestly didn’t fully understand the question and why taken me time to respond.

Yeah it happens :wink:

Do you mean that due to the fact the beacons are picked up and dropped considering when you enter and step out of the elevator, the system already considers you home?

But right now the system could determine if you arriving or entering by checking the previous state. Unless I don’t understand what you mean. Also I would advise this be handled by another app, rather than trying to add it into this app. It helps with better management.

Now I think I would process it this way, I will have another app that will do the following
I assume BT is the monitor system, unless I am wrong.

  • Since WLAN is wider, if it picks up your phone and BT hasn’t, its safe to say you are set to arriving
  • I wouldn’t scan until the door is opened, and once it detects, you are then set to arrived or home
  • If leaving and the door is closed, you run the departure and if not picked up by BT, but still picked by WLAN you departed but around (or whatever you want to use like departing)
  • Then if dropped by WLAN then you definitely departed

To ensure it doesn’t think you home when you not, I don’t subscribe to scanning unless the entrance is opened/closed, as only at that will you truly be arrived or departed which to me means being in the house. Its one of the reasons to use this app, I suggested the monitor’s internal scanning constantly be turned off but one to avoid partially the possibility of being picked up even when outside the house. If its an issue, then all should be ran as scan unless triggered for both arrive and depart. This will actually help your wireless devices anyway.

I don’t think you need to force everything into a single entity. The thing about AD is you can create entities, which you can use to check states; this app also does that. When I need data I need to process later, especially in other apps, I store my data in entities in AD along, and listen to them in other apps so I can process their data.

No worries, its open source anyway and supposed to be improved upon :wink: . Thanks for the complement, considering I am not a full time coder :upside_down_face:.

Got no issues with it, can always message me anytime.

Hope this helps and made some sense, and didn’t complicate it the more? :roll_eyes:

Hello everyone,

I have released a new version of the app, and can read about it here. Hope you enjoy the new features.

Regards

Where do you set this option?

Hello @so3n,

This setting can be set in the behaviour_preferences within the monitor app. Please ensure you using version 2 of the app.

Regards

1 Like

Hi Guys …

Installed this … no problems nice work …
I have a the minute 2 nodes … however I’m planning to install several …

Now I don’t find where I need to modify in order to scan for rssi … At the minute Home Assistant shows my fone in 2 locations at same time and same confidence rating …

Any advice appreciated.

Hi everyone,

i’m using the Appdaemon App now for quite some time with 3 nodes (groundfloor, upper floor, and cellar) in the future there will be another in the garage.

Arrival and Departures work well, my only problem is that intermittingly devices are switching home/ not home in 10 Seconds, without me leaving the home.

I already tried to read through all the comments but could not find an explanation that helped me.
The spacing in the main node ist 120s.

I also realized that the nodes themselve are sometimes away (i suppose they should always be home/on) any idea what could cause that?

Any help is appreciated
Flave