jlusiardi / homekit_python

A python implementation to work as both HomeKit controller and accessory.
Apache License 2.0
216 stars 41 forks source link

IP Discovery not working on MacOS #131

Closed netmanchris closed 5 years ago

netmanchris commented 5 years ago

Following the example in the README results in an exception.

Platform: macOS Mojave Python 3.6 ( virtual env ) homekit[ip] 0.13.0

Happy to provide more info upon request but hoping this is enough to point me in the right direction.

(venv) Christophers-MacBook-Air:HomekitPythonPlaying christopheryoung$ python3 -m homekit.discover
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/christopheryoung/PycharmProjects/HomekitPythonPlaying/venv/lib/python3.6/site-packages/homekit/discover.py", line 49, in <module>
    results = Controller.discover(args.timeout)
  File "/Users/christopheryoung/PycharmProjects/HomekitPythonPlaying/venv/lib/python3.6/site-packages/homekit/controller/controller.py", line 88, in discover
    return discover_homekit_devices(max_seconds)
  File "/Users/christopheryoung/PycharmProjects/HomekitPythonPlaying/venv/lib/python3.6/site-packages/homekit/zeroconf_impl/__init__.py", line 142, in discover_homekit_devices
    d['category'] = Categories[int(category)]
  File "/Users/christopheryoung/PycharmProjects/HomekitPythonPlaying/venv/lib/python3.6/site-packages/homekit/model/categories.py", line 83, in __getitem__
    raise KeyError('Item {item} not found'.format(item=item))
KeyError: 'Item 22 not found'
jlusiardi commented 5 years ago

Hi @netmanchris, looks like this device has a non-standard accessory category (Table 12-3 on page 254f says that all above 20 is reserved). What kind of device do you have there?

netmanchris commented 5 years ago

Hey @jlusiardi I'm running this in a subnet that has 150+ physical accessories ( showing 254 online and 50 devices offline which are the break outs of the physical accessories ).

Sounds like you might be suggesting I might need to split out the various accessories into a seperate subnet and then reperform the discovery to see if I can see which one is failing?

jlusiardi commented 5 years ago

oh wow, thats a big amount!

no I would prefer to have some logs. Can you try with master instead of a release from pypi? I will push a change with extended logging for discovery.py now. Use --log DEBUG for this.

netmanchris commented 5 years ago

Here's the debug before the exception was raised

(venv) Christophers-MacBook-Air:homekit_python-master christopheryoung$ python3 -m homekit.discover --log DEBUG
2019-04-16 09:19:07,239 __init__.py:0105 DEBUG device {'name': 'Xiaoyan HC - 789b41._hap._tcp.local.', 'address': '10.101.0.126', 'port': 34235, 'c#': '31', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '09:8b:8c:6a:31:58', 'md': 'xiaoyan home center', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '2', 'category': 'Bridge'}
2019-04-16 09:19:07,240 __init__.py:0105 DEBUG device {'name': 'LaserEgg2-C42ED9._hap._tcp.local.', 'address': '10.101.0.88', 'port': 80, 'c#': '2', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '7E:14:DE:BE:17:4A', 'md': 'LE-200', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '10', 'category': 'Sensor'}
2019-04-16 09:19:07,240 __init__.py:0105 DEBUG device {'name': 'iHome SmartPlug-8DBA3B._hap._tcp.local.', 'address': '10.101.0.87', 'port': 80, 'c#': '5', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '83:67:9A:43:9E:49', 'md': 'iSP8', 'pv': '1.0', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '7', 'category': 'Outlet'}
2019-04-16 09:19:07,240 __init__.py:0105 DEBUG device {'name': 'GLOCO-C152._hap._tcp.local.', 'address': '10.101.0.84', 'port': 80, 'c#': '1', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '80:A5:89:C0:C1:52', 'md': 'GLOCO-500', 'pv': '1.0', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '10', 'category': 'Sensor'}
2019-04-16 09:19:07,241 __init__.py:0105 DEBUG device {'name': 'Koogeek-O1US-917363._hap._tcp.local.', 'address': '10.101.0.114', 'port': 80, 'c#': '1', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '88:F1:F6:7A:38:F3', 'md': 'O1US', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '7', 'category': 'Outlet'}
2019-04-16 09:19:07,241 __init__.py:0105 DEBUG device {'name': 'iHome SmartMonitor-A289F4._hap._tcp.local.', 'address': '10.101.0.102', 'port': 80, 'c#': '2', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '6D:3A:28:5E:56:A6', 'md': 'iSS50', 'pv': '1.0', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '10', 'category': 'Sensor'}
2019-04-16 09:19:07,241 __init__.py:0105 DEBUG device {'name': 'Philips hue - 2687A7._hap._tcp.local.', 'address': '10.101.0.120', 'port': 8080, 'c#': '104', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': 'D6:A6:AF:B9:45:FC', 'md': 'BSB002', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '2', 'category': 'Bridge'}
2019-04-16 09:19:07,241 __init__.py:0105 DEBUG device {'name': 'ConnectSense Outlet 2 01786E._hap._tcp.local.', 'address': '10.101.0.124', 'port': 80, 'c#': '1', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '17:0F:14:F9:C6:5D', 'md': 'CS-SO-2', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '7', 'category': 'Outlet'}
2019-04-16 09:19:07,242 __init__.py:0105 DEBUG device {'name': 'Canvas 6A54._hap._tcp.local.', 'address': '10.101.0.128', 'port': 6517, 'c#': '4', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '57:C8:27:4B:E7:33', 'md': 'NL29', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '5', 'category': 'Lightbulb'}
2019-04-16 09:19:07,242 __init__.py:0105 DEBUG device {'name': 'VOCOlinc-PM2-0bbd7c._hap._tcp.local.', 'address': '10.101.0.79', 'port': 80, 'c#': '11', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': 'DF:E1:49:D0:38:86', 'md': 'VOCOlinc-PM2-0bbd7c', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '7', 'category': 'Outlet'}
2019-04-16 09:19:07,243 __init__.py:0105 DEBUG device {'name': 'ArloBaby1A._hap._tcp.local.', 'address': '10.101.0.171', 'port': 5051, 'c#': '20', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': 'EA:14:B6:A5:EA:47', 'md': 'ABC1000', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '17', 'category': 'IP Camera'}
2019-04-16 09:19:07,243 __init__.py:0105 DEBUG device {'name': 'iHome SmartPlug-8DDFC4._hap._tcp.local.', 'address': '10.101.0.82', 'port': 80, 'c#': '5', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '58:8C:E3:77:A5:EA', 'md': 'iSP8', 'pv': '1.0', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '7', 'category': 'Outlet'}
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/christopheryoung/PycharmProjects/HomekitPythonPlaying/homekit_python-master/homekit/discover.py", line 49, in <module>
    results = Controller.discover(args.timeout)
  File "/Users/christopheryoung/PycharmProjects/HomekitPythonPlaying/homekit_python-master/homekit/controller/controller.py", line 89, in discover
    return discover_homekit_devices(max_seconds)
  File "/Users/christopheryoung/PycharmProjects/HomekitPythonPlaying/homekit_python-master/homekit/zeroconf_impl/__init__.py", line 100, in discover_homekit_devices
    info.properties
  File "/Users/christopheryoung/PycharmProjects/HomekitPythonPlaying/homekit_python-master/homekit/zeroconf_impl/__init__.py", line 178, in parse_discovery_properties
    d['category'] = Categories[int(category)]
  File "/Users/christopheryoung/PycharmProjects/HomekitPythonPlaying/homekit_python-master/homekit/model/categories.py", line 83, in __getitem__
    raise KeyError('Item {item} not found'.format(item=item))
KeyError: 'Item 22 not found'
(venv) Christophers-MacBook-Air:homekit_python-master christopheryoung$ 

In case you see it somewhere, For my local copy, I reved the library version to 0.13.1 to make sure I wasn't running the mainline version.

jlusiardi commented 5 years ago

Ok, i failed. The problem happens before the log is done. I Just pushed some more logging.

netmanchris commented 5 years ago

you didn't fail. You just proved the error is earlier. :)

Taking a guess here, but looking at the categories.py it doesn't look like there's a definition for humidifier. Could it be that the it's the Vocolinc Flowerbud (light and humidifier) that's causing this to crash? Making the leap here that the 22 in bold below is the item 22 not found.

2019-04-16 12:40:09,839 init.py:0099 DEBUG candidate data {b'id': b'A4:BF:0A:80:A8:BB', b'c#': b'18', b's#': b'1', b'sf': b'0', b'md': b'VOCOlinc-Flowerbud-0d239e', b'ff': b'1', b'ci': b'22', b'pv': b'1.1', b'sh': b'Ldtpag==', b'aws': b'0', b'alc': b'0'}

Here's the new logs

(venv) Christophers-MacBook-Air:homekit_python-master christopheryoung$ python3 -m homekit.discover --log DEBUG
2019-04-16 12:40:09,803 __init__.py:0099 DEBUG candidate data {b'pv': b'1.1', b'id': b'09:8b:8c:6a:31:58', b'c#': b'31', b's#': b'1', b'sf': b'0', b'ff': b'1', b'md': b'xiaoyan home center', b'ci': b'2'}
2019-04-16 12:40:09,812 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'Xiaoyan HC - 789b41._hap._tcp.local.', 'address': '10.101.0.126', 'port': 34235, 'c#': '31', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '09:8b:8c:6a:31:58', 'md': 'xiaoyan home center', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '2', 'category': 'Bridge'}
2019-04-16 12:40:09,813 __init__.py:0099 DEBUG candidate data {b'c#': b'5', b'ff': b'1', b'id': b'0E:AA:CE:2B:35:71', b'md': b'iSP8', b'pv': b'1.0', b'sf': b'0', b'ci': b'7', b's#': b'1'}
2019-04-16 12:40:09,814 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'iHome SmartPlug-C4CF6A._hap._tcp.local.', 'address': '10.101.0.83', 'port': 80, 'c#': '5', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '0E:AA:CE:2B:35:71', 'md': 'iSP8', 'pv': '1.0', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '7', 'category': 'Outlet'}
2019-04-16 12:40:09,814 __init__.py:0099 DEBUG candidate data {b'c#': b'5', b'ff': b'1', b'id': b'58:8C:E3:77:A5:EA', b'md': b'iSP8', b'pv': b'1.0', b'sf': b'0', b'ci': b'7', b's#': b'1'}
2019-04-16 12:40:09,817 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'iHome SmartPlug-8DDFC4._hap._tcp.local.', 'address': '10.101.0.82', 'port': 80, 'c#': '5', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '58:8C:E3:77:A5:EA', 'md': 'iSP8', 'pv': '1.0', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '7', 'category': 'Outlet'}
2019-04-16 12:40:09,818 __init__.py:0099 DEBUG candidate data {b'c#': b'1', b'ff': b'1', b'id': b'17:0F:14:F9:C6:5D', b'md': b'CS-SO-2', b'pv': b'1.1', b'sf': b'0', b'ci': b'7', b's#': b'1', b'sh': b'IuYeHA=='}
2019-04-16 12:40:09,818 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'ConnectSense Outlet 2 01786E._hap._tcp.local.', 'address': '10.101.0.124', 'port': 80, 'c#': '1', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '17:0F:14:F9:C6:5D', 'md': 'CS-SO-2', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '7', 'category': 'Outlet'}
2019-04-16 12:40:09,821 __init__.py:0099 DEBUG candidate data {b'c#': b'5', b'ff': b'1', b'id': b'83:67:9A:43:9E:49', b'md': b'iSP8', b'pv': b'1.0', b'sf': b'0', b'ci': b'7', b's#': b'1'}
2019-04-16 12:40:09,821 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'iHome SmartPlug-8DBA3B._hap._tcp.local.', 'address': '10.101.0.87', 'port': 80, 'c#': '5', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '83:67:9A:43:9E:49', 'md': 'iSP8', 'pv': '1.0', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '7', 'category': 'Outlet'}
2019-04-16 12:40:09,822 __init__.py:0099 DEBUG candidate data {b'c#': b'1', b'ff': b'1', b'id': b'88:F1:F6:7A:38:F3', b'md': b'O1US', b'pv': b'1.1', b'sf': b'0', b'ci': b'7', b's#': b'1', b'sh': b'enUIEA=='}
2019-04-16 12:40:09,822 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'Koogeek-O1US-917363._hap._tcp.local.', 'address': '10.101.0.114', 'port': 80, 'c#': '1', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '88:F1:F6:7A:38:F3', 'md': 'O1US', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '7', 'category': 'Outlet'}
2019-04-16 12:40:09,823 __init__.py:0099 DEBUG candidate data {b'ci': b'17', b'c#': b'3', b'pv': b'1.1', b'id': b'B8:00:CC:07:9B:0F', b's#': b'1', b'sf': b'0', b'ff': b'1', b'md': b'DSH-C310', b'sh': b'VfvbSA=='}
2019-04-16 12:40:09,823 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'Omna 180Cam HD - 790D._hap._tcp.local.', 'address': '10.101.0.92', 'port': 5010, 'c#': '3', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': 'B8:00:CC:07:9B:0F', 'md': 'DSH-C310', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '17', 'category': 'IP Camera'}
2019-04-16 12:40:09,823 __init__.py:0099 DEBUG candidate data {b'c#': b'2', b'ff': b'1', b'id': b'6D:3A:28:5E:56:A6', b'md': b'iSS50', b'pv': b'1.0', b'sf': b'0', b'ci': b'10', b's#': b'1'}
2019-04-16 12:40:09,823 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'iHome SmartMonitor-A289F4._hap._tcp.local.', 'address': '10.101.0.102', 'port': 80, 'c#': '2', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '6D:3A:28:5E:56:A6', 'md': 'iSS50', 'pv': '1.0', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '10', 'category': 'Sensor'}
2019-04-16 12:40:09,826 __init__.py:0099 DEBUG candidate data {b'id': b'82:9C:E8:3B:94:EF', b'md': b'NL22', b'ff': b'1', b'c#': b'6', b's#': b'1', b'ci': b'5', b'pv': b'1.1', b'sh': b'QF49Yw==', b'sf': b'0'}
2019-04-16 12:40:09,827 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'Light Panels 50:d2:b7._hap._tcp.local.', 'address': '10.101.0.73', 'port': 6517, 'c#': '6', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '82:9C:E8:3B:94:EF', 'md': 'NL22', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '5', 'category': 'Lightbulb'}
2019-04-16 12:40:09,827 __init__.py:0099 DEBUG candidate data {b'c#': b'3', b'ff': b'1', b'id': b'56:E3:17:08:12:94', b'md': b'LIFX Pls BR30', b's#': b'1', b'sf': b'0', b'ci': b'5', b'pv': b'1.1', b'sh': b'+96yDg=='}
2019-04-16 12:40:09,831 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'Games Flood Two._hap._tcp.local.', 'address': '10.101.0.89', 'port': 80, 'c#': '3', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '56:E3:17:08:12:94', 'md': 'LIFX Pls BR30', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '5', 'category': 'Lightbulb'}
2019-04-16 12:40:09,831 __init__.py:0099 DEBUG candidate data {b'c#': b'1', b'ff': b'1', b'id': b'80:A5:89:C0:C1:52', b'md': b'GLOCO-500', b'pv': b'1.0', b'sf': b'0', b'ci': b'10', b's#': b'1'}
2019-04-16 12:40:09,832 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'GLOCO-C152._hap._tcp.local.', 'address': '10.101.0.84', 'port': 80, 'c#': '1', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '80:A5:89:C0:C1:52', 'md': 'GLOCO-500', 'pv': '1.0', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '10', 'category': 'Sensor'}
2019-04-16 12:40:09,833 __init__.py:0099 DEBUG candidate data {b'C#': b'2', b'S#': b'1', b'ff': b'1', b'sf': b'0', b'pv': b'1.1', b'md': b'Welcome', b'id': b'67:C5:2B:9E:59:47', b'na_tkn': b'02cae089aad5', b'ci': b'17'}
2019-04-16 12:40:09,834 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'Netatmo Welcome._hap._tcp.local.', 'address': '10.101.0.150', 'port': 5001, 'c#': '2', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '67:C5:2B:9E:59:47', 'md': 'Welcome', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '17', 'category': 'IP Camera'}
2019-04-16 12:40:09,834 __init__.py:0099 DEBUG candidate data {b'c#': b'20', b'ff': b'1', b'id': b'EA:14:B6:A5:EA:47', b'md': b'ABC1000', b's#': b'1', b'ci': b'17', b'sf': b'0', b'pv': b'1.1'}
2019-04-16 12:40:09,834 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'ArloBaby1A._hap._tcp.local.', 'address': '10.101.0.171', 'port': 5051, 'c#': '20', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': 'EA:14:B6:A5:EA:47', 'md': 'ABC1000', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '17', 'category': 'IP Camera'}
2019-04-16 12:40:09,834 __init__.py:0099 DEBUG candidate data {b'c#': b'104', b'ff': b'1', b'id': b'D6:A6:AF:B9:45:FC', b'md': b'BSB002', b'pv': b'1.1', b'sf': b'0', b's#': b'1', b'ci': b'2'}
2019-04-16 12:40:09,835 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'Philips hue - 2687A7._hap._tcp.local.', 'address': '10.101.0.120', 'port': 8080, 'c#': '104', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': 'D6:A6:AF:B9:45:FC', 'md': 'BSB002', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '2', 'category': 'Bridge'}
2019-04-16 12:40:09,835 __init__.py:0099 DEBUG candidate data {b'c#': b'2', b'ff': b'1', b'id': b'7E:14:DE:BE:17:4A', b'md': b'LE-200', b'pv': b'1.1', b'sf': b'0', b'ci': b'10', b's#': b'1', b'sh': b'J+82xQ=='}
2019-04-16 12:40:09,836 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'LaserEgg2-C42ED9._hap._tcp.local.', 'address': '10.101.0.88', 'port': 80, 'c#': '2', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '7E:14:DE:BE:17:4A', 'md': 'LE-200', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '10', 'category': 'Sensor'}
2019-04-16 12:40:09,836 __init__.py:0099 DEBUG candidate data {b'c#': b'10', b'ff': b'1', b'id': b'3C:E0:EE:CC:24:A2', b'md': b'LIFX BR30', b's#': b'1', b'sf': b'0', b'ci': b'5', b'pv': b'1.1', b'sh': b'IVLh/A=='}
2019-04-16 12:40:09,836 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'Joshua’s Main Light._hap._tcp.local.', 'address': '10.101.0.74', 'port': 80, 'c#': '10', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '3C:E0:EE:CC:24:A2', 'md': 'LIFX BR30', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '5', 'category': 'Lightbulb'}
2019-04-16 12:40:09,838 __init__.py:0099 DEBUG candidate data {b'c#': b'4', b'ff': b'1', b'id': b'74:54:0F:8C:F7:9A', b'md': b'LIFX Z', b's#': b'1', b'sf': b'0', b'ci': b'5', b'pv': b'1.1', b'sh': b'/iKHFg=='}
2019-04-16 12:40:09,839 __init__.py:0107 DEBUG found Homekit IP accessory {'name': 'Lifx Master Bedroom Strip._hap._tcp.local.', 'address': '10.101.0.65', 'port': 80, 'c#': '4', 'ff': 1, 'flags': 'Supports HAP Pairing', 'id': '74:54:0F:8C:F7:9A', 'md': 'LIFX Z', 'pv': '1.1', 's#': '1', 'sf': '0', 'statusflags': 'Accessory has been paired.', 'ci': '5', 'category': 'Lightbulb'}
2019-04-16 12:40:09,839 __init__.py:0099 DEBUG candidate data {b'id': b'A4:BF:0A:80:A8:BB', b'c#': b'18', b's#': b'1', b'sf': b'0', b'md': b'VOCOlinc-Flowerbud-0d239e', b'ff': b'1', b'ci': b'22', b'pv': b'1.1', b'sh': b'Ldtpag==', b'aws': b'0', b'alc': b'0'}
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/christopheryoung/PycharmProjects/HomekitPythonPlaying/homekit_python-master/homekit/discover.py", line 49, in <module>
    results = Controller.discover(args.timeout)
  File "/Users/christopheryoung/PycharmProjects/HomekitPythonPlaying/homekit_python-master/homekit/controller/controller.py", line 89, in discover
    return discover_homekit_devices(max_seconds)
  File "/Users/christopheryoung/PycharmProjects/HomekitPythonPlaying/homekit_python-master/homekit/zeroconf_impl/__init__.py", line 102, in discover_homekit_devices
    info.properties
  File "/Users/christopheryoung/PycharmProjects/HomekitPythonPlaying/homekit_python-master/homekit/zeroconf_impl/__init__.py", line 180, in parse_discovery_properties
    d['category'] = Categories[int(category)]
  File "/Users/christopheryoung/PycharmProjects/HomekitPythonPlaying/homekit_python-master/homekit/model/categories.py", line 83, in __getitem__
    raise KeyError('Item {item} not found'.format(item=item))
KeyError: 'Item 22 not found'
(venv) Christophers-MacBook-Air:homekit_python-master christopheryoung$ 
netmanchris commented 5 years ago

Haven't setup full testing yet, but made added humidifier to the category.py file and seems to be getting through this exception now. available here and happy to issue a PR (https://github.com/netmanchris/homekit_python)

Was able to get this output from the Debugs

Name: VOCOlinc-Flowerbud-0d19f1._hap._tcp.local. Url: http_impl://10.101.0.133:80 Configuration number (c#): 12 Feature Flags (ff): Supports HAP Pairing (Flag: 1) Device ID (id): C8:93:D2:13:47:7D Model Name (md): VOCOlinc-Flowerbud-0d19f1 Protocol Version (pv): 1.1 State Number (s#): 1 Status Flags (sf): Accessory has been paired. (Flag: 0) Category Identifier (ci): Humidifier (Id: 22)

jlusiardi commented 5 years ago

Ok, did you add the 22 as new category „humidifier“? Since this seems unofficial perhaps we should add some marker?

netmanchris commented 5 years ago

Yes, I added 22 as the new category humidifer.

https://developer.apple.com/documentation/homekit/hmaccessorycategory/accessory_category_types

It does look like categorTypeAirHumidifier is an official category, but I haven't found where that maps into the integer 22 yet. I'm guessing that since Air Humidifier is an official category, it should have an official designation. I'm guessing there are also other categories in the list which should be updated including sprinklers, showers, etc... but not sure what those category integers should be.

Happy to add a marker if it's unofficial, just let me know what you'd like to see. Just a comment in the code that it's an unofficial category?

netmanchris commented 5 years ago

hey @jlusiardi

I'm thinking that the categories may be "official" but hidden in the commercial spec. I did find this other repo that seems to have some of the other categories defined and it also lines up with "22" being the humidifier category.

https://github.com/abedinpour/HAS/blob/master/src/categories.ts

jlusiardi commented 5 years ago

ok, interesting. Can you make a pull request and add those two links as comment near the new categories? Those should be new:

airconditioner = 21,
    humidifer = 22,
dehumidifier = 23
Jc2k commented 5 years ago

<Snip out bit i wrote before i went to bed and you've seen yourselves>

And it looks like we'll need to add extra characteristics and services for all of these too.

HAP-NodeJS added these a year ago:

https://github.com/KhaosT/HAP-NodeJS/commit/871a14cca456df9741005fbab99dbd131fd8f94e#diff-1594a403ef24f947b4afcae7e9d1c69f

They look like they aren't in the spec we have but they are things mentioned in other apple docs.

Then TV support this January

https://github.com/KhaosT/HAP-NodeJS/blob/35023513c544012f3c8ca11761ab33386f947a25/lib/gen/HomeKitTypes-Television.js

ESP HomeKit has some of these too

https://github.com/maximkulkin/esp-homekit/blob/master/include/homekit/characteristics.h

I haven't found an online official doc - most of the library authors seem to have treated them as such but not documented where they got the info from.

Someone with XCode should find the HomeKit package and see if there is a .h/.swift file with all these constants defined in it.

netmanchris commented 5 years ago

Following up. Sent a PR for the new categories as discussed. Placed comments in Class docstring as well as right above the code with the new categories.

jlusiardi commented 5 years ago

Ok, i just added a branch fix_131_add_new_categories_characteristics_and_services for that changes. We should add it there first.

jlusiardi commented 5 years ago

@Jc2k i just got access to a mac to investigate the XCode stuff: there are headerfile confirming even Showerheads (HMAccessoryCategoryTypeShowerHead) but there is no mapping to numbers or UUIDs...

Jc2k commented 5 years ago

Just had a quick look myself and I found a swift file with stuff like:

/*!
 * @brief Characteristic type for humidifier threshold. The value of the characteristic is
 *        a float value in percent.
 */
@available(iOS 10.2, *)
public let HMCharacteristicTypeHumidifierThreshold: String

But not the values. So I made a swift playground and did this:

import UIKit
import HomeKit

print(HMCharacteristicTypeCurrentHeatingCooling)

And it spat out the UUID.

So it we can confirm that the characteristics are official and the UUID's are right.

jlusiardi commented 5 years ago

Mh on my iPad, the import HomeKit fails, but the Home App is thre and working

Jc2k commented 5 years ago

Boo - this was in XCode FWIW

jlusiardi commented 5 years ago

Ok I was confused because the iOS app is named the same. Do you know if a playground on Mac OS can be scripted? I ask because I expect updates to those definitions every now and then...

Jc2k commented 5 years ago

Hmm no idea tbh - that was the first time i tried it!

jlusiardi commented 5 years ago

ok, so we should find out...

netmanchris commented 5 years ago

PR https://github.com/jlusiardi/homekit_python/pull/133 was merged. Is it ok to close this issue?

jlusiardi commented 5 years ago

:+1: but i opened #136