BLE detecting script

  • Platform information:
    • Hardware: _Raspberry Pi3
    • OS: openhabian (latest version)
    • Java Runtime Environment: zulu (latest version)
    • openHAB version: 2.3

Hello everybody,

I have after a long time, a lot of playing around and testing my system completely reinstalled.

So far everything works and with a better performance.

However, I still have a problem, I had my “Gigaset tag” controlled by a script. This returned an ON or OFF to the item “nog_tag”.

Since reinstalling, it is not working anymore. It is always attached that the “tag” is not present.
if i start the “hcitool lescan” i see the “tag”.

#!/usr/bin/python

import bluetooth
import time
import requests
from requests.exceptions import ConnectionError

payload =''

while True:
    print "Checking " + time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime())
    result = bluetooth.lookup_name('78:7F:70:38:51:1B', timeout=5)
	
    if (result != None and payload!='ON'):
        print "User present"
	payload ='ON'
	try:
		r = requests.put("http://localhost:8080/rest/items/nog_tag/state",data=payload)
	except ConnectionError as e:
		print e
		r = "No Response"
		payload = ''
    elif (payload != 'OFF' and result == None):
        print "User out of range"
	payload ='OFF'
	try:
		r = requests.put("http://localhost:8080/rest/items/nog_tag/state",data=payload)
	except ConnectionError as e:
		print e
		r = "No Response"
		payload = ''
    time.sleep(10)

I hope anybody can help :slight_smile:

Why not use @vkolotov Vlads Bluetooth binding. I’m detecting things allegations over the place