How to check presence of Beacon ?

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Post by jmleglise »

So the second time it's working. Log : tag detected

And i understand : it's normal that it doesnt work after a reboot as the dongle has to be activated by a :
sudo hciconfig hci0 up

I need to find a way to auto run this hciconfig up
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
User avatar
blackdog65
Posts: 311
Joined: Tuesday 17 June 2014 18:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norfolk, UK
Contact:

Re: How to check presence of Beacon ?

Post by blackdog65 »

Hi guys,

I've now run out of RasPis, wifi dongles, and BLE dongles... but I have 4 "Monitoring Stations" around the house which is starting to form a very crude "Indoor GPS". :ugeek:

The plan is to use the following... logic :lol:
if Office = On then set DriveLamp On
if Office & Library = On set CourtyardLamp On
if Library & SittingRm = On set PorchInternal & Porchexternal On & DriveLamp Off
if SittingRm & Hall = On set CourtyardLamp off
... etc

Mrs Blackdog very pleased to see something useful :roll:

However, it all falls apart without it all running as a service from reboot.

I wish there was some way I could help (other than testing) as this is the 2nd most critical part (after heating control) of my Domoticz :shock:

Mega thanks to all involved with this

Sean
CubieTruck Master
RasPi slaves
Aeon Labs Z-Stick, multi sensor
Fibaro Dimmers, relays, Universal sensors
EQ3 MAX!
TKB Sockets
RFXCOM
LightwaveRF sockets, switches, relays, doorbell
MySensors
ESPEasy ESP8266-12E
jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Post by jmleglise »

whoua, I have great pressure on my shoulders :-)

I will look after that this week-end. And I have no doubt I will found a way to autorun at linux boot.


The dirty solution is to launch at startup :
the hciconfig command to enable the BLE dongle
then the python script with &

the better solution is to finish the service script.

If you are in a hurry, you can search :
https://www.google.fr/search?q=autorun+ ... &ie=UTF-8
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
User avatar
blackdog65
Posts: 311
Joined: Tuesday 17 June 2014 18:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norfolk, UK
Contact:

Re: How to check presence of Beacon ?

Post by blackdog65 »

jmleglise wrote:whoua, I have great pressure on my shoulders :-)

I will look after that this week-end. And I have no doubt I will found a way to autorun at linux boot.
We have faith in you ;) you have done fantastic work so far :D
The dirty solution is to launch at startup :
the hciconfig command to enable the BLE dongle
then the python script with &
Yeah.... I'm now doing this on 4 (maybe more soon) RasPis :lol:
the better solution is to finish the service script.

If you are in a hurry, you can search :
https://www.google.fr/search?q=autorun+ ... &ie=UTF-8
I most certainly will, (though on google.co.uk until the Soviet Union of Europe dictates that we all use Google.eu) but I'm not a coder, but I'll research and try :D

Many thanks for your work so far

Sean
CubieTruck Master
RasPi slaves
Aeon Labs Z-Stick, multi sensor
Fibaro Dimmers, relays, Universal sensors
EQ3 MAX!
TKB Sockets
RFXCOM
LightwaveRF sockets, switches, relays, doorbell
MySensors
ESPEasy ESP8266-12E
User avatar
blackdog65
Posts: 311
Joined: Tuesday 17 June 2014 18:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norfolk, UK
Contact:

Re: How to check presence of Beacon ?

Post by blackdog65 »

Sill getting this

Code: Select all

pi@Kitchen ~ $ sudo /etc/init.d/check_beacon_presence start
[ ok ] Starting check_beacon_presence:.
pi@Kitchen ~ $ sudo /etc/init.d/check_beacon_presence status
[FAIL] check_beacon_presence is not running ... failed!
pi@Kitchen ~ $ 
Whatever I try, I just can't get this part running
CubieTruck Master
RasPi slaves
Aeon Labs Z-Stick, multi sensor
Fibaro Dimmers, relays, Universal sensors
EQ3 MAX!
TKB Sockets
RFXCOM
LightwaveRF sockets, switches, relays, doorbell
MySensors
ESPEasy ESP8266-12E
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: How to check presence of Beacon ?

Post by woody4165 »

Strange, because I get another kind of error

when I start from reboot either if set pi or root as user in the /etc/init.d/check_beacon_presence I get this

Code: Select all

● check_beacon_presence.service - LSB: This daemon manages the bluetooth low energy device detector : check_beacon_presence
   Loaded: loaded (/etc/init.d/check_beacon_presence)
   Active: active (exited) since mer 2016-05-11 14:02:43 CEST; 29s ago
  Process: 368 ExecStart=/etc/init.d/check_beacon_presence start (code=exited, status=0/SUCCESS)

mag 11 14:02:42 raspberrypi check_beacon_presence[368]: Starting check_beacon...
mag 11 14:02:43 raspberrypi systemd[1]: Started LSB: This daemon manages the....
Hint: Some lines were ellipsized, use -l to show in full.
If I then stop and start again, if I have pi as user I get again the same status, if I have root as user I get

Code: Select all

● check_beacon_presence.service - LSB: This daemon manages the bluetooth low energy device detector : check_beacon_presence
   Loaded: loaded (/etc/init.d/check_beacon_presence)
   Active: active (running) since mer 2016-05-11 14:05:22 CEST; 2s ago
  Process: 1008 ExecStop=/etc/init.d/check_beacon_presence stop (code=exited, status=0/SUCCESS)
  Process: 1102 ExecStart=/etc/init.d/check_beacon_presence start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/check_beacon_presence.service
           └─1109 /usr/bin/python /usr/local/bin/check_beacon_presence.py

mag 11 14:05:22 raspberrypi systemd[1]: Started LSB: This daemon manages the....
mag 11 14:05:22 raspberrypi check_beacon_presence[1102]: Starting check_beaco...
I've never got the FAIL message...
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: How to check presence of Beacon ?

Post by woody4165 »

I've tried a couple of solution found googling:

Code: Select all

sudo crontab -u root -e
And add the following to it:

Code: Select all

@reboot hciconfig hci0 up 
Creating new file /etc/udev/rules.d/10-local.rules

Code: Select all

# Set bluetooth power up
ACTION=="add", KERNEL=="hci0", RUN+="/usr/local/bin/hciconfig hci0 up"
but none of them worked.

:?
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: How to check presence of Beacon ?

Post by woody4165 »

I correct myself.

This way it's working, maybe it's a workaround....

Code: Select all

crontab -e
and add this line

Code: Select all

@reboot sudo -u root hciconfig hci0 up
Let me know if it's working also for you
In any case the DAEMON user in /etc/init.d/check_beacon_presence needs to be root
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
User avatar
blackdog65
Posts: 311
Joined: Tuesday 17 June 2014 18:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norfolk, UK
Contact:

Re: How to check presence of Beacon ?

Post by blackdog65 »

You beauty! :D

Code: Select all

pi@Office ~ $ sudo /etc/init.d/check_beacon_presence status
[ ok ] check_beacon_presence is running.
Now to update the other 3 units and I'm away and running.

Many thanks for the tips

My second NUT arrived today too so I've been testing my pseudo-GPS. Unfortunately, one of my RasPis is having problems sending json commands to the master Domoticz :twisted: strange fault but I now have a BT_RaspI.img for quick set up. Just change hostname & uservariable details and they fire up straight away.

Thanks again

Sean
CubieTruck Master
RasPi slaves
Aeon Labs Z-Stick, multi sensor
Fibaro Dimmers, relays, Universal sensors
EQ3 MAX!
TKB Sockets
RFXCOM
LightwaveRF sockets, switches, relays, doorbell
MySensors
ESPEasy ESP8266-12E
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: How to check presence of Beacon ?

Post by Westcott »

Big thanks to whoever wrote the Python script!
My Avvel Ranger Eddystone long-range beacon arrived today.
It works, and is detected by hcitool and the Python script.
I've tweaked the script to update a virtual switch rather than a user variable.
Now to test the beacon's range. It will go in my car.

I need to use this quite frequently -
sudo hciconfig hci0 reset
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: How to check presence of Beacon ?

Post by woody4165 »

Can you share the switch tweak?
What are you using for in the car, if I can ask you?
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: How to check presence of Beacon ?

Post by Westcott »

Hi Woody,

It's so that things get switched on when my car arrives home.
I haven't updated the code comments-

Code: Select all

#!/usr/bin/python
#   File : check_beacon_presence.py
#   Author: jmleglise
#   Date: 06-May-2016
#   Info: Beacon (BlueTooth Low Energy V4.0) detection and reports back to domoticz
#   URL : https://github.com/jmleglise/mylittle-domoticz/edit/master/Presence%20detection%20%28beacon%29/check_beacon_presence.py
#   Version : 1.0
#   Version : 1.1   Log + Mac Adress case insensitive 
#   Version : 1.2   Fix initial state for Tag Away
#
# Feature : 
# Check the presence of a list of beacon and update uservariables in Domoticz accordingly. 
# When the MACADRESS of the beacons are detected, send "HOME". And send "AWAY" when the beacons are not in range.
# The detection is very fast : around 4 seconds. And the absence is verified every 15 seconds by comparing the hour of the last presence.
#
# References :
# https://wiki.tizen.org/wiki/Bluetooth
# https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/pybluez/source-archive.zip  => pybluez\examples\advanced\inquiry-with-rssi.py
#
# Required in Domoticz : An uservariable of type String for each BLE Tag
#
# Configuration :
# Change your IP and Port here :
URL_DOMOTICZ = 'http://127.0.0.1:8080/json.htm?type=command&param=switchlight&idx=PARAM_IDX&switchcmd=PARAM_CMD'
#
# Configure your Beacon here : 
# [Name,MacAddress,Timeout,0,idx,mode]
# Name : same as the uservariable in Domoticz
# Timeout is in seconds the elapsed time  without a detetion for switching the beacon AWAY. Ie :if your beacon emits every 3 to 8 seondes, a timeout of 15 secondes seems good.
# 0 : used by the script (will keep the time of the last broadcast) 
# idx of the uservariable in Domoticz for this beacon
# mode : 0 for 1 update per status change / 1 continuous updating

TAG_DATA = [  
           ["Hamish beacon","7C:EC:79:62:8C:AD",15,0,529]
           ]

           
import logging

# choose between DEBUG (log every information) or CRITICAL (almost no log)
logLevel=logging.DEBUG
#logLevel=logging.CRITICAL

#logOutFilename='/var/log/check_beacon_presence.log'       # comment this line to console output
ABSENCE_FREQUENCY=5
################ Nothing to edit under this line #####################################################################################


import os
import sys
import struct
import bluetooth._bluetooth as bluez
import time
import requests
import signal
import threading



LE_META_EVENT = 0x3e
OGF_LE_CTL=0x08
OCF_LE_SET_SCAN_ENABLE=0x000C
EVT_LE_CONN_COMPLETE=0x01
EVT_LE_ADVERTISING_REPORT=0x02

def print_packet(pkt):
    for c in pkt:
        sys.stdout.write("%02x " % struct.unpack("B",c)[0])

def packed_bdaddr_to_string(bdaddr_packed):
    return ':'.join('%02x'%i for i in struct.unpack("<BBBBBB", bdaddr_packed[::-1]))

def hci_disable_le_scan(sock):
    hci_toggle_le_scan(sock, 0x00)

def hci_toggle_le_scan(sock, enable):
    cmd_pkt = struct.pack("<BB", enable, 0x00)
    bluez.hci_send_cmd(sock, OGF_LE_CTL, OCF_LE_SET_SCAN_ENABLE, cmd_pkt)

def handler(signum = None, frame = None):
    time.sleep(1)  #here check if process is done
    sys.exit(0)   
    
for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]:
    signal.signal(sig, handler)

def request_thread(idx,cmd, name):
    try:
        url = URL_DOMOTICZ
        url=url.replace('PARAM_IDX',str(idx))
        url=url.replace('PARAM_CMD',str(cmd))
        url=url.replace('PARAM_NAME',str(name))
        result = requests.get(url)
        logging.debug(" %s -> %s" % (threading.current_thread(), result))
    except requests.ConnectionError, e:
        logging.warning(' %s Request Failed %s - %s' % (threading.current_thread(), e, url) )

class CheckAbsenceThread(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
    def run(self):

        while True:
            time.sleep(ABSENCE_FREQUENCY)
            for tag in TAG_DATA:
                elapsed_time_absence=time.time()-tag[3]
                if elapsed_time_absence>tag[2] and elapsed_time_absence<(tag[2]+ABSENCE_FREQUENCY) :  #update when > timeout ant only 1 time , before the next absence check [>15sec <30sec]
                    logging.debug('Tag %s not seen since %i sec => update absence',tag[0],elapsed_time_absence)
                    threadReqAway = threading.Thread(target=request_thread,args=(tag[4],"Off",tag[0]))
                    threadReqAway.start()

devId = 0
FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
if globals().has_key('logOutFilename') :
    logging.basicConfig(format=FORMAT,filename=logOutFilename,level=logLevel)
else:
    logging.basicConfig(format=FORMAT,level=logLevel)

try:
    sock = bluez.hci_open_dev(devId)
    logging.info('Connect to bluetooth device %i',devId)
except:
    logging.debug('Unable to connect to bluetooth device...')
    sys.exit(1)

old_filter = sock.getsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, 14)
hci_toggle_le_scan(sock, 0x01)


for tag in TAG_DATA:
    tag[3]=time.time()
    



th=CheckAbsenceThread()
th.daemon=True
th.start()

while True:
    old_filter = sock.getsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, 14)
    flt = bluez.hci_filter_new()
    bluez.hci_filter_all_events(flt)
    bluez.hci_filter_set_ptype(flt, bluez.HCI_EVENT_PKT)
    sock.setsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, flt )
    
    pkt = sock.recv(255)
    ptype, event, plen = struct.unpack("BBB", pkt[:3])

    if event == bluez.EVT_INQUIRY_RESULT_WITH_RSSI:
        i =0
    elif event == bluez.EVT_NUM_COMP_PKTS:
        i =0 
    elif event == bluez.EVT_DISCONN_COMPLETE:
        i =0 
    elif event == LE_META_EVENT:
        subevent, = struct.unpack("B", pkt[3])
        pkt = pkt[4:]
        if subevent == EVT_LE_CONN_COMPLETE:
            le_handle_connection_complete(pkt)
        elif subevent == EVT_LE_ADVERTISING_REPORT:
            num_reports = struct.unpack("B", pkt[0])[0]
            report_pkt_offset = 0
            for i in range(0, num_reports):
                #logging.debug('UDID: ', print_packet(pkt[report_pkt_offset -22: report_pkt_offset - 6]))
                #logging.debug('MAJOR: ', print_packet(pkt[report_pkt_offset -6: report_pkt_offset - 4]))
                #logging.debug('MINOR: ', print_packet(pkt[report_pkt_offset -4: report_pkt_offset - 2]))
                #logging.debug('MAC address: ', packed_bdaddr_to_string(pkt[report_pkt_offset + 3:report_pkt_offset + 9]))
                #logging.debug('Unknown:', struct.unpack("b", pkt[report_pkt_offset -2])) # don't know what this byte is.  It's NOT TXPower ?
                #logging.debug('RSSI: %s', struct.unpack("b", pkt[report_pkt_offset -1])) #  Signal strengh !
                macAdressSeen=packed_bdaddr_to_string(pkt[report_pkt_offset + 3:report_pkt_offset + 9])
                #logging.debug('Tag Detected %s - RSSI %s - DATA %s', macAdressSeen, struct.unpack("b", pkt[report_pkt_offset -1]),struct.unpack("b", pkt[report_pkt_offset -2])) #  Signal strenght !
                for tag in TAG_DATA:
                    if macAdressSeen.lower() == tag[1].lower():  # MAC ADDRESS
                        #logging.debug('It is tag: %s', tag[0])
                        elapsed_time=int(time.time()-tag[3])  # lastseen
                        # if mode = continuous and elapsed_time>2seconde   # continuous mode
                        # or mode= not continous and elapsed_time >tag[2] 
                        if elapsed_time>tag[2]: # >timeout
                            threadReqHome = threading.Thread(target=request_thread,args=(tag[4],"On",tag[0]))
                            threadReqHome.start()
                            logging.debug('Tag %s seen after an absence of %i sec : update presence',tag[0],elapsed_time)
                        tag[3]=time.time()   # update lastseen
                                    
    sock.setsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, old_filter )
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: How to check presence of Beacon ?

Post by woody4165 »

Thanks
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
User avatar
blackdog65
Posts: 311
Joined: Tuesday 17 June 2014 18:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norfolk, UK
Contact:

Re: How to check presence of Beacon ?

Post by blackdog65 »

I like the idea of operating a switch directly. I'd be interested to know why a variable was used in the 1st instance? Is it because it has more versatility for use in a scripts? Hmmm... beyond my old brain :lol:

Anyhoo, @Westcott that's exactly my usage. I live in a big old farm house in the middle of... well nothing, so I want lights to come on when I come onto my drive, followed by the end of house and parking area lights, followed by the courtyard, porch and inner hall lights... as the other lights go off behind me. How cool will that make me feel? :ugeek:
CubieTruck Master
RasPi slaves
Aeon Labs Z-Stick, multi sensor
Fibaro Dimmers, relays, Universal sensors
EQ3 MAX!
TKB Sockets
RFXCOM
LightwaveRF sockets, switches, relays, doorbell
MySensors
ESPEasy ESP8266-12E
User avatar
blackdog65
Posts: 311
Joined: Tuesday 17 June 2014 18:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norfolk, UK
Contact:

Re: How to check presence of Beacon ?

Post by blackdog65 »

@Westcott,
Hi, which parts of the script did you change? I see the change to the json command and the use of the switch idx in the TAG_DATA, but are there any other changes that I've missed?

Many thanks

Sean
CubieTruck Master
RasPi slaves
Aeon Labs Z-Stick, multi sensor
Fibaro Dimmers, relays, Universal sensors
EQ3 MAX!
TKB Sockets
RFXCOM
LightwaveRF sockets, switches, relays, doorbell
MySensors
ESPEasy ESP8266-12E
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: How to check presence of Beacon ?

Post by Westcott »

Lines 110 and 181 in my version send 'Off' and 'On'
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
User avatar
blackdog65
Posts: 311
Joined: Tuesday 17 June 2014 18:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norfolk, UK
Contact:

Re: How to check presence of Beacon ?

Post by blackdog65 »

Gotcha, many thanks again. :D
I hope the direct route will be slightly quicker responding too
CubieTruck Master
RasPi slaves
Aeon Labs Z-Stick, multi sensor
Fibaro Dimmers, relays, Universal sensors
EQ3 MAX!
TKB Sockets
RFXCOM
LightwaveRF sockets, switches, relays, doorbell
MySensors
ESPEasy ESP8266-12E
jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Post by jmleglise »

I choose uservariable because :
- the script is aimed to be convenient for multiple beacon. And a lot of switch is not very userfriendly in the interface.
- the "presence" is most an information (so a variable) to use in other script. Not very usefull standalone.

uservariable is very easy to use.



I read than you plan to light several lamp depending of the beacon.
Did you notice , that you can have the strength of the signal of the beacon. (called RSSI in the script). With that, you can deduct easely the distance of the beacon.

And with more work, (and 3 RPi), you could triangulate the position of the beacon. It's more difficult ...
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
User avatar
blackdog65
Posts: 311
Joined: Tuesday 17 June 2014 18:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norfolk, UK
Contact:

Re: How to check presence of Beacon ?

Post by blackdog65 »

yes, I'd seen the RSSI in the log and was hoping to use it (assuming my IQ goes up by 30 points soon :lol: )

I now have 2 tags (me + wife) and 4 raspi/bt sets. 3 work fine but one is a bt temperamental and needs a manual start each time. Plus, that one sees my tag but not my wife's... I think I need another install on it. :roll:

So... using a variable is the more practical option within a complex script. Makes sense to me.

As to the RSSI, it doesn't appear to be linear i.e. if max range = 1 and min range = 100 but half way isn't 50. However, with a bit of trial and error, I think key way-points can be created i.e.
WayPoint_1 = (RSSI_1 = 52 to 57) + (RSSI_2 = 25 to 30) + (RSSI_3 = 78 to 82) = "Standing by garage door"

I assume the RSSI data can also be used to update an additional variable for the script.

Sean
CubieTruck Master
RasPi slaves
Aeon Labs Z-Stick, multi sensor
Fibaro Dimmers, relays, Universal sensors
EQ3 MAX!
TKB Sockets
RFXCOM
LightwaveRF sockets, switches, relays, doorbell
MySensors
ESPEasy ESP8266-12E
woody4165
Posts: 476
Joined: Monday 14 March 2016 13:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: How to check presence of Beacon ?

Post by woody4165 »

Just to understand, what is the advantage or needs of having Domoticz installed on multiple RPis instead of only one?
Sorry for the small OT
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest