ESPresense / ad-espresense-ips

DEAD: See https://github.com/ESPresense/ESPresense-companion
64 stars 9 forks source link

Help! Getting confused over coordinates #10

Closed jimmyeao closed 2 years ago

jimmyeao commented 2 years ago

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: ------------------------------------------------------------
KuotenoAshiato commented 2 years ago

You need to define the name in roomplans as name: <name> Also there could be an issue because you're not using - in the roomplan section so instead of:

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

use:

roomplans: 
- name: backhall
  y1: 20.0
  x1: 0.0
  y2: 22.0
  x2: 2.0
- name: bedroom
  y1: 20.0
  x1: 2.0
  y2: 23.0
  x2: 5.0
jimmyeao commented 2 years ago

Wow, how did I miss that! Thanks, at least the app isn't crashing anymore :)