Giter Site home page Giter Site logo

ad-espresense-ips's Introduction

ATTENTION: This has been replaced by this: https://github.com/ESPresense/ESPresense-companion

ESPresense - Ips Solver

Appdaemon app that attempts to solve indoor position (x,y,z) with multiple ESPresense stations using multilateralization.

This uses numpy/scipy with a "Nelder-Mead" minimize of total error. Error is the amount of difference a guessed position has between the calced distance to a base station and the actual measured distance to the base station (via ESPresense rssi). Various x,y,z are tried and the position with the least error is where we guess it is.

This requires at least 3 ESPresense nodes that can get a "fix" on the particular device. The more devices the better. To get a decently accurate position you need at least 5 or 6. But this can find the location of something even if the particular room doesn't have a base station (You can put nodes on the perimeter of your house instead of the "center" of rooms). To actually determine if an item is in a particular room, you have to write down two opposite coordinates of a room to check if the items coordinates are within these boundaries.

Installation

For this to work you need to add this to your appdaemon Add-On config: image

You need to have both MQTT and HASS added to appdaemon.yaml:

appdaemon:
  time_zone: America/New_York
  latitude: 40.234223
  longitude: -75.23456
  elevation: 146
  plugins:
    HASS:
      type: hass
      ha_url: "http://192.168.128.8:8123"
      token: "xxxx"
      namespace: default
      app_init_delay: 30
      appdaemon_startup_conditions:
        delay: 30
    MQTT:
      type: mqtt
      client_host: 192.168.128.9
      namespace: mqtt
      birth_topic: appdaemon
      will_topic: appdaemon

Finally you need something like this in your app.yaml:

ESPresenseIps:
  module: espresense-ips
  class: ESPresenseIps
  pluggins:
    - HASS
    - MQTT
  draw_interval: 3
  rooms:
    office: [0, 0.864, 0.965]
    living_room: [9.83, 0.584, 1.224]
    living_room_2: [3.175, 1.499, 1.727]
    bedroom: [9.398, 5.817, 1.32]
    kitchen: [3.772, 7.417, 0.838]
    kitchen_2: [1.049, 4.56, 1.930]
  devices:
  - id: iBeacon:xxxx
    name: Phone
    timeout: 30
    away_timeout: 120
  roomplans:
  - name: office
    points:
    - x: 0.0
      y: 0.0
    - x: 3.175
      y: 0
    - x: 3.175
      y: 2.225
    - x: 1.87
      y: 3.658
    - x: 0
      y: 1.956
  - name: living_room
    points:
    - x: 3.175
      y: 0
    - x: 9.449
      y: 0
    - x: 9.449
      y: 3.327
    - x: 2.171
      y: 3.327
    - x: 3.175
      y: 2.225
  - name: bedroom
    points:
    - x: 5.41
      y: 6.985
    - x: 5.41
      y: 6.121
    - x: 6.248
      y: 6.121
    - x: 6.248
      y: 4.191
    - x: 9.398
      y: 4.191
    - x: 9.398
      y: 6.985
  - name: kitchen
    points:
    - x: 1.081
      y: 2.94
    - x: 1.87
      y: 3.658
    - x: 2.171
      y: 3.327
    - x: 5.41
      y: 3.327
    - x: 5.41
      y: 6.985
    - x: 4.166
      y: 6.985
    - x: 2.917
      y: 8.356
    - x: 0.006
      y: 5.706
    - x: 1.169
      y: 4.428
    - x: 0.38
      y: 3.71

This application allows one to :

  • Create a floorplan/Rooms easily
  • Name each room
  • Add your ESP32 devices inside each room
  • Add z values for ESP32's, coverage radius and coverage circle color
  • Show coverage of each ESP32 devices to see the exact coverage in each rooms
  • Show coverage of ESP32 while you place them so you can find what are the best places.
  • Export your floorplan to yaml format with room coordinates and esp32 devices coordinates (just copy past inside app.js)

ad-espresense-ips's People

Contributors

dtterastar avatar kuotenoashiato avatar maxakipust avatar rfortunatov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ad-espresense-ips's Issues

device_tracker or device_tracker.see

Is there any way to use ESPresense as a device.tracker for a person enitity?

Or perhaps there's a way to use the device_tracker.see to pull information from ESPresense?

FloorPlan creator for ESPresenseIPS

Hey, the FloorPlan creator for ESPresenseIPS (https://github.com/stan69b/ESPresenseIPS-Floorplan-Creator) is now in a stable state.

This application allows one to :

  • Create a floorplan/Rooms easily
  • Name each room
  • Add your ESP32 devices inside each room
  • Add z values for ESP32's, coverage radius and coverage circle color
  • Show coverage of each ESP32 devices to see the exact coverage in each rooms
  • Show coverage of ESP32 while you place them so you can find what are the best places.
  • Export your floorplan to yaml format with room coordinates and esp32 devices coordinates (just copy past inside app.js)

A feedback would be most welcome, on the functional part mostly.
For now if multiple esp32 in a room, they will all have the same name (room name) in the yaml, is this ok ? (i suppose not, but can't guess the right way).

Feel free to link this app in your readme if you wish.

(Funny fact, I have not tested the app myself, at least not for my home. I did however triple check every calculations. xD)

Precision improvement - Wrong values polluting calculations

Hey, I've been playing a lot lately and have been having precision issues. I have 10 esp32 for 90m2. some walls are thick concrete, some in construction bricks (thiner) and juste small separations as well.
I found out that most of the time, the beacon closest to the device has the right measurement,
but a beacon from a "far away" room and a thick wall in between will return a wrong value that is also very close (1m/1.5m).
Given this, I supposed that the algorithm was miscalculating the position because 2 opposite (or more) beacons are giving small values which tends to put my devices in the center of my floorplan.

I had some ideas to approach this problem :

  • have a threshold or a diameter value in the config, Take the esp with the smallest value, and only take into account esps that are in range using smallest value esp as center and diameter value as .... diameter. Thing is, if the smallest value is a false one.... not good
  • If I have 3 esps or more per room, maybe restrict detection to the room only and discard values from other esps, so we can have a more accurate per room detection. (but that would not be practical to setup for most people i suppose .... )
  • Have a system of weight on each esps, and try to find a way to reliably give importance to the closest/more precise esps. Using the weight value, we could multiply each coordinates by its weight, hopefully, the calculation is taking a barycenter and this would filter out extreme values that have been deemed not important.

I suppose other ways are possible, I'm planning on trying to code it and make a Pull Request but I would like a little help on understanding the current code and have other ideas if you have any so we can come up with a robust and reliable solution.

Hope I made sense in all this, It's all guess work above, I might be wrong on some things.

App has 0 callbacks on Appdaemon after new setup

As the title says, I just installed this tool, and generated a floorplan using the floorplan generator.

My device is seen by 4 out of 6 ESPs32 at the moment, but the mqtt topic */ips and */location are not created.

What should I double check first?

Error: Unexpected error loading module: /conf/apps/ad-espresense-ips/espresense-ips.py:

Any ideas how to resolve this error?

~/appdaemon$ docker-compose logs -f
Attaching to appdaemon-custom
appdaemon-custom | fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
appdaemon-custom | fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
appdaemon-custom | OK: 1283 MiB in 104 packages
appdaemon-custom | Requirement already satisfied: scipy in /usr/local/lib/python3.9/site-packages (from -r /conf/apps/ad-espresense-ips/requirements.txt (line 1)) (1.7.3)
appdaemon-custom | Requirement already satisfied: numpy in /usr/local/lib/python3.9/site-packages (from -r /conf/apps/ad-espresense-ips/requirements.txt (line 2)) (1.22.0)
appdaemon-custom | WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
appdaemon-custom | WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
appdaemon-custom | You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
appdaemon-custom | 2022-01-09 14:49:16.777660 INFO AppDaemon: AppDaemon Version 4.2.0 starting
appdaemon-custom | 2022-01-09 14:49:16.777891 INFO AppDaemon: Python version is 3.9.9
appdaemon-custom | 2022-01-09 14:49:16.778132 INFO AppDaemon: Configuration read from: /conf/appdaemon.yaml
appdaemon-custom | 2022-01-09 14:49:16.782568 INFO AppDaemon: Added log: AppDaemon
appdaemon-custom | 2022-01-09 14:49:16.782937 INFO AppDaemon: Added log: Error
appdaemon-custom | 2022-01-09 14:49:16.783097 INFO AppDaemon: Added log: Access
appdaemon-custom | 2022-01-09 14:49:16.783245 INFO AppDaemon: Added log: Diag
appdaemon-custom | 2022-01-09 14:49:16.806867 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
appdaemon-custom | 2022-01-09 14:49:16.972205 INFO HASS: HASS Plugin Initializing
appdaemon-custom | 2022-01-09 14:49:16.972428 INFO HASS: HASS Plugin initialization complete
appdaemon-custom | 2022-01-09 14:49:16.972663 INFO AppDaemon: Loading Plugin MQTT using class MqttPlugin from module mqttplugin
appdaemon-custom | 2022-01-09 14:49:16.979690 INFO MQTT: MQTT Plugin Initializing
appdaemon-custom | 2022-01-09 14:49:16.980516 INFO MQTT: Using appdaemon_mqtt_client as Client ID
appdaemon-custom | 2022-01-09 14:49:16.981043 INFO AppDaemon: Initializing HTTP
appdaemon-custom | 2022-01-09 14:49:16.981727 INFO AppDaemon: Using 'ws' for event stream
appdaemon-custom | 2022-01-09 14:49:16.985705 INFO AppDaemon: Starting API
appdaemon-custom | 2022-01-09 14:49:16.989727 INFO AppDaemon: Starting Admin Interface
appdaemon-custom | 2022-01-09 14:49:16.990114 INFO AppDaemon: Starting Dashboards
appdaemon-custom | 2022-01-09 14:49:17.002101 INFO HASS: Connected to Home Assistant 2021.12.0
appdaemon-custom | 2022-01-09 14:49:17.023402 INFO AppDaemon: App 'ESPresenseIps' added
appdaemon-custom | 2022-01-09 14:49:17.024815 INFO AppDaemon: Found 1 total apps
appdaemon-custom | 2022-01-09 14:49:17.025203 INFO AppDaemon: Starting Apps with 1 workers and 1 pins
appdaemon-custom | 2022-01-09 14:49:17.026256 INFO AppDaemon: Running on port 5050
appdaemon-custom | 2022-01-09 14:49:17.028347 INFO MQTT: Connected to Broker at URL <mqtt_ip>:1883
appdaemon-custom | 2022-01-09 14:49:17.050107 INFO HASS: Evaluating startup conditions
appdaemon-custom | 2022-01-09 14:49:17.050457 INFO HASS: Delaying startup for 30 seconds
appdaemon-custom | 2022-01-09 14:49:17.054855 INFO AppDaemon: Got initial state from namespace mqtt
appdaemon-custom | 2022-01-09 14:49:17.055141 INFO MQTT: MQTT Plugin initialization complete
appdaemon-custom | 2022-01-09 14:49:17.124610 INFO MQTT: Unable to decode MQTT message
appdaemon-custom | 2022-01-09 14:49:47.063785 INFO HASS: Startup condition met: hass state=RUNNING
appdaemon-custom | 2022-01-09 14:49:47.064217 INFO HASS: All startup conditions met
appdaemon-custom | 2022-01-09 14:49:47.094584 INFO AppDaemon: Got initial state from namespace default
appdaemon-custom | 2022-01-09 14:49:48.101747 INFO AppDaemon: Scheduler running in realtime
appdaemon-custom | 2022-01-09 14:49:48.104469 INFO AppDaemon: Adding /conf/apps to module import path
appdaemon-custom | 2022-01-09 14:49:48.104772 INFO AppDaemon: Adding /conf/apps/ad-espresense-ips to module import path
appdaemon-custom | 2022-01-09 14:49:48.106562 INFO AppDaemon: Loading App Module: /conf/apps/ad-espresense-ips/espresense-ips.py
appdaemon-custom | 2022-01-09 14:49:48.186441 WARNING Error: ------------------------------------------------------------
appdaemon-custom | 2022-01-09 14:49:48.186730 WARNING Error: Unexpected error loading module: /conf/apps/ad-espresense-ips/espresense-ips.py:
appdaemon-custom | 2022-01-09 14:49:48.186940 WARNING Error: ------------------------------------------------------------
appdaemon-custom | 2022-01-09 14:49:48.194257 WARNING Error: Traceback (most recent call last):
appdaemon-custom |   File "/usr/local/lib/python3.9/site-packages/appdaemon/app_management.py", line 993, in check_app_updates
appdaemon-custom |     await utils.run_in_executor(self, self.read_app, mod["name"], mod["reload"])
appdaemon-custom |   File "/usr/local/lib/python3.9/site-packages/appdaemon/utils.py", line 337, in run_in_executor
appdaemon-custom |     response = future.result()
appdaemon-custom |   File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
appdaemon-custom |     result = self.fn(*self.args, **self.kwargs)
appdaemon-custom |   File "/usr/local/lib/python3.9/site-packages/appdaemon/app_management.py", line 784, in read_app
appdaemon-custom |     self.modules[module_name] = importlib.import_module(module_name)
appdaemon-custom |   File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
appdaemon-custom |     return _bootstrap._gcd_import(name[level:], package, level)
appdaemon-custom |   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
appdaemon-custom |   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
appdaemon-custom |   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
appdaemon-custom |   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
appdaemon-custom |   File "<frozen importlib._bootstrap_external>", line 850, in exec_module
appdaemon-custom |   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
appdaemon-custom |   File "/conf/apps/ad-espresense-ips/espresense-ips.py", line 15, in <module>
appdaemon-custom |     from scipy.optimize import minimize
appdaemon-custom |   File "/usr/local/lib/python3.9/site-packages/scipy/optimize/__init__.py", line 400, in <module>
appdaemon-custom |     from .optimize import *
appdaemon-custom |   File "/usr/local/lib/python3.9/site-packages/scipy/optimize/optimize.py", line 36, in <module>
appdaemon-custom |     from ._numdiff import approx_derivative
appdaemon-custom |   File "/usr/local/lib/python3.9/site-packages/scipy/optimize/_numdiff.py", line 6, in <module>
appdaemon-custom |     from scipy.sparse.linalg import LinearOperator
appdaemon-custom |   File "/usr/local/lib/python3.9/site-packages/scipy/sparse/linalg/__init__.py", line 112, in <module>
appdaemon-custom |     from .dsolve import *
appdaemon-custom |   File "/usr/local/lib/python3.9/site-packages/scipy/sparse/linalg/dsolve/__init__.py", line 58, in <module>
appdaemon-custom |     from .linsolve import *
appdaemon-custom |   File "/usr/local/lib/python3.9/site-packages/scipy/sparse/linalg/dsolve/linsolve.py", line 11, in <module>
appdaemon-custom |     from . import _superlu
appdaemon-custom | ImportError: Error relocating /usr/local/lib/python3.9/site-packages/scipy/sparse/linalg/dsolve/_superlu.cpython-39-x86_64-linux-gnu.so: dasum_: symbol not found
appdaemon-custom | 
appdaemon-custom | 2022-01-09 14:49:48.194494 WARNING Error: ------------------------------------------------------------
appdaemon-custom | 2022-01-09 14:49:48.194688 WARNING AppDaemon: Removing associated apps:
appdaemon-custom | 2022-01-09 14:49:48.194888 WARNING AppDaemon: ESPresenseIps
appdaemon-custom | 2022-01-09 14:49:48.195648 INFO AppDaemon: App initialization complete

espresense/ips captures all ble devices

Hi,
Looking at the espresense/ips topic with an mqtt explorer I noticed that all my ble devices are captured. Is this desired/part of the code? Apart from the two fitbits all other devices are static. Was thinking that maybe we could use this somehow to increase the ips accuracy?.

I'm also wondering wether this has any impact over the battery powered ble devices (LYWSD03MMC xiaomi ble TH sensors for example)

image

Thoughts on dealing with multiple floors

Thanks for this project, it's really dope!

I've setup ad-espresense-ips in this PR https://github.com/mvgijssel/setup/pull/134/files where I've configured two AppDaemon apps, Downstairs_ESPresenseIps and Upstairs_ESPresenseIps to help me with bluetooth object tracking across two floor.

I've made a couple of observations

  1. As mentioned in your readme, it's really helpful to have bluetooth scanners in the corners of your house. Trying to solve that in vgijssel/setup#139.

  2. matplatlib is not thread safe, therefore I got some really interesting behaviour in the mqtt camera inside of Home Assistant 🤣 because AppDaemon uses a thread per app. Implemented draw_interval_offset as a quick hack to get a semi-stable image for upstairs and downstairs.

  3. The z value of the tracked object is really high. For example this is a plot of the last 15 minutes from Home Assistant where the lowest z is 4,66 meters and I'm pretty sure my Apple Watch is in the living room on the downstairs floor and not on the roof 🤔.

image

Now I'm curious if you have any thoughts how to accurately determine the floor. I've read the comment posted here #21 (comment), to use the z value as a way to determine the active floor, but there doesn't seem to be a reliable pattern when changing floors while looking at the data. The z value is constantly really high and seems to fluctuate a lot. I'm probably doing something wrong, just would love to pick your brain on what that is!

Should we start over?

Trying to install HACS, then turning on AppDaemon, then adding custom repo, then configuring the app. It's TOO painful. We should just make a custom Add On.

Unable to decode MQTT message

I saw this issue in the How to Use thread in a post by @duceduc, but couldn't find an answer that worked for him.
I to have my MQTT Broker set to use authentication. And attempted to add those creds to my config...
I am assuming I should end up seeing new entities in HA for my configured BLE devices if everything is working. Is that correct?

AppDaemon is new to me so please bear with my ignorance.

I attempted to notate parts that I though might be problematic...

Here is my config and associated Logs...
AppDaemon:
Config:

init_commands:
  - apk add --update python3 python3-dev py3-numpy py3-scipy
python_packages: []
system_packages: []
type: hass
ha_url: '!secret ha_local_url'
token: '!secret appdaemon_token'

Log:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: AppDaemon 4
 Python Apps and Dashboard using AppDaemon 4.x for Home Assistant
-----------------------------------------------------------
 Add-on version: 0.8.1
 You are running the latest version of this add-on.
 System: Home Assistant OS 7.4  (aarch64 / odroid-n2)
 Home Assistant Core: 2022.2.6
 Home Assistant Supervisor: 2022.01.1
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] appdaemon.sh: executing... 
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/aarch64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/aarch64/APKINDEX.tar.gz
(1/7) Installing libgfortran (10.3.1_git20211027-r0)
(2/7) Installing openblas (0.3.18-r1)
(3/7) Installing py3-numpy (1.21.4-r0)
(4/7) Installing pkgconf (1.8.0-r0)
(5/7) Installing python3-dev (3.9.7-r4)
(6/7) Installing py3-numpy-f2py (1.21.4-r0)
(7/7) Installing py3-scipy (1.7.2-r0)
Executing busybox-1.34.1-r3.trigger
OK: 236 MiB in 74 packages
[cont-init.d] appdaemon.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[10:15:55] INFO: Starting AppDaemon...
2022-02-23 10:15:56.899945 INFO AppDaemon: AppDaemon Version 4.2.1 starting
2022-02-23 10:15:56.900272 INFO AppDaemon: Python version is 3.9.7
2022-02-23 10:15:56.900527 INFO AppDaemon: Configuration read from: /config/appdaemon/appdaemon.yaml
2022-02-23 10:15:56.900747 INFO AppDaemon: Added log: AppDaemon
2022-02-23 10:15:56.900972 INFO AppDaemon: Added log: Error
2022-02-23 10:15:56.901174 INFO AppDaemon: Added log: Access
2022-02-23 10:15:56.901369 INFO AppDaemon: Added log: Diag
2022-02-23 10:15:56.928966 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2022-02-23 10:15:57.259672 INFO HASS: HASS Plugin Initializing
2022-02-23 10:15:57.259981 INFO HASS: HASS Plugin initialization complete
2022-02-23 10:15:57.260431 INFO AppDaemon: Loading Plugin MQTT using class MqttPlugin from module mqttplugin
2022-02-23 10:15:57.270073 INFO MQTT: MQTT Plugin Initializing
2022-02-23 10:15:57.271187 INFO MQTT: Using appdaemon_mqtt_client as Client ID
2022-02-23 10:15:57.272147 INFO AppDaemon: Initializing HTTP
2022-02-23 10:15:57.272704 INFO AppDaemon: Using 'ws' for event stream
2022-02-23 10:15:57.278229 INFO AppDaemon: Starting API
2022-02-23 10:15:57.283083 INFO AppDaemon: Starting Admin Interface
2022-02-23 10:15:57.283703 INFO AppDaemon: Starting Dashboards
2022-02-23 10:15:57.299168 INFO HASS: Connected to Home Assistant 2022.2.6
2022-02-23 10:15:57.309481 INFO MQTT: Connected to Broker at URL 192.168.20.8:1883
###
###Area of concern
###
2022-02-23 10:15:57.336588 WARNING AppDaemon: App 'module' missing 'class' or 'module' entry - ignoring
2022-02-23 10:15:57.337452 WARNING AppDaemon: App 'class' missing 'class' or 'module' entry - ignoring
2022-02-23 10:15:57.338206 WARNING AppDaemon: App 'pluggins' missing 'class' or 'module' entry - ignoring
2022-02-23 10:15:57.339032 WARNING AppDaemon: App 'rooms' missing 'class' or 'module' entry - ignoring
2022-02-23 10:15:57.339546 WARNING AppDaemon: App 'devices' missing 'class' or 'module' entry - ignoring
2022-02-23 10:15:57.339920 WARNING AppDaemon: App 'roomplans' missing 'class' or 'module' entry - ignoring
###
End Area of concern###
###
2022-02-23 10:15:57.341036 INFO AppDaemon: Found 0 total apps
2022-02-23 10:15:57.341723 INFO AppDaemon: Starting Apps with 0 workers and 0 pins
2022-02-23 10:15:57.342384 INFO AppDaemon: Running on port 5050
2022-02-23 10:15:57.347969 INFO AppDaemon: Got initial state from namespace mqtt
2022-02-23 10:15:57.348693 INFO MQTT: MQTT Plugin initialization complete
2022-02-23 10:15:57.379426 INFO HASS: Evaluating startup conditions
2022-02-23 10:15:57.380201 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
###
###Area of concern
###
2022-02-23 10:15:57.562077 INFO MQTT: Unable to decode MQTT message
###
End Area of concern###
###
2022-02-23 10:15:58.846213 INFO AppDaemon: New client Admin Client connected
2022-02-23 10:16:02.387854 INFO HASS: Connected to Home Assistant 2022.2.6
2022-02-23 10:16:02.430545 INFO HASS: Evaluating startup conditions
2022-02-23 10:16:02.435964 INFO HASS: Startup condition met: hass state=RUNNING
2022-02-23 10:16:02.436412 INFO HASS: All startup conditions met
2022-02-23 10:16:02.489022 INFO AppDaemon: Got initial state from namespace default
###
###Area of concern
###
2022-02-23 10:16:02.889058 INFO MQTT: Previous message repeated 17 times
###
End Area of concern###
###
2022-02-23 10:16:02.889466 INFO MQTT: Unable to decode MQTT message
2022-02-23 10:16:04.378388 INFO AppDaemon: Scheduler running in realtime
2022-02-23 10:16:04.385863 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2022-02-23 10:16:04.388837 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/hello.py - ignoring
2022-02-23 10:16:04.390198 INFO AppDaemon: App initialization complete
###
###Area of concern
###
2022-02-23 10:16:07.891376 INFO MQTT: Previous message repeated 10 times
2022-02-23 10:16:07.891786 INFO MQTT: Unable to decode MQTT message
2022-02-23 10:16:12.907239 INFO MQTT: Previous message repeated 10 times
2022-02-23 10:16:12.907641 INFO MQTT: Unable to decode MQTT message
###
End Area of concern###
###

appdaemon.yaml
Config:

---
secrets: /config/secrets.yaml
appdaemon:
  latitude: !secret home_lat
  longitude: !secret home_long
  elevation: !secret home_elevation
  time_zone: ! secret time_zone
  plugins:
    HASS:
      type: hass
      ha_url: !secret ha_local_url
      token: !secret appdaemon_token
      app_init_delay: 30
      appdaemon_startup_conditions:
        delay:30
    MQTT:
      type: mqtt
      client_host: !secret mqtt_broker_ip
      client_user: !secret mqtt_broker_username
      client_password: !secret mqtt_password
      namespace: mqtt
      birth_topic: appdaemon
      will_topic: appdaemon
http:
  url: http://127.0.0.1:5050
admin:
api:
hadashboard:

apps.yaml
Config:

  ESPresenseIps:
  module: espresense-ips
  class: ESPresenseIps
  pluggins:
    - HASS
    - MQTT
  rooms:
    bedroom: [1.5, 0.5, 0.6]
    bathroom: [4.5, 5.7, 1.5]
    living_room: [8.8, 0.7, 0.5]
    kitchen: [5.3, 5.4, 1.5]
  devices:
  - id: !secret oneplus9pro_ble_id
    name: Stuart OnePlus 9 Pro BLE IPS
    timeout: 30
    away_timeout: 120
  - id: !secret ticwatch3pro_ble_id
    name: TicWatch Pro 3 BLE IPS
    timeout: 30
    away_timeout: 120
  roomplans:
  - name: living_room
    y1: 8.9
    x1: 0.5
    y2: 4.7
    x2: 4.3
  - name: bathroom
    y1: 3.2
    x1: 5.5
    y2: 5.7
    x2: 3.7
  - name: bedroom
    y1: 0
    x1: 0
    y2: 4.1
    x2: 3.2
  - name: kitchen
    y1: 4.9
    x1: 4.5
    y2: 7.0
    x2: 8.0

Queried IDs not mapped in IPS

I have a lot of apple devices that are duplicated, so use the query filter in espresense to identify them.
This works fine in espresense but they never show up in IPS if I use the queried id (e.g. apple:ipad6-4)

Install in Docker - Error

Hi!
This seams very promising!

I am running Home Assistant as a docker container, and I installed appdaemon as docker as well just to run this.
However, I am having issues being able to run this due to the dependencies.
Basically I get the below error trace:

(2/9) Installing libgfortran (10.3.1_git20210424-r2)
(3/9) Installing openblas (0.3.15-r0)
(4/9) Installing py3-numpy (1.20.3-r0)
(5/9) Installing mpdecimal (2.5.1-r1)
(6/9) Installing python3 (3.9.5-r1)
(7/9) Installing python3-dev (3.9.5-r1)
(8/9) Installing py3-numpy-f2py (1.20.3-r0)
(9/9) Installing py3-scipy (1.6.2-r1)
Executing busybox-1.33.1-r3.trigger
OK: 1149 MiB in 82 packages
Collecting numpy
  Downloading numpy-1.21.2.zip (10.3 MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Collecting scipy
  Downloading scipy-1.7.1.tar.gz (36.1 MB)
  Installing build dependencies: started
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'error'
    ERROR: Command errored out with exit status -11:
     command: /usr/local/bin/python /usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpq_6rnp4x
         cwd: /tmp/pip-install-r4jrxkes/scipy_febf0373d4b245f697bbcc33935bdc5e
    Complete output (65 lines):
    setup.py:490: UserWarning: Unrecognized setuptools command ('dist_info --egg-base /tmp/pip-modern-metadata-3rxzco_f'), proceeding with generating Cython sources and expanding templates
      warnings.warn("Unrecognized setuptools command ('{}'), proceeding with "
    Running from SciPy source directory.
    Running scipy/linalg/_generate_pyx.py
    Running scipy/stats/_generate_pyx.py
    Running scipy/special/_generate_pyx.py
    Processing scipy/cluster/_hierarchy.pyx
    Processing scipy/cluster/_vq.pyx
    Processing scipy/cluster/_optimal_leaf_ordering.pyx
    Processing scipy/fftpack/convolve.pyx
    Processing scipy/sparse/_csparsetools.pyx.in
    Processing scipy/sparse/csgraph/_shortest_path.pyx
    Processing scipy/sparse/csgraph/_min_spanning_tree.pyx
    Processing scipy/sparse/csgraph/_flow.pyx
    Processing scipy/sparse/csgraph/_tools.pyx
    Processing scipy/sparse/csgraph/_matching.pyx
    Processing scipy/sparse/csgraph/_reordering.pyx
    Processing scipy/sparse/csgraph/_traversal.pyx
    Processing scipy/spatial/ckdtree.pyx
    Traceback (most recent call last):
      File "/tmp/pip-install-r4jrxkes/scipy_febf0373d4b245f697bbcc33935bdc5e/tools/cythonize.py", line 324, in <module>
        main()
      File "/tmp/pip-install-r4jrxkes/scipy_febf0373d4b245f697bbcc33935bdc5e/tools/cythonize.py", line 320, in main
        find_process_files(root_dir)
      File "/tmp/pip-install-r4jrxkes/scipy_febf0373d4b245f697bbcc33935bdc5e/tools/cythonize.py", line 309, in find_process_files
        for result in pool.imap_unordered(lambda args: process(*args), jobs):
      File "/usr/local/lib/python3.9/multiprocessing/pool.py", line 870, in next
        raise value
      File "/usr/local/lib/python3.9/multiprocessing/pool.py", line 125, in worker
        result = (True, func(*args, **kwds))
      File "/tmp/pip-install-r4jrxkes/scipy_febf0373d4b245f697bbcc33935bdc5e/tools/cythonize.py", line 309, in <lambda>
        for result in pool.imap_unordered(lambda args: process(*args), jobs):
      File "/tmp/pip-install-r4jrxkes/scipy_febf0373d4b245f697bbcc33935bdc5e/tools/cythonize.py", line 243, in process
        processor_function(fromfile, tofile, cwd=path)
      File "/tmp/pip-install-r4jrxkes/scipy_febf0373d4b245f697bbcc33935bdc5e/tools/cythonize.py", line 108, in process_pyx
        raise Exception('Cython failed')
    Exception: Cython failed
    Cythonizing sources
    Traceback (most recent call last):
      File "setup.py", line 356, in generate_cython
        import pip
    ModuleNotFoundError: No module named 'pip'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 349, in <module>
        main()
      File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 331, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 151, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File "/tmp/pip-build-env-3l3o10_y/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 166, in prepare_metadata_for_build_wheel
        self.run_setup()
      File "/tmp/pip-build-env-3l3o10_y/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 258, in run_setup
        super(_BuildMetaLegacyBackend,
      File "/tmp/pip-build-env-3l3o10_y/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 150, in run_setup
        exec(compile(code, __file__, 'exec'), locals())
      File "setup.py", line 629, in <module>
        setup_package()
      File "setup.py", line 613, in setup_package
        generate_cython()
      File "setup.py", line 365, in generate_cython
        raise RuntimeError("Running cythonize failed!")
    RuntimeError: Running cythonize failed!
    ----------------------------------------�     �
WARNING: Discarding https://files.pythonhosted.org/packages/47/33/a24aec22b7be7fdb10ec117a95e1e4099890d8bbc6646902f443fc7719d1/scipy-1.7.1.tar.gz#sha256=6b47d5fa7ea651054362561a28b1ccc8da9368a39514c1bbf6c0977a1c376764 (from https://pypi.org/simple/scipy/) (requires-python:>=3.7,<3.10). Command errored out with exit status -11: /usr/local/bin/python /usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpq_6rnp4x Check the logs for full command output.
  Downloading scipy-1.7.0.tar.gz (36.1 MB)`

mqtt namespace question

I am trying to set this up with docker. I get the error below when namespace: mqtt in appdaemon.yaml. I am new to appdaemon and I am wondering if this is a worry. With the default namespace appdaemon starts up correctly.

appdaemon    | 2022-01-08 23:44:38.694597 INFO AppDaemon: Got initial state from namespace default
appdaemon    | 2022-01-08 23:44:39.606754 CRITICAL MQTT: Could not complete MQTT Plugin initialization, for Connection was refused due to Not Authorised
appdaemon    | 2022-01-08 23:44:39.607766 CRITICAL MQTT: MQTT Client Disconnected Abruptly. Will attempt reconnection
appdaemon    | 2022-01-08 23:44:41.611041 CRITICAL MQTT: Could not complete MQTT Plugin initialization, for Connection was refused due to Not Authorised
appdaemon    | 2022-01-08 23:44:41.611775 CRITICAL MQTT: MQTT Client Disconnected Abruptly. Will attempt reconnection
appdaemon    | 2022-01-08 23:44:44.719791 INFO AppDaemon: New client Admin Client connected
appdaemon    | 2022-01-08 23:44:45.615819 CRITICAL MQTT: Could not complete MQTT Plugin initialization, for Connection was refused due to Not Authorised
appdaemon    | 2022-01-08 23:44:45.616243 CRITICAL MQTT: MQTT Client Disconnected Abruptly. Will attempt reconnection
appdaemon    | 2022-01-08 23:44:45.677057 CRITICAL MQTT: Could not complete MQTT Plugin initialization, trying again in 5 seconds
appdaemon    | 2022-01-08 23:44:53.620301 CRITICAL MQTT: Could not complete MQTT Plugin initialization, for Connection was refused due to Not Authorised
appdaemon    | 2022-01-08 23:44:53.621748 CRITICAL MQTT: MQTT Client Disconnected Abruptly. Will attempt reconnection
appdaemon    | 2022-01-08 23:44:53.686474 CRITICAL MQTT: Could not complete MQTT Plugin initialization, trying again in 5 seconds
appdaemon    | 2022-01-08 23:45:03.691098 CRITICAL MQTT: Could not Complete Connection to Broker, please Ensure Broker at URL 10.168.20.26:1883 is correct and broker is not down and restart Appdaemon
appdaemon    | 2022-01-08 23:45:04.636591 CRITICAL MQTT: Could not complete MQTT Plugin initialization, trying again in 5 seconds
appdaemon    | 2022-01-08 23:45:09.641137 CRITICAL MQTT: Could not complete MQTT Plugin initialization, for Connection was refused due to Not Authorised

AppDaemon install issues.

Describe the bug
Chatted with you previously. Manual install [for me] across all version results in the following error: 'NoneType has no mqtt.unsubscribe'

Also, can't add appdaemon github repo as HACS repo.

Expected behavior
appdaemon app runs.

Logs
'NoneType has no mqtt.unsubscribe'

Hardware Details
only esp32 dev kit. do we need gps modules to work with the appdaemon? If so, would these work?

Screenshots
n/a

Help! Getting confused over coordinates

Having a tough time getting my head around which coordinates I should be using.
I just mapped it all out (or so I thought) and its stopped the app working :/

Would appreciate a set of eyes to confirm my settings or point out where I am plain wrong!
Im using the bottom left of my office as the origin (0,0)

This is my apps.yaml:

ESPresenseIps: 
  module: espresense-ips
  class: ESPresenseIps
  pluggins:
    - HASS
    - MQTT
  rooms:
    backhall: [0, 1.5, 0.5]
    bedroom: [3, 0.5, 0.5]
    office: [5, 1.5, 0]
    kitchen: [8, 0.5, 0.5]
    rearkitchen: [0, 0.5, 0.5]
    lounge: [2.5, 2.5, 0.5]
  devices: 
    - id: "apple:xxxx:xx-xx"
      name: "Jimmys Watch"
      timeout: 30
      away_timeout: 120
    - id: "apple:xxxx:xx-xx"
      name: "Jimmys iPhone"
      timeout: 30
      away_timeout: 120
    - id: "tile:cdxxxxxxxxxxx"
      name: "Jimmys Keys"
      timeout: 30
      away_timeout: 120
    - id: "apple:xxxx:x-xx"
      name: "Amys Watch"
      timeout: 30
      away_timeout: 120
  roomplans: 
    backhall: 
    y1: 20.0
    x1: 0.0
    y2: 22.0
    x2: 2.0
    bedroom: 
    y1: 20.0
    x1: 2.0
    y2: 23.0
    x2: 5.0
    kitchen: 
    y1: 15.0
    x1: 2.0
    y2: 19.0
    x2: 5.0
    lounge: 
    y1: 20.0
    x1: 2.0
    y2: 25.0
    x2: 5.0
    office: 
    y1: 0.0
    x1: 0.0
    y2: 1.0
    x2: 5.0
    rearkitchen: 
    y1: 2.0
    x1: 11.0
    y2: 15.0
    x2: 5.0

This is a rough floor plan:
image
And Im getting these error in appdaemon:

2022-02-18 15:28:40.811857 WARNING ESPresenseIps: ------------------------------------------------------------
2022-02-18 15:28:40.826641 WARNING AppDaemon: Suspect incorrect signature type for callback mqtt_message() in ESPresenseIps, should be f(self, event, data, kwargs) - discarding
2022-02-18 15:28:40.826930 WARNING ESPresenseIps: ------------------------------------------------------------
2022-02-18 15:28:40.827080 WARNING ESPresenseIps: Unexpected error in worker for App ESPresenseIps:
2022-02-18 15:28:40.827284 WARNING ESPresenseIps: Worker Ags: {'id': 'c6628c54b7f943e49a702014af025b56', 'name': 'ESPresenseIps', 'objectid': '0ed726bddb464035929354bef2eb7812', 'type': 'event', 'event': 'MQTT_MESSAGE', 'function': <bound method ESPresenseIps.mqtt_message of <espresense-ips.ESPresenseIps object at 0x7fa6902a9ac0>>, 'data': {'topic': 'espresense/rooms/office', 'wildcard': '#', 'payload': '{"id":"apple:1006:10-7","disc":"341e821af7ff","idType":35,"rssi@1m":-65,"rssi":-70,"mac":"53a3de74f16b","raw":1.39,"distance":0.67,"speed":0}'}, 'pin_app': True, 'pin_thread': 0, 'kwargs': {'topic': 'espresense/rooms/office', '__thread_id': 'thread-0'}}
2022-02-18 15:28:40.827496 WARNING ESPresenseIps: ------------------------------------------------------------
2022-02-18 15:28:40.827858 WARNING ESPresenseIps: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/appdaemon/threading.py", line 950, in worker
    funcref(args["event"], data, self.AD.events.sanitize_event_kwargs(app, args["kwargs"]))
  File "/config/appdaemon/apps/espresense-ips.py", line 71, in mqtt_message
    roomname = room_solve(self,round(pos[0],2,),round(pos[1],2))
  File "/config/appdaemon/apps/espresense-ips.py", line 96, in room_solve
    if rooms["x1"] < float(xpos) < rooms["x2"] and rooms["y1"] < float(ypos) < rooms["y2"]:
TypeError: string indices must be integers
2022-02-18 15:28:40.828075 WARNING ESPresenseIps: ------------------------------------------------------------

ERROR: unable to select packages: python3-3.9.5-r1:

Trying this for the first time but got an error:
any suggestions?

Error log:
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing...

Add-on: AppDaemon 4
Python Apps and Dashboard using AppDaemon 4.x for Home Assistant

Add-on version: 0.7.1
You are running the latest version of this add-on.
System: Ubuntu 20.04.2 LTS (amd64 / qemux86-64)
Home Assistant Core: 2021.11.5
Home Assistant Supervisor: 2021.10.8

Please, share the above information when looking for help
or support in, e.g., GitHub, forums or the Discord chat.

[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing...
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] appdaemon.sh: executing...
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
v3.14.3-42-ga41723b1be [https://dl-cdn.alpinelinux.org/alpine/v3.14/main]
v3.14.3-41-g6391631eb3 [https://dl-cdn.alpinelinux.org/alpine/v3.14/community]
OK: 14946 distinct packages available
(1/4) Installing libquadmath (10.3.1_git20210424-r2)
(2/4) Installing libgfortran (10.3.1_git20210424-r2)
(3/4) Installing openblas (0.3.15-r0)
(4/4) Installing py3-numpy (1.20.3-r0)
OK: 142 MiB in 68 packages
ERROR: unable to select packages:
python3-3.9.5-r1:
breaks: python3-dev-3.9.5-r2[python3=3.9.5-r2]
satisfies: world[python3=3.9.5-r1]
py3-urllib3-1.26.5-r0[python3]
py3-cachecontrol-0.12.6-r1[python3]
py3-retrying-1.3.3-r1[python3]
py3-contextlib2-0.6.0-r1[python3]
py3-webencodings-0.5.1-r4[python3]
py3-chardet-4.0.0-r2[python3]
py3-requests-2.25.1-r4[python3]
py3-colorama-0.4.4-r1[python3]
py3-setuptools-52.0.0-r3[python3]
py3-distlib-0.3.1-r3[python3]
py3-msgpack-1.0.2-r1[python3]
py3-pip-20.3.4-r1[python3]
py3-toml-0.10.2-r2[python3]
py3-parsing-2.4.7-r2[python3]
py3-pep517-0.10.0-r2[python3]
py3-packaging-20.9-r1[python3]
py3-progress-1.5-r2[python3]
py3-ordered-set-4.0.2-r1[python3]
py3-idna-3.2-r0[python3]
py3-cparser-2.20-r1[python3]
py3-certifi-2020.12.5-r1[python3]
py3-lockfile-0.12.2-r4[python3]
py3-appdirs-1.4.4-r2[python3]
py3-distro-1.5.0-r3[python3]
py3-six-1.15.0-r1[python3]
[19:10:20] FATAL: Failed installing package py3-scipy
[cont-init.d] appdaemon.sh: exited 1.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.