ad-espresense-ips icon indicating copy to clipboard operation
ad-espresense-ips copied to clipboard

how to use

Open corgan2222 opened this issue 4 years ago • 102 comments
trafficstars

Hello, as answer to your comment https://github.com/mKeRix/room-assistant/issues/842#issuecomment-922391919 I'm looking into this, but I'm not sure what to do with this app. What's the out coming from this?

corgan2222 avatar Sep 19 '21 00:09 corgan2222

You give it the locations of your base stations and it tries to calculate where the tracker is in relation to those base stations. It could be overlayed on a floor plan so you could see where stuff is. Or you could tell if your inside your house, or outside.

DTTerastar avatar Sep 19 '21 10:09 DTTerastar

Could you help explain what the third number in the plot coordinates is?

garage: [0, 8, 0.4]
office: [5, 1.5, 0.5]
family: [0, 0, 0]

How did you define the the .4, .5, and 0 as they are height/z, right?

michaeldvinci avatar Sep 19 '21 16:09 michaeldvinci

Z is elevation in meters

On Sun, Sep 19, 2021 at 12:20 PM Michael Vinci @.***> wrote:

Could you help explain what the third number in the plot coordinates is?

garage: [0, 8, 0.4] office: [5, 1.5, 0.5] family: [0, 0, 0]

How did you define the the .4, .5, and 0 as they are height/z, right?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ESPresense/ad-espresense-ips/issues/2#issuecomment-922499294, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALMBSOCJM6YYBYZGNK36I3UCYETFANCNFSM5EJXDUOQ .

DTTerastar avatar Sep 19 '21 16:09 DTTerastar

Yeah one thing I've noticed is because antennas work better when higher up, trilateration for height doesn't work well yet. I think trying to put all base stations at the same height would be better to start with.

DTTerastar avatar Sep 19 '21 21:09 DTTerastar

Hello, as answer to your comment mKeRix/room-assistant#842 (comment) I'm looking into this, but I'm not sure what to do with this app. What's the out coming from this?

The idea is we can deduce the location even if there isn't a base station in that room. So you could put 4 devices on the four corners of your house and it can find where it must be based on the distances measured from the 4 points. In practice the more base stations the better, so i'd still have 6 or so, but we should be able to show the location +-1m in your house if it works.

DTTerastar avatar Sep 21 '21 19:09 DTTerastar

Hi @DTTerastar , probably being a bit dense here but still not getting it.

So the base station locations are defined as per:

garage: [0, 8, 0.4]
office: [5, 1.5, 0.5]
family: [0, 0, 0]

How do define the perimeters of the rooms?

Any idea how you'd model an L shaped house? Thanks!

Alfiegerner avatar Sep 22 '21 02:09 Alfiegerner

That's the coordinates of the base station only. I don't yet have any perimeters of rooms. That would be a later step once we get the positioning right. The code is really very dumb so far, all it does is trying and work out the most likely position by taking all fixes (distances to base stations) and base station locations and minimizing the total error based on a guess of where the device is. It outputs both the raw x,y,z as as well as a latt, long, and altitude. The latter is just the former plus the latt, long, and elevation specified in your appdaemon.yaml

DTTerastar avatar Sep 22 '21 12:09 DTTerastar

Thanks makes sense now, I'll plug it in and have a play and let you know how I go.

Alfiegerner avatar Sep 22 '21 13:09 Alfiegerner

Got it up and running, definitely lots of potential!

I found moving around the house would cause the 'holding' of old values, as we don't expire distances once we're out of range. I added a noddy timeout which helped a lot:


...
        dr["updated"] = time.time():
....
                if ("distance" in device["rooms"][r]) and (time.time() - device["rooms"][r]["updated"] < 10):
                    distance_to_stations.append(device["rooms"][r]["distance"])
                    stations_coordinates.append(device["rooms"][r]["pos"])

Something a bit more sophisticated like weighting the values might help but that's getting a bit outside my ken.

It would be nice to see which stations are currently 'fixed' to help debug - i'm a python novice and couldn't work out how to get the room name so gave up on that.

In terms of accurancy I can definitely see a case with this for adding that Android setting to specify tx power, I'll see if I can come back to that. I'm using room-assistant for base stations at the moment while I wait for some esp32s to arrive, and found that the ability to override transmission power increased accuracy a lot.

Thanks @DTTerastar for this, nice bit of work.

Alfiegerner avatar Sep 23 '21 05:09 Alfiegerner

Yeah, when I originally wrote it I didn't set the maxDistances very low so all nodes would send a value. It's annoying that you need maxDistances to make Home Assistant work right, but it kills this use case. That's part of why I send both room and devices. I want to make one the unfiltered view of all data, and the other is specifically for HA. Either that or just use the AppDaemon app to do the job of mqtt room since it doesn't really work all that well. Oh and if you're not using ESPresence you don't have the really nice kalman filtering, right?

DTTerastar avatar Sep 23 '21 05:09 DTTerastar

I think last updated filtering instead of Max distance would be useful- what I saw without it was that old values would contaminate current position whether that testing was high or low. I have 10 base stations over a fairly large area so it's not unusual to walk out of range of a device while it's still reporting as 'close'.

Oh and room assistant uses Kalman filtering too, will be interesting to see how well the espsence and room assistant stations play together.

Would you happy with me doing a small PR to add an 'updatedWithin' property, defaulting to existing behaviour of not being used?

Alfiegerner avatar Sep 23 '21 07:09 Alfiegerner

Should I see a new topic generated by this appdaemon? How do I confirm this is working fine?

(Sorry for the probably dumb question)

ee02217 avatar Sep 28 '21 10:09 ee02217

It reads from espresense/rooms and writes to espresense/ips and espresense/location.

DTTerastar avatar Sep 28 '21 13:09 DTTerastar

It doesn't show up for me. But I don't see any error in logs :(

ee02217 avatar Sep 28 '21 14:09 ee02217

Can you post the redacted apps.yml?

DTTerastar avatar Sep 28 '21 14:09 DTTerastar

Here you go. I still dont have the 3rd base station, maybe that is the problem. But I expected some errors at least.

~/appdaemon$ more appdaemon.yaml

appdaemon:
  time_zone: Europe/Lisbon
  latitude: 38.XXXXXXX
  longitude: -9.YYYYYY
  elevation: 60
  plugins:
    HASS:
      type: hass
      ha_url: "http://192.168.1.XXX:8123"
      token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
      app_init_delay: 30
      appdaemon_startup_conditions:
        delay: 30
    MQTT:
      type: mqtt
      client_host: 192.168.1.XXX
      namespace: mqtt
      birth_topic: appdaemon
      will_topic: appdaemon

http:
  url: "http://192.168.1.XXX:5050"
admin:
api:
hadashboard:


logs:
  main_log:
    filename: /home/ee02217/appdaemon/logs/appdaemon.log
  access_log:
    filename: /home/ee02217/appdaemon/logs/access.log
  error_log:
    filename: /home/ee02217/appdaemon/logs/error.log
  diag_log:
    filename: /home/ee02217/appdaemon/logs/diag.log
    log_generations: 5
    log_size: 1024
    format: "{asctime} {levelname:<8} {appname:<10}: {message}"
  test_log:
    name: TestLog
    filename: /home/ee02217/appdaemon/logs/test.log

ee02217@NUC:~/appdaemon/apps$ more apps.yaml

ESPresenseIps:
  module: espresense-ips
  class: ESPresenseIps
  pluggins:
    - HASS
    - MQTT
  rooms:
    livingroom: [1, 0.5, 0]
    bedroom: [16, 3.5, 0]
  devices:
  - id: apple:ZZZZ:X-YY
    name: AppleWatch_Sergio
    timeout: 30
    away_timeout: 120

ee02217 avatar Sep 28 '21 14:09 ee02217

Ahh yeah, that's it. From the README: 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). We need futher work to actually determine if the item is actually in a particular room (we'll need some kind of floorplan).

DTTerastar avatar Sep 28 '21 14:09 DTTerastar

Trilateration requires 3 to do be able to find the location. It really needs more like 4 or 5 to do a decent job with all of error present in rssi measurements.

DTTerastar avatar Sep 28 '21 14:09 DTTerastar

Oh man... really sorry! I just expected some error or something (this is my first adventure in the appdaemon)

Just a final confirmation, I read the above conversation, and I'll need to increase the Max Distance to the max?

ee02217 avatar Sep 28 '21 14:09 ee02217

I don't log anything for that case atm because it happens pretty often and would just clog the logs. I could add a periodic stats print out to help people tho. Good idea.

DTTerastar avatar Sep 28 '21 14:09 DTTerastar

MaxDistance 0 does no filtering. Atm is does help to set the maxDistance higher than your otherwise would. This is all VERY beta. I'd like to make maxDistance only apply to the mqtt room topic and use another topic so we get all the data.

DTTerastar avatar Sep 28 '21 17:09 DTTerastar

Completely understand. And very keen to help you test this. Already ordered two more esp32 :) Biggest problem where I’m from is that walls really mess up signals (concrete). I already have my home 3D map ready for experiences :D

ee02217 avatar Sep 28 '21 22:09 ee02217

Completely understand. And very keen to help you test this. Already ordered two more esp32 :) Biggest problem where I’m from is that walls really mess up signals (concrete). I already have my home 3D map ready for experiences :D

Sweet! I need the help!

DTTerastar avatar Sep 29 '21 00:09 DTTerastar

OK, maybe I need another cup of coffee before I attempt to wrap my head around this. So we're plotting X,Y,Z coordinates, I got that. How do I determine what is correct? How do I figure X and Y? Z is height in meters, but the others?

dmccabe79 avatar Oct 02 '21 12:10 dmccabe79

Has anyone noticed the amount of RAM this is using to bee quite high?

ee02217 avatar Oct 02 '21 17:10 ee02217

OK, maybe I need another cup of coffee before I attempt to wrap my head around this. So we're plotting X,Y,Z coordinates, I got that. How do I determine what is correct? How do I figure X and Y? Z is height in meters, but the others?

X and Y are also meters. You gotta have a floor plan and measure where the base stations are in relation to each other.

DTTerastar avatar Oct 02 '21 23:10 DTTerastar

Has anyone noticed the amount of RAM this is using to bee quite high?

I haven't. Does it continuously increase like a memory leak?

DTTerastar avatar Oct 02 '21 23:10 DTTerastar

OK, maybe I need another cup of coffee before I attempt to wrap my head around this. So we're plotting X,Y,Z coordinates, I got that. How do I determine what is correct? How do I figure X and Y? Z is height in meters, but the others?

X and Y are also meters. You gotta have a floor plan and measure where the base stations are in relation to each other.

Do you have a recommended means of doing this?

dmccabe79 avatar Oct 03 '21 00:10 dmccabe79

I estimated mine using a thing like this: https://amzn.to/3uDLcLl

Eventually i'd like to have some sort of gps attachment, or phone app to figure it out.

DTTerastar avatar Oct 03 '21 00:10 DTTerastar

I could probably figure it out by just walking the area. X and Y might be tricky to calculate. Z is the easy one

dmccabe79 avatar Oct 03 '21 00:10 dmccabe79