The error is definitely caused by its inability to import paho. There are two ways to install a python library, globally or for the specific user. You might be installing it as a specific user but sensorReporter is running as a different user and that user doesn’t have paho available.
If you are not going to use sensorReporter (I’d recommend reelyActive instead anyway) don’t worry about an issue. I think the problem is a configuration problem, not something I can fix in code anyway.
Make socat run in docker either by sharing device (not possible because socat use symlink). I tried with privileged to true to eliminate any isolated issue. I try to make run as a service. But exemple was given with Systemd which is a pain to make running in docker at least for me.
Let’s say I went to the docker machine and manually start socat with the necessary configuration. I tried to run the Bluetooth python tool to check it works. It is looking good. But then come openhab third party Bluetooth binding where I set the device path directly instead of general regex. But the adapter I manually add stay offline. I can share the log when back to my computer.
I am taking any advice, really interested to make raspberry pi gateway using ser2ner…
PS: Location exact is only a bonus. Main purpose is like the first post shared, to be able to have deported Bluetooth or zwave using raspberry pi.
If you want to run this inside Docker you are going to have to get good at building your own custom Docker images. If you are using the official OH dinner image you need to added installation of all the stuff you need and add starting the socat stuff to entrypoint.sh. Docker images, almost as a rule, do not include systemd or upstart.
I firmly believe that pretty much every other suggestion in this thread will be less work to get working than getting socat and the Bluetooth binding working in Docker.
I believe as well that the other solutions are easier. But won’t work if I want to connect other devices.
But with perseverance I now able to run socat and openhab thanks to supervisord in the container. Openhab run but cannot connect to the bluetooth when this works within the container:
root@NAS:/openhab# ./bled112_scanner.py -p /dev/ttyNET0
================================================================
BLED112 Scanner for Python v2013-04-07
================================================================
Serial port: /dev/ttyNET0
Baud rate: 115200
Scan interval: 200 (250.00 ms)
Scan window: 200 (250.00 ms)
Scan type: Passive
UUID filters: None
MAC filter(s): None
RSSI filter: None
Display fields: - Time
- RSSI
- Packet type
- Sender MAC
- Address type
- Bond status
- Payload data
Friendly mode: Disabled
----------------------------------------------------------------
Starting scan for BLE advertisements...
Does not find anything but at least no errors.
And I have this in the container:
root@NAS:/openhab# ls -al /dev/ttyNET0
lrwxrwxrwx 1 root root 10 Jun 26 01:59 /dev/ttyNET0 -> /dev/pts/0
while writing it I realise it creates it under root:root… I specified openhab:dialout in socat command there: (still work if I login as openhab and run ./bled112_scanner.py -p /dev/ttyNET0
But on openhab side with the third party bluetooth binding I get the following:
01:52:48.903 [WARN ] [er.transport.bluegiga.BluegigaHandler] - Timeout has happened while sending a transaction, retry one more time: BlueGigaEndProcedureCommand
01:52:58.904 [WARN ] [er.transport.bluegiga.BluegigaHandler] - Timeout has happened second time, giving up: BlueGigaEndProcedureCommand
01:52:58.931 [WARN ] [er.transport.bluegiga.BluegigaFactory] - Error occurred while creating a new adapter for port: /dev/ttyNET0, Could not initialize blugiga handler for port: /dev/ttyNET0
On the pi the netstat command gives
tcp6 233 0 192.168.178.84:3001 192.168.178.29:35734 ESTABLISHED -
reelActive has a central server and clients. Each client uses its own BT device and reports the signal strength of all the BT devices that it sees. The server looks at all the reports from all the clients and reports to OH which client has the strongest signal and therefore telling you which room the BT device is in. It solves EXACTLY your problem.
Similarly, sensorReporter is designed to run on more than one Raspberry Pi (or other computers) and report to OH when it can see a BT device. Slight modifications will let it report the RSSI (I’d even make the modifications for you). So sensorReporter nearly solves EXACTLY your problem, though determining which RPi the BT device is closest to will have to be done by Rules.
Somewhat differently, FIND triangulates the location of your phone based on the signal strength of all the wifi APs the phone can see. So this solves your problem, but uses wifi instead of BT.
There is no limitation to connecting to only one BT device in ANY of these solutions.
Just so you know guys @rlkoshak@clempat, the 3rd party bluetooth binding is supposed to do indoor positioning as well. It accumulates RSSI readings from all adapters and calculates shortest distance from bt device to installed adapters. Obviously you will need to have an adapter in each room.
Do you really use a BlueGiga Adapter? and did you get data on your raspi zero? I have the strong feeling, that the onboard bluetooth ist a generic bluetooth device and with this ser2net will not work.
Sorry I meant for exemple I have a Bluetooth temperature Sensor (Xiaomi). I would be interested to get the data from it instead of the signal and the presence. And for this reason I would need to use the Bluetooth binding solution.
@vkolotov As you are here. First thanks for the awesome work you did for the Bluetooth binding. Here is how I stand now:
I have a raspberry pi zero with ser2net exposing the serial I think is the built in Bluetooth.
I have a machine with docker and running socat and openhab. I made a custom image for that here: https://hub.docker.com/r/clempat/openhab-socat/
I see /dev/tryNET0 as said in my last message. Is the 3rd party Bluetooth integration a solution for me or I need to look somewhere else ?
hi @clempat, the internal bluetooth adapter is not serial port based device (unlike BlueGiga devices). You will have to use something different rather than ser2net, that allows you to create a virtual usb port over ip.
Hello, i could not have it work. As deported solution I did have one success with zwave but not the Bluetooth. I don’t remember where I was blocking. I am now using mqtt solutions…