Home (Monitor) Presence App V2

Hi just installed it through HACS on a NUC. Plus I have a pi zero w and 2 pi3.

How do I install all, is there some tutorial?

Ok I am trying to install it. Some questions please.

  1. I installed appdaemon from HASSIO addon
  2. Installed from HACS this component
  3. Under appdaemon/apps/Monitor-app there is a file home_presence_app_example, so I am modifying this file and rename it home_presence_app

Some questions a bit unclear
A. inside appadaemon/app.yaml hot to reference to home_presence_app that is under appdaemon/app/Monitor-app ?? Or shall I put the content of homepresence_app.yaml, inside app.yaml??
A. not sure the difference between home_motion_sensor and home_gateway_sensors I have a bunch of PIR (mostly Xiaomy PIR sensors and door sensors)

B. known_devices is the MAC_ADDRESS of the WiFi MAC of smartphones generally?
C. How to get the known_beacons, of devices, for example of my Galaxy Watch??

What do I need to do with my pi3 and pi0W, how do I program those, or I just put the data in the remote_monitors: section, and the program those the programming of each device?? Or?

thatā€™s my appdaemon log, maybe someone can help telling me what I do wrong

this I have under appdaemon/apps/Montior-app/home_presence_app.yaml


home_presence_app:
  module: home_presence_app
  class: HomePresenceApp
  plugin: 
    - HASS
    - MQTT
  #monitor_topic: presence
  #mqtt_event: MQTT
  #user_device_domain: device_tracker
  #everyone_not_home: everyone_not_home
  #everyone_home: everyone_home
  #somebody_is_home: somebody_is_home
  depart_check_time: 30
  depart_scans: 3
  minimum_confidence: 60
  not_home_timeout: 15
  system_check: 30
  system_timeout: 60
  home_gateway_sensors:
    - binary_sensor.pir_garden_west 
    # binary_sensor.front_door_sensor  # home door
    # binary_sensor.14a_door_sensor # office 14a sensor
    # binary_sensor.14b_door_sensor # office 14b sensor
    - binary_sensor.pir_office

  # reboot the all nodes at 12 midnight on Mondays and Thursdays
  scheduled_restart:
    time: 00:00:01
    days:
      - mon
      - thu
    location: all

  # other location configuration options
    #location: living_room, kitchen
    #location:
    # - living_room
    # - kitchen
  home_motion_sensors:
    - binary_sensor.pir_foyer
    - binary_sensor.pir_hallway
    - binary_sensor.hallway_motion_sensor_occupancy
  

  #log_level: DEBUG
  known_devices:
    - 78:02:F8:xxxx Ixxxxs
    - 7C:D6:61xxxxxF Cxxxxx
    - 48:4B:Axxxxx9 xxxxxx
    - 24:AD:74xxxxx xxxxxx
    - 04:52:Fxxxxx6 xxxxxxxi

  
  known_beacons:
    - xx:xx:xx:xx:xx:xx Odianosen's Car Keys

  

  remote_monitors:
    disable: False
    guest_room_pi3:
      auto_reboot_when_offline: True
      host: 192.168.1.239
      username: !secret guest_room_monitor_username
      password: !secret guest_room_monitor_password

    office_pi3:
      auto_reboot_when_offline: True
      host: 192.168.1.238
      username: !secret guest_room_monitor_username
      password: !secret guest_room_monitor_password

    

    living_room_pi3:
      host: 192.168.1.237
      username: !secret guest_room_monitor_username
      password: !secret guest_room_monitor_password
      reboot_command: sudo /sbin/reboot now
      auto_reboot_when_offline: True
      time: 02:00:01

this my appdaemon/apps.yaml


hello_world:
  module: hello
  class: HelloWorld

2020-04-05 17:34:14.626637 WARNING AppDaemon: Threads directive is deprecated apps - will be pinned. Use total_threads if you want to unpin your apps
2020-04-05 17:34:14.641774 INFO HASS: Connected to Home Assistant 0.107.7
2020-04-05 17:34:14.647295 INFO MQTT: Connected to Broker at URL 192.168.1.12:1883
2020-04-05 17:34:14.652081 INFO AppDaemon: Got initial state from namespace mqtt
2020-04-05 17:34:14.655736 INFO MQTT: MQTT Plugin initialization complete
2020-04-05 17:34:14.742209 INFO AppDaemon: App 'hello_world' added
2020-04-05 17:34:14.748565 INFO AppDaemon: App 'home_presence_app' added
2020-04-05 17:34:14.759901 INFO AppDaemon: Found 2 total apps
2020-04-05 17:34:14.767507 INFO AppDaemon: Starting Apps with 2 workers and 2 pins
2020-04-05 17:34:14.809402 INFO HASS: Evaluating startup conditions
2020-04-05 17:34:15.185980 INFO AppDaemon: Got initial state from namespace default
2020-04-05 17:34:16.777571 INFO AppDaemon: Scheduler running in realtime
2020-04-05 17:34:16.782198 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2020-04-05 17:34:16.783169 INFO AppDaemon: Adding /config/appdaemon/apps/Monitor-App to module import path
2020-04-05 17:34:16.801098 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/deconz_event.py - ignoring
2020-04-05 17:34:16.804171 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/hello.py
2020-04-05 17:34:16.813164 WARNING Error: ------------------------------------------------------------
2020-04-05 17:34:16.814313 WARNING Error: Unexpected error loading module: /config/appdaemon/apps/hello.py:
2020-04-05 17:34:16.815287 WARNING Error: ------------------------------------------------------------
2020-04-05 17:34:16.818672 WARNING Error: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 788, in check_app_updates
    await utils.run_in_executor(self, self.read_app, mod["name"], mod["reload"])
  File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 276, in run_in_executor
    response = future.result()
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 580, in read_app
    self.modules[module_name] = importlib.import_module(module_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/appdaemon/apps/hello.py", line 1, in <module>
    import appdaemon.appapi as appapi
ModuleNotFoundError: No module named 'appdaemon.appapi'
2020-04-05 17:34:16.821161 WARNING Error: ------------------------------------------------------------
2020-04-05 17:34:16.821999 WARNING AppDaemon: Removing associated apps:
2020-04-05 17:34:16.822665 WARNING AppDaemon: hello_world
2020-04-05 17:34:16.824420 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/hass_apps_loader.py - ignoring
2020-04-05 17:34:16.827451 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/remote_control.py - ignoring
2020-04-05 17:34:16.828908 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/OLDhome_presence_app.py - ignoring
2020-04-05 17:34:16.830297 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/cube_control.py - ignoring
2020-04-05 17:34:16.831709 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/Monitor-App/home_presence_app.py
2020-04-05 17:34:16.837957 INFO AppDaemon: Initializing app home_presence_app using class HomePresenceApp from module home_presence_app
2020-04-05 17:34:16.840268 WARNING home_presence_app: ------------------------------------------------------------
2020-04-05 17:34:16.840816 WARNING home_presence_app: Unexpected error initializing app: home_presence_app:
2020-04-05 17:34:16.841391 WARNING home_presence_app: ------------------------------------------------------------
2020-04-05 17:34:16.842496 WARNING home_presence_app: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 820, in check_app_updates
    await self.init_object(app)
  File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 279, in init_object
    "object": app_class(
  File "/usr/lib/python3.8/site-packages/appdaemon/adbase.py", line 75, in __init__
    self.dashboard_dir = self.AD.http.dashboard_dir
AttributeError: 'NoneType' object has no attribute 'dashboard_dir'
2020-04-05 17:34:16.842923 WARNING home_presence_app: ------------------------------------------------------------
2020-04-05 17:34:16.843680 WARNING AppDaemon: Unable to find module home_presence_app - initialize() skipped
2020-04-05 17:34:16.844837 INFO AppDaemon: App initialization complete

Hello,

Your issue is actually beyond this app, I think you should check on the monitor thread itself for assistance.

Once itā€™s been resolved, so let me know if you still having issues.

Regards

The You can leave the app config in home_presence_app.yaml. There is no need of moving it to apps.yaml

home_motion_sensors are not really needed, but home_gateway_sensorsis needed, as it uses it to scan for devices. Do your door sensors should go to home_gateway_sesnors

The MAC address belonging to the deviceā€™s Bluetooth. Each Bluetooth device has a MAC address associated with it.

I honestly donā€™t use the beacons, so not sure how to get it as you requesting. So I am afraid I canā€™t help you there.

The Error you getting is an AD error, which will be fixed in the next release. To fix it for now, kindly add the http component as described here.

Regards

oK, thanks, almost all fixed. Is the below warning to be fixed? Not sure what that is


2020-04-05 21:29:10.278452 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/Monitor-App/home_presence_app.py
2020-04-05 21:29:10.287696 INFO AppDaemon: Initializing app home_presence_app using class HomePresenceApp from module home_presence_app
2020-04-05 21:29:10.298505 WARNING home_presence_app: home_presence_app: Entity monitor.monitor_state not found in namespace mqtt
2020-04-05 21:29:10.299433 INFO AppDaemon: home_presence_app: Entity monitor.monitor_state created in namespace: mqtt
2020-04-05 21:29:10.476133 INFO home_presence_app: Setting up Monitor auto reboot
2020-04-05 21:29:10.497793 INFO AppDaemon: App initialization complete

BTW I guess now I have to install monitor on nmy pi3 and i0w.

I am following these instructions

but up to which point I have to install? Until this below (point 3 mqtt settings), included, and then no more??

  1. Initial run:

Configuration files will be created with default preferences. Any executables that are not installed will be reported. All can be installed via apt-get install ...

sudo bash monitor.sh

  1. Edit mqtt_preferences file:

sudo nano mqtt_preferences

#################

also I do not understand which are these username and passwords ā€¦ where do I set them up???


remote_monitors:
    disable: False
    guest_room_pi3:
      auto_reboot_when_offline: True
      host: 192.168.1.239
      username: !secret guest_room_monitor_username
      password: !secret guest_room_monitor_password

how/where to see this server?

The warning is totally fine, so donā€™t bother abt it.

You install until the creation of the behaviour_preferences and all the reporting true in it. Then itā€™s all good

Ops, sorry I do not get it. I do not see behaviour_preferences in the instructions. So do I need to set mqtt_preferences and known_static_addresses in EACH pi3 and pi0w, or is not needed???

Other small issue. If I use my smartphone and my watch, I will have 2 binary_sensor.watch and binary_sensor.phone ā€¦ will I need to do a template sensor to ā€œmergeā€ the 2 into one single binary_sensor??

Like the below, or there is a better system?


binary_sensor:
  - platform: template
    sensors:
      john:
        device_class: presence
        value_template: "{{ is_state('binary_sensor.rwatch', 'on') or is_state('binary_sensor.phone_motion', 'on') }}"

also how to launch a SCAN to all the piā€™s?

Yes for now you have to. I havenā€™t gotten around to merging different devices for a single person

The app handles that automatically for you based on the state of the gateway_sensors. Also the monitor system itself allows to do that.

Regards

if I understood correctly there is an arrival scan and departure scan ā€¦ how is handled that?

Yes there is. The monitor system supports it by default by sending an empty payload to the topic monitor/scan/depart monitor/scan/arrive

Ok, just that I understand, if I publish that topic it will go to all nodes (pi0w running monitor)?

Yes it will

So after quite a few failed attempts I have managed (I think) to install AppDaemon and the Home Presence App. However, no matter what I do I canā€™t seem to get AD to recognize that the app is installed.

In the /config/appdeamon/apps/Monitor-App folder I have a home_presence_app.yaml file that contains the following:

home_presence_app:
  module: home_presence_app
  class: HomePresenceApp
  plugin:
    - HASS
    - MQTT
  #monitor_topic: presence
  #mqtt_event: MQTT
  #user_device_domain: device_tracker
  #everyone_not_home: everyone_not_home
  #everyone_home: everyone_home
  #somebody_is_home: somebody_is_home
  depart_check_time: 30
  depart_scans: 3
  minimum_confidence: 60
  not_home_timeout: 15
  system_check: 30
  system_timeout: 60
  home_gateway_sensors:
    - binary_sensor.main_door_contact

  # reboot the all nodes at 12 midnight on Mondays and Thursdays
  scheduled_restart:
    time: 00:00:01
    days:
      - mon
      - thu
    location: all

  # other location configuration options

  log_level: DEBUG
  known_devices:
    xx:xx:xx:xx:xx:xx SE2020_bt #MAC address for BT on SE2020

Output from AD log is:

2020-05-20 19:41:08.375943 INFO hello_world: You are now ready to run Apps!
2020-05-20 19:41:08.375197 INFO hello_world: Hello from AppDaemon
2020-05-20 19:41:08.369907 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2020-05-20 19:41:08.369033 INFO AppDaemon: Terminating hello_world
2020-05-20 19:41:08.368770 INFO AppDaemon: Processing restart for HASS

What additional configuration file(s) are required to run the Home Presence App successfully?

I just installed the following:

  • monitor
  • mqtt (hass add-on)
  • appdaemon (hass add-on)
  • monitor-app (hacs automation)

I now see the related binary_sensor entities. However, I do not see the ā€œnearest_monitorā€ attribute anywhere. Please help. Thank you.

My home_presence_app.yaml configuration:

home_presence_app:
  module: home_presence_app
  class: HomePresenceApp
  plugin: 
    - HASS
    - MQTT
  home_gateway_sensors:
    - binary_sensor.front_door
    - binary_sensor.garage_door
  scheduled_restart:
    time: 03:00:00
    days:
      - wed
      - sat
    location:
      - living_room
      - master_room
  home_motion_sensors:
    - binary_sensor.living_room
    - binary_sensor.master_room
  known_devices:
    - 3c:xx:xx:xx:xx:0e galaxy
    - c0:xx:xx:xx:xx:4f iphone

Hello @rationi_meae,

Did you pair the devices with the nodes? Without pairing, you canā€™t have rssi readings and by extension the nearest monitor attributes.

Regards