I am a novice and only got into Home Assistant over the past couple of days. So far I’m I think I’m doing reasonably well for a non-developer and have got TP-Link switches and Harmony Hub integration working.
I wanted to experiment with Device Tracking and noticed the BT Home Hub 5 component however it is giving me the following errors:
2018-01-07 20:50:54 INFO (SyncWorker_9) [homeassistant.components.device_tracker.bt_home_hub_5] Initialising BT Home Hub 5
2018-01-07 20:50:54 INFO (SyncWorker_9)
2018-01-07 20:50:54 ERROR (SyncWorker_9) [homeassistant.components.device_tracker.bt_home_hub_5] Invalid response from Home Hub: <Response [404]>
2018-01-07 20:50:54 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform bt_home_hub_5
I’m also a noob but running into the same issues. I see threads from the last 2 years saying the bt home hub integration isn’t working. My error is below:
ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform bt_home_hub_5
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/__init__.py", line 158, in async_setup_platform
platform.get_scanner, hass, {DOMAIN: p_config})
File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
raise self._exception
File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/bt_home_hub_5.py", line 32, in get_scanner
scanner = BTHomeHub5DeviceScanner(config[DOMAIN])
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/bt_home_hub_5.py", line 48, in __init__
data = _get_homehub_data(self.url)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/bt_home_hub_5.py", line 97, in _get_homehub_data
return _parse_homehub_response(response.text)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/bt_home_hub_5.py", line 104, in _parse_homehub_response
root = ET.fromstring(data_str)
File "/usr/lib/python3.5/xml/etree/ElementTree.py", line 1344, in XML
parser.feed(text)
File "<string>", line None
xml.etree.ElementTree.ParseError: mismatched tag: line 74, column 2
I worked around this problem by using the nmap tracker (for IOS) and ping tracker (for Android). My devices have static IPs, so it’s not an expensive scan to carry out.
Incidentally I was able to modify the BT Home Hub 5 Device Tracker python script to parse the devices connected table from the HTML response of the home page of the hub. All seems to work as expected but iPhone devices drop the wifi connections so not a particularly reliable means of detecting presence.
I’m no developer so have no idea how to upload the scripts if anyone is interested but below are the changes I made to bt_home_hub_5.py. I saved this down under custom_components/device_tracker. Note that the changes make use of HTMLTableParser written by Josua Schmid (nice one).
Note that the URL has been changed to eliminate home_status.xml which gives you the 404 error.
from html_table_parser import HTMLTableParser
…
self.url = ‘http://{}/’.format(self.host)
…
def _parse_homehub_response(data_str):
“”“Parse the BT Home Hub 5 data format.”“”
p = HTMLTableParser()
p.feed(data_str)
known_devices = p.tables[9]
devices = {}
for device in known_devices:
if len(device) == 5 and device[2] != '':
devices[device[2]] = device[1]
return devices
@Slap_Ed This home hub module is currently broken. @ha_novice has made some changes in his home assistant files to get it working, which you can try and replicate. I decided to just use nmap and ping.
@Kallb123 thanks for your comment. I took a look at @ha_novice changes, as a noob to HA and complete novice in software coding, I wouldn’t know where to start/place/store the example script.
That said, I have got nmap up and running with just the devices I wish to track/view. I’d be interested in your “ping thing” if you wouldn’t mind sharing.
As an aside, I’l love to get my teeth into MQTT to track and manage my home automation, but it gives me a headache just reading about the topic
@Slap_Ed my nmap tracker wasn’t picking up my android phone properly, so I had to switch to the ping platform. It just sends out a small message and waits for a reply from the phone. Works just fine. Nmap works fine for the ios devices though, so I have both going at the same time:
In my config file. It works fine and I have one device that interacts with it that way. Wasn’t sure about the prefix and how it effects things, I think the device uses a different prefix but I still managed to add it into the system. I don’t really understand it but it works haha.
I followed your notes and copied what you did: Take the bt_home_hub_5.py code and add your modifications (Added the import, changed the URL, changed the _parse_homehub_response function) and saved it as a custom component bt_home_hub_5.py
According to the docs if I create a component with the same name it overrides the built-in one.
However, I now get the error:
ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform bt_home_hub_5
I’m sure this is just something silly and obvious, but I’m brand new to HA. Would appreciate if you could point me in the right direction
Sorry to revive a seemingly dead thread but I thought I’d update it to let you all know that my pull request that fixes the bt home hub 5 component has just been closed. This should mean the component should be working with the next home assistant update.
Many thanks to @ha_novice for his suggestion on how to fix it as it thoroughly helped me.
Should the component now be fixed in 0.76.2? I have the component enabled but the device tracking isn’t working.
Upon HA booting up, there’s an error of something (I’m not with HA at the moment) like:
IndexError: list index out of range
I can get the full error later if needed.
Currently new devices aren’t being added and current devices aren’t tracked.
Hey guys! I’ve been very busy recently with work so haven’t been able to check out these errors or look at a fix. @trevor.hendo or @theTechnician, if you are finding that you are having trouble with the module working, im just wondering, could you let me know what BT home hub 5 type you have - Type A or Type B? It should say at the bottom of the page when you go to 192.168.1.254 in your browser. This would help debug the problem. Thanks!
Wow … I had no idea you replied, sorry it’s taken this long.
I’ll check when I get home and edit this reply … I know I have a BT Home Hub 5, that’s for sure.
Hi @freekeys & All, I have a BT Home Hub 6 Type B and I get a load of Python errors when I try and configure it to track devices. Does it work for you now or anyone else with a BT home hub?
I’ve tried using device type “bt_home_hub_5” and “bt_smarthub” but both types give me the same errors below… I don’t think device tracking works for BT hubs anymore, It used to work when I first setup HA about 6 months ago then all my node red scripts stopped working on mobile devices connecting to my network.
2019-02-10 13:02:25 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform bt_home_hub_5
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/init.py”, line 176, in async_setup_platform
platform.get_scanner, hass, {DOMAIN: p_config})
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/bt_home_hub_5.py”, line 29, in get_scanner
scanner = BTHomeHub5DeviceScanner(config[DOMAIN])
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/bt_home_hub_5.py”, line 46, in init
data = bthomehub5_devicelist.get_devicelist(self.host)
File “/usr/local/lib/python3.6/site-packages/bthomehub5_devicelist/bthomehub5_devicelist.py”, line 20, in get_devicelist
return parse_devicelist(response.text)
File “/usr/local/lib/python3.6/site-packages/bthomehub5_devicelist/bthomehub5_devicelist.py”, line 31, in parse_devicelist
known_devices = p.tables[9] IndexError: list index out of range