BT smart hub 2 no longer talking with HA

So I have been using Presence Detection with a BT smart hub 2 for the last year or so and its been working great. The plan is always to replace the hub with something a little better but atm the money to do this is needed elsewhere so just not an option.
As I say it was working fine but its just stopped working. I tried to check the logs but I cant even see it trying to communicate with the hub. Its been this way for a couple or weeks. Frustratingly I have no idea if this coincides with an update on either side as I didn’t even know it wasn’t working at first as it worked so well the only reason I noticed is because my alarm didn’t set when I was the last to leave.

I used NMAP as a replacement but with newer smart phones its just too unreliable. I used an old asus router I have laying around and put that in the network as basically a switch but then put my mesh wifi wired through that and I can see our phones but again its not very reliable. The TP link mesh wifi we have doesnt have any integration that can work with it as far as I can see. I can use the Home Assistant app but only on my phone my Mrs is definitely a techno phobe and does not want the app on her phone she thinks if she installs an app she doesnt want something will break.

I removed the known devices file and it hasnt been replaced despite the bt hub still being a tracker. Im at a complete loss as to how to debug the integration.

Can I make the logs more detailed so it shows more? Can I do something to check communication between HA and the BT hub
I would be very grateful to anyone that can help with this I’ve become quite attached to my presence automations and not having them work is so frustrating
edit
I change the logging to debug and found that there is indeed an error with setting up the bt smart up presence detection
I just need to know if its at all possible to fix it

I’m having the same issue with the BT Smart Hub Device Tracker - any news on this?

So I posted to github as I think its an issue that’s arisen due to a code change maybe.

As yet no response hopefully it will be picked up soon but I don’t think there are many of us using the bt smarhub and probably less using it for presence.

Its a real shame, I’d just got presence set up and working nicely after recently upgrading to the BT Smart Hub 2!

Yeah I love my presence detection and I fully intend to buy a better router but I wish it would of stayed working till I can afford a good one.

I’ve noticed that connectivity with the smart hub I have becomes unresponsive sometimes. It returns when I restart HA after an update (I’ve not found the time to look into this properly). My suspicion is that the hub reboots due to a firmware update and HA doesn’t realise it needs to re-authenticate with the hub or something like that.

Presence detection was working well until my smarthub updated it’s firmware to V35

Now I’m getting the following error:

Logger: homeassistant.components.device_tracker
Source: components/bt_smarthub/device_tracker.py:100
Integration: Device tracker (documentation, issues)
First occurred: August 23, 2022 at 10:49:47 AM (1 occurrences)
Last logged: August 23, 2022 at 10:49:47 AM

Error setting up platform legacy bt_smarthub
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/legacy.py", line 248, in async_setup_legacy
    scanner = await hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/bt_smarthub/device_tracker.py", line 39, in get_scanner
    scanner = BTSmartHubScanner(smarthub_client)
  File "/usr/src/homeassistant/homeassistant/components/bt_smarthub/device_tracker.py", line 66, in __init__
    if self.get_bt_smarthub_data():
  File "/usr/src/homeassistant/homeassistant/components/bt_smarthub/device_tracker.py", line 100, in get_bt_smarthub_data
    return [_create_device(d) for d in data if d.get("PhysAddress")]
TypeError: 'NoneType' object is not iterable

Anyone have any ideas?

I’m getting exactly the same error. If you haven’t commented on the GitHub issue then I would go and do that and mention which version of HA you’re on.

1 Like

Done! Please could anyone else having the issue also comment in GitHub. We can’t be the only ones…

I could have sworn that I saw someone suggest that the issue was cause by a missing referer header, but I can’t find the comment. The library being used to communicate with the Smart Hub hasn’t been updated in a couple of years now, so it’s possible that it’s drifted out of sync with changes to the hub.

I’m going to install it and play around a bit, and see if I can track down what’s going on.

I remember seeing that comment too I just wouldnt know where to start to fix it.

This one:

I’ve forked the Python library that handles the communication with the Smart Hub and I’ve manage to spike out a fix. The referer header is now required, and there’s also a change to the data returned regarding WiFi Discs which needed to be addressed. The library scrapes a JavaScript file and then transforms it into JSON so that Python can read it and grab the values it needs. It’s obviously a bit brittle because of this, but I don’t think there’s another way of getting the data out that it grabs.

I’ll try to get this tidied up and put a PR to the owner of the library, but I need to make sure that this doesn’t break Smart Hubs on older versions (ideally, maybe I can assume they will all be upgraded by now), and then I’ve got to make sure a new version gets released, and then update Home Assistant to use the new version. Failing that I supposed I’ll need to figure out how to publish a Python package and then use that in Home Assistant instead.

Here’s the repo in case you’re interested: https://github.com/typhoon2099/btsmarthub_devicelist

2 Likes

That’s a PR up to fix the issue. Hopefully it’s picked up and merged so a new version can be released, at which point Home Assistant can be updated to use the fix.

1 Like

And now a PR for the merge into Home Assistant. Hopefully I can get this merged in soon to make it in time for one of the next releases (not sure if it would be a bugfix release or have to wait for the next major release.

2 Likes

Has the update to 2022.9 fixed this for anybody?

Mine still seems borken.

I was just about to post, I’ve updated and it didn’t at first, but after rebooting my host it’s working again (I also had to add the smarthub_model to my config as I had warnings that it couldn’t be detected. There may be another issue there to fix.

EDIT: Yes, that’s the problem, there’s a method for determining the SmatHub type which also needs the referer header present. I’ll have to push another fix for tat, but in the mean time specifying the version in you Home Assistant config will work around the issue.

1 Like

Can confirm that adding the model line fixes the issue. Thank you for all your work on getting this sorted out!

Update: 2022.10.1 has fixed the autodetection, so you should be good to drop that config line again if you want. There’s also a fix for names on the SmartHub that have special characters in them, which was breaking the integration. So hopefully a much better experience now!