Inkbird/Engbird Thermometer and Hygrometer sensor. Need help trying to add them to HA

Hi,

TL;DR: - I need help adding them to my HA.

I’ve been using Inkbird IBS-TH1 mini sensors as a standalone usecase. They are great, they store quite a bit of data and work great.

I’ve used them for:
-balcony temperature tracking. (sometimes we keep food there, its great to know the temperature difference at different weather conditions)
-to check room temperature fluctuations on different radiator settings,
-to check different parts of the room for difference in temperature
-to check room to room temperature differences and humidity difference.
-track humidity and temperature level around plants
-check different parts of the fridge for temperature fluctuations (my fridge allows temperature to float about 1.5* C)
-check freezer temperatures

And I believe there could be a ton more.
They are fairly cheap. ~20 usd. (Link at the bottom for Aliexpress)

I would like to have them work with home assistant. As then I dont need to open the app everytime I want to know something, and they could give me a warning before me even opening the app first if something is wrong.

I’ve tried using Xiaomi Bluetooth Temperature sensor, but that did not work.

I’ve also found the libs that someone created for them:


However, it’s beyond my skillset to somehow work them into HA as I don’t have any real coding skills.

Would there be anyone amongst us willing to give it a go? I would gladly be willing to run any testing required on my devices.

https://www.aliexpress.com/item/Inkbird-IBS-TH1-Mini-Data-Logger-Wireless-Thermometer-Hygrometer-for-iPhone-Android-Temperature-and-Humidity-Smart/32861103933.html?spm=2114.search0104.3.2.2acd5dadcKW6MC&ws_ab_test=searchweb0_0,searchweb201602_2_10065_10068_319_317_10696_453_10084_454_10083_433_10618_431_10307_10820_10821_10303_537_10302_536_10902_10059_10884_10887_100031_321_322_10103,searchweb201603_35,ppcSwitch_0&algo_expid=f9f6e6e5-4f7a-4eeb-9866-33cff48d87e6-0&algo_pvid=f9f6e6e5-4f7a-4eeb-9866-33cff48d87e6&transAbTest=ae803_4

Seconded. any advice?

Good news, I have it working for my single probe atm, and I have a few more on order. I will be flinging it up shortly onto github. There was a strange problem though…

I used bluepy as pybluez depends on gatttool which has been deprecated since around 2017. The recent hasbian distribution has it under bluez-deprecated. Anyhoo, I assume you can ssh into your hasbian (install the ssh/terminal client) and once that is done, you will have toi compile bluepy (maybe :slight_smile:

bluepy has no apk package in alpine for it, so we have to build it under python using pip3. This means we need to install a c/c++ compiler. I did put the code in here but, apparently, “new users can not post a message with more than 2 links” (and my post had none… oh well)

note that more often than not, the probes get an error on running this, which basically says

bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral 90:e2:02:9b:45:3a, addr type: public

That’s the inkbird saying, very politely, ‘go away at the moment’. The monitor does recover from this, but it’s a sign that your sensor maybe too far away (anything over -85 dbm and it seems to have real issues). Eventually, you should get something like;

Connecting…
raw readings is b’\x99\x08$\x16\x00t\x17’
temperateure is 22.01
humidity is 56.68

So… as I said… it’s done, and without using any node or deprecated tools (using ‘pure python’ which is what hass is written in). The only issue, as I mentioned at the top, is that I have almost zero idea of how to package this up, since it does require bluepy to be installed. It took me about 20 minutes to do the btle stuff and about 2 days to understand the lovelace/css/components thing. Such is life.

Regards,
S.

As promised… https://github.com/stelford/home-assistant_inkbird

3 Likes

can you confirm is still working?

I’ve purchased Inkbird sensor, but doest appear.

Im trying with some MAC’s because I can’t intercept which on is it.

Just tried it, seems to work. will let it run for a bit next to other temp sensors to see how it compares.
I’m running raspberry pi 4, latest home assistant.

Can anyone tell me how to add 2 Sensors to Hassio?

Is anyone getting, or know what this error in Home Assistant (core as is now known, in a venv) , and how to fix it? I’ve added permissions to the bluepy-helper, but that didn’t resolve anything:

“Error while setting up platform inkbird
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py”, line 150, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File “/usr/lib/python3.7/asyncio/tasks.py”, line 416, in wait_for
return fut.result()
File “/usr/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/inkbird/sensor.py”, line 76, in setup_platform
inkbird_devices.append( InkbirdUpdater(hass, inkbird_devices) )
File “/home/homeassistant/.homeassistant/custom_components/inkbird/sensor.py”, line 93, in init
self.scanner.start()
File “/srv/homeassistant/lib/python3.7/site-packages/bluepy/btle.py”, line 790, in start
self._mgmtCmd(“le on”)
File “/srv/homeassistant/lib/python3.7/site-packages/bluepy/btle.py”, line 312, in _mgmtCmd
raise BTLEManagementError(“Failed to execute management command ‘%s’” % (cmd), rsp)
bluepy.btle.BTLEManagementError: Failed to execute management command ‘le on’ (code: 20, error: Permission Denied)”

Thanks in advance.

Anyone know if there is a fix for the device losing connectivity? My inkbird works just fine until all of a sudden the system can no longer receive updates.

below log is from Homeassistant 0.106.5 running on a raspberry pi 4.

Any help or direction would be appreciated.

Logger: homeassistant.helpers.entity
First occured: 4:52:01 PM (45 occurences)
Last logged: 5:36:45 PM

Update for inkbird.updater fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 476, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/inkbird/sensor.py", line 139, in update
    self.handleDiscovery(dev)
  File "/config/custom_components/inkbird/sensor.py", line 167, in handleDiscovery
    battery = int(value[14:16], 16)
ValueError: invalid literal for int() with base 16: ''

@Motive313 Did you ever get past that error? I have the same problem.

Been playing with the inkbird and custom component for few days now and cant seem to work out the ha functioning properly. Whatever I try, it wont load any values in HA. Figured all kinds of tools on command line which helped me on the permissions etc.
In the end, I COULD use the helper_scripts showing me through Python the readings of sensor. So i modified the test_btle.py to return only value of temperature first. command line works and returns me temp.
Then i added a command line sensor in HA that executes “python3 temp.py” and voila, i have temperature in HA.
Next step to modify the py to return a json format of all 3 values and parse them as such into HA and i’m done.
Maybe look later into the custom component itself, but for now i’m happy :slight_smile:

additional findings. Having polling a lot isn’t very stable, bt on raspberry gets unresponsive etc. Changed update interval to 3 times and hour. Got feeling that BT 2,4Ghz band has interference a lot with all the wifi around.
Adjustments in frequency do help a lot, not all updates are succesful, but it always recover.

Sorry I never noticed that you asked me. I’m still having this issue.

Anybody using @stelford add on with the Inkbird IBS-P01?

Been trying but there seems to be an issue that I am unfortunately not talented enough to address.

2021-03-09 20:22:14 ERROR (MainThread) [homeassistant.components.sensor] inkbird: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 360, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 465, in async_device_update
    await task
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/inkbird/sensor.py", line 139, in update
    self.handleDiscovery(dev)
  File "/config/custom_components/inkbird/sensor.py", line 167, in handleDiscovery
    battery = int(value[14:16], 16)
ValueError: invalid literal for int() with base 16: ''

To get @stelford add-on to work with Docker HA, need to access shell of the container to install bluepy. Also MAY need to apk add libcap, then setcap ‘cap_net_raw,cap_net_admin+eip’ on the bluepy-helper file. Likely more importantly is cap_add: NET_ADMIN for the container. This would get you past the permissions block for bluepy ‘le on’. However, I was then faced with the ValueError as described a few times in this thread.

This was resolved when the MAC address in the configuration.yaml was all lowercase.

Humidity, temperature, and battery values are all correctly pulled from IBS-TH1 v1.5.0 and v2.0.0.

I hacked out some fixes to @stelford that may correct some of the issues people have in this thread. See my fork here:

It’s probably better to use MQTT or something, but I haven’t gotten to that yet. I “don’t know how to program”, so that’s why I’m saying my fork is more a hack and this is why I can’t provide any support! First time looking at python code, first time using github. Let me know if it works for you though! Good luck

1 Like

Hi everyone,

I am trying to integrate the current model IBS-TH2 sensor into HA, and have been modifying stelford’s code to make it work. While the device is being detected and is shown on the dashboards, the temperature displayed is not correct.

I have been testing with the test_btle.py script , and after a bit of trial and error I have managed to identify the code which needs to change in order to get the correct temperature from the IBS-TH2.

At line 45 of the test_btle.py script where it reads “readings = dev.readCharacteristic(40)” this needs to be changed to “readings = dev.readCharacteristic(36)”

I have tested this multiple times and it works across a range of temperatures. And I now need to get the changes to reflect in Home Assistant, but I cannot find a similar line of code in “sensor.py”. Can someone please point me to the right script where I can make this change?

2 Likes

I just ordered the IBS-TH2. I’ve been reading through the code, test_btle.py uses a different function to get the values than the sensor.py does. Line 162 of stelford’s code is where the temperature is parsed, I suspect this is where the issue is. Once I get my sensor I’ll try to figure this out.

1 Like

I received my IBS-TH2 and it works with no modification of the code. All values match the Engbird app. I am using the code from mike0xt which did have an error in manifest.json. It needed a comma after version, line 4.

1 Like