3rd Party Bluetooth Binding. Beta testers needed

Hi,
I am currently trying to setup my Xiaomi Mijia Bluetooth Temperature Smart Humidity Sensors with my Raspberry with Openhab. I could successfully install the binding. I already had Bluez 5.43 (5.43-2+rpt2+deb9u2) installed (seems was part of Raspbian 4.14).

Now my issue is I can not find the bluetooth deviceses. I tried the bluetoothctl tool and scan and hcitool lescan but can not find the devices (only the controller).

Can someone help me?

Hello, just set up this binding on my RPI3, works butifly with my one+ phone :star_struck:. I would like to put a adapter in every room to use indoor positioning, but I don’t know (understand) how to go about it :thinking:. Wich devices could i use as an adapter? If i use usb ble sticks i would have to connect them via usb to the pi and its not very convenient to place usb cables all over the house. If I use seperate RPI’s, how can i get the data into the pi thats running openhab? Is there a (ready-made) wireless solution for this? It would be nice if all adapters could act like some sort of mesh network (dont know if this is possible). Just dont know how best to tackle this. Any help would be much appreciated. :grin:

I found something like this, but question is can it be integrated with the binding?

So what i am actually looking for is a gateway i can plug into my RPI (openhab server) that connects (via wifi, or other wireless protocol) to to other BLE receivers that are spread around the house. So every BLE receiver can send its data over wifi to the gateway, wich sends all data via usb to open hab. Is this even possible? And usable for indoor positioning?

Is there a way to limit the polling for some of the devices? I may be confused, but my understanding is for the Xiaomi Mijia Temperature and Humidity sensor, temperature and humidity are broadcasted (so no battery impact to frequent “reads”?), but battery and other items need to be fetched (would have battery impact). Is that correct? If so, how can we limit the polling of that data, or otherwise the overall polling interval of a bluetooth device?

How I can define in things file the Preferred adapter ?

Not sure how. What are you trying to achieve? Do you enable “Connection Control” for your nut? Preferred adapter is used if you want your device to be connected to your adapter. With Nut devices you should not establish connection I believe, hence setting a preferred adapter is no needed.

Hi @Polo, have you added an adapter from PaperUI inbox? You must add an adapter, after that the binding starts controlling it, it enables discovery of BT devices.

Hi @jimmyalias, you may use “usb over ip” or “serial over ip” solutions. Have a look here:
Forwarding of serial and USB ports over the network to openHAB

Hi @ggg,

That’s correct.

There is no need to limit polling interval for the such type of devices in the binding as it does not have any impact on battery life. Well, this is true for the binding logic / algorithms. There is a way to control polling interval on low level for BT stack itself, but this is not supported by the binding as it is not supported by Bluez/TinyB afaik. Anyway, this won’t make a huge difference on battery life even if we implement this.

As per “connected” devices, there is not any way at the moment to configure the “update rate” per each device. You can only configure refresh rate for all devices at once in the binding settings.

There is some work in progress to add a new feature that should allow us to configure each device thing “connection strategy” where you can define how often/ when /for how long connection should be established. Just for now, you could work around this by creating a rule that would connect/disconnect (enable/disable Connection Control setting) periodically.

Hi,
I just started using this binding and I have one question. I can connect with the binding to my ble device without problem, but when I disconnect the device it will stop advertising after a while, and it seems that the binding is removing the bonding information after while. I got this in my log:
[ager.impl.CombinedDeviceGovernorImpl] - Possible stale object detected: /XX:XX:XX:XX:XX:XX/

this is a problem because my ble device will not allow to refresh the bonding information. How Can I disable this “feature” ?

Hey @rozpruwacz, the reason why it removes bonds is that it tries to recover stale TinyB native objects. There is a bug/issue with TinyB when native objects become stale after some time, so the binding monitors activity and if it exceeds some timeout, it disposes objects (unfortunately with this bonds also get disposed by Bluez).

There is some work to add a setting to disable that “work around”. Not sure if it actually improve things as you may get stale objects after that.

Is this bug is planned to be fixed ?

I don’t think TinyB is going to fix it. There are some works that aimed to get rid of TinyB by implementing a new transport module that talks to Bluez directly via DBus. It is wip by @xrucka, see hi post here:

3rd Party Bluetooth Binding. Beta testers needed

ok, thanks. I’ll check that.

Do you have an example of a .thing file for this binding? Or is it only possible to configure using paperUI?
Thanks

1 Like

Hi all, I need your help. I have two sensors [Xiaomi Mijia Bluetooth Temperature Smart Humidity Sensor] one has been detected with options temperature/humidity/last updated etc. but second one can’t get all these options. I tried to remove but once detected again and added from Inbox it takes the same parameters including name. How to remove from db all historical informations about this sensor? Some cache? Is it any karaf cli command? I already tried smarthome:things remove but effect the same as removing from PaperUI - does not forget previous data.

Hi @Grzegorz_Golec, make sure your Temp/Humidity sensor is of most recent firmware version. Connect it to your phone and update it through Mi app.

it seems to both sensors are in the same latest firmware 1.0.1_0066.
Any other suggestions appreciated

I’m regularly (about once a day) getting these errors on my syslog:

Jan  8 05:44:04 raspberrypi kernel: [19732.559920] Bluetooth: hci0 command 0x200c tx timeout
Jan  8 05:44:04 raspberrypi kernel: [19732.559961] Bluetooth: Failed to disable LE scan: status 0x1f

and from that moment this breaks bluetooth (devices get no later updates), until I do a sudo systemctl restart bluetooth

This then thows a bunch of errors in openhab.log, but it starts working again:

Jan  8 10:00:35 raspberrypi systemd[1]: Stopping Bluetooth service...
Jan  8 10:00:35 raspberrypi bluetoothd[763]: Terminating
Jan  8 10:00:35 raspberrypi kernel: [35123.238016] Bluetooth: hci0: Frame reassembly failed (-84)
Jan  8 10:00:37 raspberrypi kernel: [35125.260539] Bluetooth: hci0 command 0x200c tx timeout
Jan  8 10:00:41 raspberrypi bluetoothd[763]: Stopping SDP server
Jan  8 10:00:41 raspberrypi bluetoothd[763]: Exit
Jan  8 10:00:41 raspberrypi systemd[1]: Starting Bluetooth service...
Jan  8 10:00:41 raspberrypi bluetoothd[25375]: Bluetooth daemon 5.48
Jan  8 10:00:41 raspberrypi systemd[1]: Started Bluetooth service.
Jan  8 10:00:41 raspberrypi bluetoothd[25375]: Starting SDP server
Jan  8 10:00:41 raspberrypi bluetoothd[25375]: Bluetooth management interface 1.14 initialized
Jan  8 10:00:41 raspberrypi dbus[495]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service'
Jan  8 10:00:41 raspberrypi systemd[1]: Starting Hostname Service...
Jan  8 10:00:41 raspberrypi systemd[1]: Failed to reset devices.list on /system.slice: Invalid argument
Jan  8 10:00:41 raspberrypi karaf[927]: (process:927): GLib-GIO-CRITICAL **: g_dbus_interface_get_info: assertion 'G_IS_DBUS_INTERFACE (interface_)' failed
Jan  8 10:00:41 raspberrypi karaf[927]: (process:927): GLib-GIO-CRITICAL **: g_dbus_interface_get_info: assertion 'G_IS_DBUS_INTERFACE (interface_)' failed
Jan  8 10:00:41 raspberrypi karaf[927]: (process:927): GLib-GIO-CRITICAL **: g_dbus_interface_get_info: assertion 'G_IS_DBUS_INTERFACE (interface_)' failed
Jan  8 10:00:41 raspberrypi karaf[927]: (process:927): GLib-GIO-CRITICAL **: g_dbus_interface_get_info: assertion 'G_IS_DBUS_INTERFACE (interface_)' failed
Jan  8 10:00:41 raspberrypi karaf[927]: (process:927): GLib-GIO-CRITICAL **: g_dbus_interface_get_info: assertion 'G_IS_DBUS_INTERFACE (interface_)' failed
Jan  8 10:00:41 raspberrypi karaf[927]: (process:927): GLib-GIO-CRITICAL **: g_dbus_interface_get_info: assertion 'G_IS_DBUS_INTERFACE (interface_)' failed
Jan  8 10:00:41 raspberrypi karaf[927]: (process:927): GLib-GIO-CRITICAL **: g_dbus_interface_get_info: assertion 'G_IS_DBUS_INTERFACE (interface_)' failed
Jan  8 10:00:41 raspberrypi karaf[927]: (process:927): GLib-GIO-CRITICAL **: g_dbus_interface_get_info: assertion 'G_IS_DBUS_INTERFACE (interface_)' failed
Jan  8 10:00:41 raspberrypi karaf[927]: (process:927): GLib-GIO-CRITICAL **: g_dbus_interface_get_info: assertion 'G_IS_DBUS_INTERFACE (interface_)' failed
Jan  8 10:00:41 raspberrypi karaf[927]: (process:927): GLib-GIO-CRITICAL **: g_dbus_interface_get_info: assertion 'G_IS_DBUS_INTERFACE (interface_)' failed
Jan  8 10:00:41 raspberrypi systemd-hostnamed[25406]: Warning: nss-myhostname is not installed. Changing the local hostname might make it unresolveable. Please install nss-myhostname!
Jan  8 10:00:41 raspberrypi dbus[495]: [system] Successfully activated service 'org.freedesktop.hostname1'
Jan  8 10:00:41 raspberrypi systemd[1]: Started Hostname Service.
Jan  8 10:00:49 raspberrypi karaf[927]: ** (process:927): WARNING **: Error setting property 'Powered' on interface org.bluez.Adapter1: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name :1.3 was not provided by any .service files (g-dbus-error-quark, 2)

Previously I used to pick up my bluetooth device updates through regularly cron-ed python scripts, and that didn’t cause any issues. I did upgrade bluetooth to 5.48 from 5.43 at the same time as switched to this binding though.

Have a look in the first post:

Sorry, had missed that note! Gone down to 5.47 now, and running; will see how it holds up.
Thanks

Hi

I’m Trying to get this to work - I have followed the install instruction but stuck here:

openhab> bundle:list | grep bluetooth
264 │ Waiting  │  80 │ 1.1.3                  │ org.sputnikdev:org.eclipse.smarthome.binding.bluetooth.transport.tinyb
265 │ Active   │  80 │ 1.1.6                  │ org.sputnikdev:org.eclipse.smarthome.binding.bluetooth

The .bluetooth.transport.tinyb never starts keeps waiting

Blues are running and within the version required

]# systemctl status bluetooth -l
● bluetooth.service - Bluetooth service
   Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-01-09 01:27:41 CET; 6h ago
     Docs: man:bluetoothd(8)
 Main PID: 1310 (bluetoothd)
   Status: "Running"
    Tasks: 1
   CGroup: /system.slice/bluetooth.service
           └─1310 /usr/libexec/bluetooth/bluetoothd

Jan 09 01:27:41 openhab.agesen.dk systemd[1]: Starting Bluetooth service...
Jan 09 01:27:41 openhab.agesen.dk bluetoothd[1310]: Bluetooth daemon 5.44
Jan 09 01:27:41 openhab.agesen.dk systemd[1]: Started Bluetooth service.
Jan 09 01:27:41 openhab.agesen.dk bluetoothd[1310]: Starting SDP server
Jan 09 01:27:41 openhab.agesen.dk bluetoothd[1310]: Bluetooth management interface 1.14 initialized
Jan 09 01:27:41 openhab.agesen.dk bluetoothd[1310]: Endpoint registered: sender=:1.130 path=/MediaEndpoint/A2DPSource
Jan 09 01:27:41 openhab.agesen.dk bluetoothd[1310]: Endpoint registered: sender=:1.130 path=/MediaEndpoint/A2DPSink

Could this have anything to with TinyB wrong path?

java.lang.IllegalStateException: Could not load native libraries for TinyB
	at org.sputnikdev.esh.binding.bluetooth.transport.tinyb.activator.TinyBActivator.activate(TinyBActivator.java:19) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod.invokeMethod(BaseMethod.java:228) ~[39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod.access$500(BaseMethod.java:41) ~[39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod$Resolved.invoke(BaseMethod.java:664) ~[39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.inject.methods.BaseMethod.invoke(BaseMethod.java:510) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:317) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:307) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:341) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:114) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:983) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:956) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:765) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:666) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:432) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:665) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:339) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:381) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.Activator.access$200(Activator.java:49) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:263) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169) [39:org.apache.felix.scr:2.1.14]
	at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:49) [39:org.apache.felix.scr:2.1.14]
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482) [?:?]
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415) [?:?]
	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) [?:?]
	at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) [?:?]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:908) [?:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213) [?:?]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120) [?:?]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112) [?:?]
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:168) [?:?]
	at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) [?:?]
	at org.eclipse.osgi.container.Module.start(Module.java:467) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1634) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1614) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1585) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1528) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [?:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?]