sputnikdev / eclipse-smarthome-bluetooth-binding

Eclipse SmartHome Bluetooth Binding
46 stars 10 forks source link

Add support for Inkbird IBS-TH1 Mini sensor #60

Open binladin opened 6 years ago

binladin commented 6 years ago

I have an ibs-th1 mini temperature and humidity sensor with logger function (http://www.ink-bird.com/products-smart-sensor-ibsth1mini.html). I create custom xml files for service and characteristic and open access rights for all (777), but in thing for my sensor, temperature and humidity was not added. Where is my mistake ? Which uuid I must use in xml ?

And I can't understand how to declare field for temp&humidity (uuid: 0000fff2-0000-1000-8000-00805f9b34fb) if it have 7 byte, for example: EA-09-EA-0E-00-1B-DF. First two byte is temperature in little endian (2538 for 0.01°C - 25.38°), humidity is similar (3-4 bytes - 38.18%), 5 byte is permanent 00 (delimiter ?), and 6-7 bytes is crc16 (modbus). Another charactiristic, with uuid=fff1 contains cfg data (20 bytes): calibration point for temp&hum, time interval for logging, software version and crc16. Other manufacturer specific characteristic intended for reading history data (logger) and reseting.

------my log for bluetoothctl ----- [07:31:26] pi@openHABianPi:~$ bluetoothctl [NEW] Controller 43:43:A1:12:1F:AC BlueZ 5.47 [default] [NEW] Device 50:33:8B:DE:4E:B4 sps [NEW] Primary Service /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028 0000fff0-0000-1000-8000-00805f9b34fb Unknown [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0042 0000fff9-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0042/desc0044 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char003f 0000fff8-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char003f/desc0041 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char003c 0000fff7-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char003c/desc003e 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0038 0000fff6-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0038/desc003b 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0038/desc003a 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0035 0000fff5-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0035/desc0037 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0032 0000fff4-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0032/desc0034 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char002f 0000fff3-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char002f/desc0031 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char002c 0000fff2-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char002c/desc002e 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0029 0000fff1-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0029/desc002b 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Primary Service /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015 0000180a-0000-1000-8000-00805f9b34fb Device Information [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char0026 00002a50-0000-1000-8000-00805f9b34fb PnP ID [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char0024 00002a2a-0000-1000-8000-00805f9b34fb IEEE 11073-20601 Regulatory Cert. Data List [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char0022 00002a29-0000-1000-8000-00805f9b34fb Manufacturer Name String [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char0020 00002a28-0000-1000-8000-00805f9b34fb Software Revision String [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char001e 00002a27-0000-1000-8000-00805f9b34fb Hardware Revision String [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char001c 00002a26-0000-1000-8000-00805f9b34fb Firmware Revision String [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char001a 00002a25-0000-1000-8000-00805f9b34fb Serial Number String [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char0018 00002a24-0000-1000-8000-00805f9b34fb Model Number String [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char0016 00002a23-0000-1000-8000-00805f9b34fb System ID [NEW] Primary Service /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0011 00001801-0000-1000-8000-00805f9b34fb Generic Attribute Profile [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0011/char0012 00002a05-0000-1000-8000-00805f9b34fb Service Changed [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0011/char0012/desc0014 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Primary Service /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0001 0000180f-0000-1000-8000-00805f9b34fb Battery Service [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0001/char0002 00002a19-0000-1000-8000-00805f9b34fb Battery Level [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0001/char0002/desc0005 00002908-0000-1000-8000-00805f9b34fb Report Reference [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0001/char0002/desc0004 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration

vkolotov commented 6 years ago

Hi @binladin , can you please attach your custom gatt files here?

vkolotov commented 6 years ago

Just so you know, you don't have to define all characteristics and fields. You may start only with one char and those two fields for temp and humidity. I suggest you to do like that. Debug it, make it working, and only then add more fields/chars.

binladin commented 6 years ago

Ok, in my custom xml I used only temp&hum char with oregonscientific and miflora as examples. I will attach they when I return to home.

vkolotov commented 6 years ago

Your fields should like like that:

        <Field name="Temperature">
            <Format>uint16</Format>
            <DecimalExponent>-2</DecimalExponent>
            <Unit>org.bluetooth.unit.thermodynamic_temperature.degree_celsius</Unit>
        </Field>
        <Field name="Humidity">
            <Format>uint16</Format>
            <DecimalExponent>-2</DecimalExponent>
            <Unit>org.bluetooth.unit.percentage</Unit>
        </Field>
vkolotov commented 6 years ago

And make sure you follow this manual: https://github.com/sputnikdev/eclipse-smarthome-bluetooth-binding/blob/master/gatt-extensions.md

binladin commented 6 years ago

Field section is fully consistent with your post. I create folder /home/pi/.bluetooth_devices, characteristic, service in it, set full right for other (owner - pi, group - pi, must I change owner for openhab ?), configured binding for gatt extention folder, but can't see temp&hum channels. May I need to remove thing first ?

vkolotov commented 6 years ago

Yes, you will definitely need to remove it and restart OH. OpenHab user must have access to those files.

Update: you actually don't have to restart OH, but definitely re-add your device.

binladin commented 6 years ago

Good Evening! My com.inkbird.service.temperature_and_humidity.xml com.inkbird.service.txt фтв com.inkbird.characteristic.temperature_and_humidity.xml com.inkbird.txt

All my attempts so far have been unsuccessful :(

vkolotov commented 6 years ago

Both files look ok to me. I'll do some experiments when I'm back at home.

vkolotov commented 6 years ago

Hey @binladin, sorry for a late reply.

I did some experiments with the extension folder and it works for me. Let's try to narrow down it.

Could you please enable DEBUG level for the gatt parser as per this?

log:set DEBUG org.sputnikdev.bluetooth.gattparser.spec

Then you should expect in the logs something like that:

13:28:57.924 [INFO ] [spec.BluetoothGattSpecificationReader] - Reading services and characteristics from folder: /home/pi/.bluetooth_smart
13:28:57.928 [INFO ] [spec.BluetoothGattSpecificationReader] - Reading services from folder: /home/pi/.bluetooth_smart/service
13:28:58.108 [INFO ] [spec.BluetoothGattSpecificationReader] - Reading characteristics from folder: /home/pi/.bluetooth_smart/characteristic

Could you please also let me know where is your folder and how did you make it to be accessible by openhab user?

Here is where I have it:

pi@raspberrypi:~ $ pwd
/home/pi
pi@raspberrypi:~ $ ls -la
drwxr-xr-x  4 pi   pi      4096 Sep 11 13:25 .bluetooth_smart

And I have this in the binding config:

image

binladin commented 6 years ago

Hi, i am have next output for log:tail command:

21:22:43.298 [INFO ] [spec.BluetoothGattSpecificationReader] - Reading services and characteristics from folder: /home/pi/.bluetooth_devices 21:22:43.305 [INFO ] [spec.BluetoothGattSpecificationReader] - Reading services from folder: /home/pi/.bluetooth_devices/service 21:22:43.429 [INFO ] [spec.BluetoothGattSpecificationReader] - Reading characteristics from folder: /home/pi/.bluetooth_devices/characteristic

About folder:

[21:28:39] pi@openHABianPi:~$ pwd /home/pi [21:28:43] pi@openHABianPi:~$ ls -la total 12424 drwxr-xr-x 10 pi pi 4096 Sep 11 21:14 . drwxr-xr-x 4 root root 4096 Oct 31 2017 .. -rw------- 1 pi pi 19006 Aug 26 01:23 .bash_history -rw-r--r-- 1 pi pi 220 Jan 26 2017 .bash_logout -rw-r--r-- 1 pi pi 2615 Nov 12 2017 .bash_profile -rw-r--r-- 1 pi pi 3515 Jan 26 2017 .bashrc drwxrwxrwx 4 openhab openhab 4096 Aug 20 21:30 .bluetooth_devices

GATT services and characteristics extension folder: /home/pi/.bluetooth_devices

xrucka commented 6 years ago

Hi, I had a similar issue - just to clarify, you do have the xml specs in /home/pi/.bluetooth_devices/service/com.inkbird.service.temperature_and_humidity.xml and characteristics in /home/pi/.bluetooth_devices/characteristic/com.inkbird.characteristic.temperature_and_humidity.xml?

What does ls -laR /home/pi/.bluetooth_devices report?

binladin commented 6 years ago

Hi! I have next output:

[17:53:32] pi@openHABianPi:~$ ls -laR /home/pi/.bluetooth_devices /home/pi/.bluetooth_devices: total 16 drwxrwxrwx 4 openhab openhab 4096 Aug 20 21:30 . drwxr-xr-x 10 pi pi 4096 Sep 11 21:14 .. drwxrwxrwx 2 openhab openhab 4096 Aug 21 20:10 characteristic drwxrwxrwx 2 openhab openhab 4096 Aug 20 21:53 service

/home/pi/.bluetooth_devices/characteristic:

total 12 drwxrwxrwx 2 openhab openhab 4096 Aug 21 20:10 . drwxrwxrwx 4 openhab openhab 4096 Aug 20 21:30 .. -rw-rw-rw- 1 openhab openhab 861 Aug 21 22:18 com.inkbird.characteristic.temperature_and_humidity.xml

/home/pi/.bluetooth_devices/service:

total 12 drwxrwxrwx 2 openhab openhab 4096 Aug 20 21:53 . drwxrwxrwx 4 openhab openhab 4096 Aug 20 21:30 .. -rw-rw-rw- 1 openhab openhab 2008 Aug 22 19:13 com.inkbird.service.temperature_and_humidity.xml

art0 commented 4 years ago

I have an ibs-th1 mini temperature and humidity sensor with logger function (http://www.ink-bird.com/products-smart-sensor-ibsth1mini.html). I create custom xml files for service and characteristic and open access rights for all (777), but in thing for my sensor, temperature and humidity was not added. Where is my mistake ? Which uuid I must use in xml ?

And I can't understand how to declare field for temp&humidity (uuid: 0000fff2-0000-1000-8000-00805f9b34fb) if it have 7 byte, for example: EA-09-EA-0E-00-1B-DF. First two byte is temperature in little endian (2538 for 0.01°C - 25.38°), humidity is similar (3-4 bytes - 38.18%), 5 byte is permanent 00 (delimiter ?), and 6-7 bytes is crc16 (modbus). Another charactiristic, with uuid=fff1 contains cfg data (20 bytes): calibration point for temp&hum, time interval for logging, software version and crc16. Other manufacturer specific characteristic intended for reading history data (logger) and reseting.

------my log for bluetoothctl ----- [07:31:26] pi@openHABianPi:~$ bluetoothctl [NEW] Controller 43:43:A1:12:1F:AC BlueZ 5.47 [default] [NEW] Device 50:33:8B:DE:4E:B4 sps [NEW] Primary Service /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028 0000fff0-0000-1000-8000-00805f9b34fb Unknown [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0042 0000fff9-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0042/desc0044 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char003f 0000fff8-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char003f/desc0041 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char003c 0000fff7-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char003c/desc003e 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0038 0000fff6-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0038/desc003b 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0038/desc003a 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0035 0000fff5-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0035/desc0037 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0032 0000fff4-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0032/desc0034 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char002f 0000fff3-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char002f/desc0031 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char002c 0000fff2-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char002c/desc002e 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0029 0000fff1-0000-1000-8000-00805f9b34fb Unknown [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0028/char0029/desc002b 00002901-0000-1000-8000-00805f9b34fb Characteristic User Description [NEW] Primary Service /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015 0000180a-0000-1000-8000-00805f9b34fb Device Information [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char0026 00002a50-0000-1000-8000-00805f9b34fb PnP ID [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char0024 00002a2a-0000-1000-8000-00805f9b34fb IEEE 11073-20601 Regulatory Cert. Data List [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char0022 00002a29-0000-1000-8000-00805f9b34fb Manufacturer Name String [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char0020 00002a28-0000-1000-8000-00805f9b34fb Software Revision String [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char001e 00002a27-0000-1000-8000-00805f9b34fb Hardware Revision String [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char001c 00002a26-0000-1000-8000-00805f9b34fb Firmware Revision String [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char001a 00002a25-0000-1000-8000-00805f9b34fb Serial Number String [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char0018 00002a24-0000-1000-8000-00805f9b34fb Model Number String [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0015/char0016 00002a23-0000-1000-8000-00805f9b34fb System ID [NEW] Primary Service /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0011 00001801-0000-1000-8000-00805f9b34fb Generic Attribute Profile [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0011/char0012 00002a05-0000-1000-8000-00805f9b34fb Service Changed [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0011/char0012/desc0014 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Primary Service /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0001 0000180f-0000-1000-8000-00805f9b34fb Battery Service [NEW] Characteristic /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0001/char0002 00002a19-0000-1000-8000-00805f9b34fb Battery Level [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0001/char0002/desc0005 00002908-0000-1000-8000-00805f9b34fb Report Reference [NEW] Descriptor /org/bluez/hci0/dev_50_33_8B_DE_4E_B4/service0001/char0002/desc0004 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration

Hi @binladin et al Did you manage to pull the data of th IBS-TH1 including the historical records and the status of battery?

Thanks

wattsie commented 3 years ago

5 byte is permanent 00

This is which temperature sensor is in use.

00 - Internal Probe 01 - External Probe

Cheers.