Open a3135134 opened 4 years ago
Hi, This module should also work under windows, but only for IP based accessories, no Bluetooth LE support. I have a few questions:
_crypt
? I am not aware the _crypt
module is loaded directly by the modules code.I used cmd " pip install homekit". When I try python -m homekit.discover, here's the log:
Traceback (most recent call last):
File "E:\Python3\lib\runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "E:\Python3\lib\runpy.py", line 109, in _get_module_details
import(pkg_name)
File "E:\Python3\lib\site-packages\homekit__init.py", line 26, in
Mh interesting point, looks like the crypt module is not available on windows (https://docs.python.org/3/library/crypt.html). Because only crypt.mksalt
is needed, we might reimplement that?
Yes. Might choose a cross-platform python lib.
It looks like crypt.mksalt
is justed used to generate random 16-byte numbers needed by Srp as salt and keys. One of the crypto libraries we already depend on (cryptography) has some advice in that case:
https://cryptography.io/en/latest/random-numbers/
It should be fine to replace mksalt with:
int.from_bytes(os.urandom(16), byteorder="big")
On python 3.6 and later an option would be:
int.from_bytes(secrets.token_bytes(16), byteorder="big")
No new libraries required.
@Jc2k sounds good, this should be the solution.
Hey @a3135134,
can you try with branch fix_185_homekit_on_windows
? I removed the dependency to crypt in that.
Hey @a3135134,
can you try with branch
fix_185_homekit_on_windows
? I removed the dependency to crypt in that.
I placed the homekit directory into python lib.
python -m homekit.discover
Traceback (most recent call last):
File "E:\Python3\lib\runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "E:\Python3\lib\runpy.py", line 109, in _get_module_details
import(pkg_name)
File "E:\Python3\lib\site-packages\homekit__init.py", line 26, in
I tried pip install tlv8. Here's a different error File "E:\Python3\lib\site-packages\zeroconf.py", line 1817, in init self._listen_socket.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, _value) OSError: [WinError 10042]
Fixed the issue with tlv8
.
Is there nothing behind the OSError: [WinError 10042]
?
close was not intended?
Fixed the issue with
tlv8
.Is there nothing behind the
OSError: [WinError 10042]
?
I think this is another problem. I'll have a check first OSError: [WinError 10042] An unknown, invalid, or unsupported option or level specified in the getsockopt or setsockopt call.
So I was able to install homekit_python on a win 10 VM.
py.exe -m venv venv
Set-ExecutionPolicy Bypass -Scope Process -Force;
.\venv\Scripts\activate
&'C:\Program Files\Git\bin\git.exe' clone https://github.com/jlusiardi/homekit_python.git
cd homekit_python
&'C:\Program Files\Git\bin\git.exe' checkout fix_185_homekit_on_windows
pip3 install .[IP]
py.exe -m homekit.discover
to check for homekit accessories. This wants to access network, so you might want to allow that.Results: One of my accessories is found
Name: Koogeek-P1-770D90._hap._tcp.local.
Url: http_impl://192.168.178.200:80
Configuration number (c#): 2
Feature Flags (ff): Supports HAP Pairing (Flag: 1)
Device ID (id): 44:AF:68:9E:5D:17
Model Name (md): P1EU
Protocol Version (pv): 1.1
State Number (s#): 1
Status Flags (sf): Accessory has been paired. (Flag: 0)
Category Identifier (ci): Outlet (Id: 7)
@a3135134 does this work for you?
I use win 10 and install this python module. However, it raises ModuleNotFoundError: No module named '_crypt' . It seems _crypt only work on Unix/Linux, so this library also only support Linux?