Comparing distances

Posted on
Wed Dec 05, 2018 2:30 pm
new2me07 offline
Posts: 30
Joined: Apr 07, 2017

Comparing distances

First off thanks for all the time and effort on a great plugin!

I only have on rPI at the moment and I simply want to run a conditional action based on who is closer to said rPi. I imagine it will have to be script based and wondering if I should use txpowerreceived or Pi_0_Distance or something else?

Its a big PITA as the rPi I completely out of range of indigo so I can't really see anything real time, and I'm ok at modifying python, not so much its creation....

For reference I have a dummy switch connected to an aeotec microswitch that I use to set my receiver to Speaker B output, source as Apple TV, and airplay the shuffled "bathroom" playlist. I'd like to have it specific to who ever hits the switch. It's pretty much the highest WAF rating I've ever gotten with automation.

Posted on
Thu Dec 06, 2018 7:50 am
kw123 offline
User avatar
Posts: 6023
Joined: May 12, 2013
Location: Dallas, TX

Re: Comparing distances

txpowerreceived or Pi_0_Distance:
distance is calculated from signalreceived and txPower:
Code: Select all
dist =  sqrt( 10**(  (txPower-rssi)/10 )  )
you can find discussion on how to calculate it on the web at many places.

"rPi is completely out of range of indigo", what does this mean : far away, not connected ..?

If you want to know which iBeacon is closest, yes currently you have to do this yourself. with triggers for each ibeacon and then rank the ibeacons.. But that is actually a good idea to add.

Give me a day. I can add a field that gives the device name of the closest ibeacon.

Q: what if no beacon is connected = all gone: should it keep that last name or make it blank? or "none"

Karl

[edit]
was easy to add..
next Q: should there be a cut off in distance: ie if distance > 10m (= not in room) ignore?
and should it be a parameter for each RPI or same for all?

Posted on
Thu Dec 06, 2018 10:57 am
kw123 offline
User avatar
Posts: 6023
Joined: May 12, 2013
Location: Dallas, TX

Re: Comparing distances

here some screen shots:
1. RPI device edit
Screen Shot 2018-12-06 at 10.48.06.png
Screen Shot 2018-12-06 at 10.48.06.png (11.2 KiB) Viewed 73 times

2. RPI device state:
Screen Shot 2018-12-06 at 10.47.51.png
Screen Shot 2018-12-06 at 10.47.51.png (4.26 KiB) Viewed 73 times


you can get the device name ... w:
Code: Select all
      yyyy = indigo.devices["name of your rpi"].states
      xxx = yyyy["closestiBeacon"]
      if xxx.find("@")>-1: 
         nameOfBeacon = xxx.split("@")[0]
         distToRPI    = float(xxx.split("@")[1])
         indigo.server.log(" closest beacon to RPi is "+nameOfBeacon+" at distance of "+str(distToRPI))
         # do something with dist
         if distToRPI < 3:
            indigo.server.log("beacon is very close" )
      else:
         indigo.server.log("no iBeacon is close" )


will publish later today . still need to do some testing and optimizing

Karl

Posted on
Thu Dec 06, 2018 6:16 pm
kw123 offline
User avatar
Posts: 6023
Joined: May 12, 2013
Location: Dallas, TX

Re: Comparing distances

@new2me07 check out the latest release v7.97.252. It should do everything you requested.

Karl

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest