mochipon / pysesame3

Unofficial Python Library to communicate with SESAME 3 series products from CANDY HOUSE, Inc.
https://pysesame3.readthedocs.io/en/stable/
Other
22 stars 2 forks source link

[Request]: Home Assistant Integration #61

Closed mochipon closed 3 years ago

mochipon commented 3 years ago

Describe the solution you'd like - リクエストの内容

As the subject line suggests.

What's the problem this feature will solve? - 解決したい内容

No response

Additional context - その他

No response

mochipon commented 3 years ago

I started to take it easy, but it seems to be more complicated than I thought.

I tried to create a custom component, but I couldn't install pysesame3[cognito] in the first place 🤣 I get an error while installing awscrt.

➜  ~ docker exec -it homeassistant pip install awscrt
Collecting awscrt
  Using cached awscrt-0.12.4.tar.gz (18.4 MB)
Building wheels for collected packages: awscrt
  Building wheel for awscrt (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/setup.py'"'"'; __file__='"'"'/tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-x5i2bo0c
       cwd: /tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/
  Complete output (52 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.9
  creating build/lib.linux-x86_64-3.9/awscrt
  copying awscrt/s3.py -> build/lib.linux-x86_64-3.9/awscrt
  copying awscrt/mqtt.py -> build/lib.linux-x86_64-3.9/awscrt
  copying awscrt/io.py -> build/lib.linux-x86_64-3.9/awscrt
  copying awscrt/http.py -> build/lib.linux-x86_64-3.9/awscrt
  copying awscrt/exceptions.py -> build/lib.linux-x86_64-3.9/awscrt
  copying awscrt/crypto.py -> build/lib.linux-x86_64-3.9/awscrt
  copying awscrt/common.py -> build/lib.linux-x86_64-3.9/awscrt
  copying awscrt/checksums.py -> build/lib.linux-x86_64-3.9/awscrt
  copying awscrt/auth.py -> build/lib.linux-x86_64-3.9/awscrt
  copying awscrt/_test.py -> build/lib.linux-x86_64-3.9/awscrt
  copying awscrt/__init__.py -> build/lib.linux-x86_64-3.9/awscrt
  creating build/lib.linux-x86_64-3.9/awscrt/eventstream
  copying awscrt/eventstream/rpc.py -> build/lib.linux-x86_64-3.9/awscrt/eventstream
  copying awscrt/eventstream/__init__.py -> build/lib.linux-x86_64-3.9/awscrt/eventstream
  running build_ext
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/setup.py", line 286, in <module>
      setuptools.setup(
    File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "/usr/local/lib/python3.9/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/local/lib/python3.9/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/usr/local/lib/python3.9/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 299, in run
      self.run_command('build')
    File "/usr/local/lib/python3.9/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/lib/python3.9/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.9/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/usr/local/lib/python3.9/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/lib/python3.9/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/setup.py", line 208, in run
      self._build_dependency(lib)
    File "/tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/setup.py", line 150, in _build_dependency
      cmake = get_cmake_path()
    File "/tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/setup.py", line 91, in get_cmake_path
      raise Exception("CMake must be installed to build from source.")
  Exception: CMake must be installed to build from source.
  ----------------------------------------
  ERROR: Failed building wheel for awscrt
  Running setup.py clean for awscrt
Failed to build awscrt
Installing collected packages: awscrt
    Running setup.py install for awscrt ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/setup.py'"'"'; __file__='"'"'/tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-d2y5_b9g/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.9/awscrt
         cwd: /tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/
    Complete output (54 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.9
    creating build/lib.linux-x86_64-3.9/awscrt
    copying awscrt/s3.py -> build/lib.linux-x86_64-3.9/awscrt
    copying awscrt/mqtt.py -> build/lib.linux-x86_64-3.9/awscrt
    copying awscrt/io.py -> build/lib.linux-x86_64-3.9/awscrt
    copying awscrt/http.py -> build/lib.linux-x86_64-3.9/awscrt
    copying awscrt/exceptions.py -> build/lib.linux-x86_64-3.9/awscrt
    copying awscrt/crypto.py -> build/lib.linux-x86_64-3.9/awscrt
    copying awscrt/common.py -> build/lib.linux-x86_64-3.9/awscrt
    copying awscrt/checksums.py -> build/lib.linux-x86_64-3.9/awscrt
    copying awscrt/auth.py -> build/lib.linux-x86_64-3.9/awscrt
    copying awscrt/_test.py -> build/lib.linux-x86_64-3.9/awscrt
    copying awscrt/__init__.py -> build/lib.linux-x86_64-3.9/awscrt
    creating build/lib.linux-x86_64-3.9/awscrt/eventstream
    copying awscrt/eventstream/rpc.py -> build/lib.linux-x86_64-3.9/awscrt/eventstream
    copying awscrt/eventstream/__init__.py -> build/lib.linux-x86_64-3.9/awscrt/eventstream
    running build_ext
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/setup.py", line 286, in <module>
        setuptools.setup(
      File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/usr/local/lib/python3.9/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/local/lib/python3.9/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/local/lib/python3.9/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python3.9/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/local/lib/python3.9/distutils/command/install.py", line 546, in run
        self.run_command('build')
      File "/usr/local/lib/python3.9/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/lib/python3.9/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python3.9/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/usr/local/lib/python3.9/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/lib/python3.9/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/setup.py", line 208, in run
        self._build_dependency(lib)
      File "/tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/setup.py", line 150, in _build_dependency
        cmake = get_cmake_path()
      File "/tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/setup.py", line 91, in get_cmake_path
        raise Exception("CMake must be installed to build from source.")
    Exception: CMake must be installed to build from source.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/setup.py'"'"'; __file__='"'"'/tmp/pip-install-2_utdjrz/awscrt_d31290ec762048278be5de5a73efc288/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-d2y5_b9g/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.9/awscrt Check the logs for full command output.

Yes, this is clearly not trying to install a pre-compiled build, but trying to build in my environment. Then I checked to see for which environments the pre-compiled builds were provided, and if the Home Assistant environment was not included in that.

➜  ~ docker exec -it homeassistant pip debug -v
WARNING: This command is only meant for debugging. Do not use this with automation for parsing and getting these details, since the output and options of this command may change without notice.
pip version: pip 21.2.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
sys.version: 3.9.7 (default, Sep  9 2021, 11:03:41)
[GCC 10.3.1 20210424]
sys.executable: /usr/local/bin/python
sys.getdefaultencoding: utf-8
sys.getfilesystemencoding: utf-8
locale.getpreferredencoding: UTF-8
sys.platform: linux
sys.implementation:
  name: cpython
'cert' config value: Not specified
REQUESTS_CA_BUNDLE: None
CURL_CA_BUNDLE: None
pip._vendor.certifi.where(): /usr/local/lib/python3.9/site-packages/pip/_vendor/certifi/cacert.pem
pip._vendor.DEBUNDLED: False
vendored library versions:
  appdirs==1.4.4
  CacheControl==0.12.6
  colorama==0.4.4
  distlib==0.3.2
  distro==1.5.0 (Unable to locate actual module version, using vendor.txt specified version)
  html5lib==1.1
  msgpack==1.0.2 (Unable to locate actual module version, using vendor.txt specified version)
  packaging==21.0
  pep517==0.11.0
  progress==1.5
  pyparsing==2.4.7
  requests==2.26.0
  certifi==2021.05.30
  chardet==4.0.0
  idna==3.2
  urllib3==1.26.6
  resolvelib==0.7.1
  setuptools==44.0.0 (Unable to locate actual module version, using vendor.txt specified version)
  six==1.16.0
  tenacity==8.0.1 (Unable to locate actual module version, using vendor.txt specified version)
  tomli==1.0.3
  webencodings==0.5.1 (Unable to locate actual module version, using vendor.txt specified version)
Compatible tags: 96
  cp39-cp39-musllinux_1_2_x86_64
  cp39-cp39-musllinux_1_1_x86_64
  cp39-cp39-musllinux_1_0_x86_64
  cp39-cp39-linux_x86_64
  cp39-abi3-musllinux_1_2_x86_64
  cp39-abi3-musllinux_1_1_x86_64
  cp39-abi3-musllinux_1_0_x86_64
  cp39-abi3-linux_x86_64
  cp39-none-musllinux_1_2_x86_64
  cp39-none-musllinux_1_1_x86_64
  cp39-none-musllinux_1_0_x86_64
  cp39-none-linux_x86_64
  cp38-abi3-musllinux_1_2_x86_64
  cp38-abi3-musllinux_1_1_x86_64
  cp38-abi3-musllinux_1_0_x86_64
  cp38-abi3-linux_x86_64
  cp37-abi3-musllinux_1_2_x86_64
  cp37-abi3-musllinux_1_1_x86_64
  cp37-abi3-musllinux_1_0_x86_64
  cp37-abi3-linux_x86_64
  cp36-abi3-musllinux_1_2_x86_64
  cp36-abi3-musllinux_1_1_x86_64
  cp36-abi3-musllinux_1_0_x86_64
  cp36-abi3-linux_x86_64
  cp35-abi3-musllinux_1_2_x86_64
  cp35-abi3-musllinux_1_1_x86_64
  cp35-abi3-musllinux_1_0_x86_64
  cp35-abi3-linux_x86_64
  cp34-abi3-musllinux_1_2_x86_64
  cp34-abi3-musllinux_1_1_x86_64
  cp34-abi3-musllinux_1_0_x86_64
  cp34-abi3-linux_x86_64
  cp33-abi3-musllinux_1_2_x86_64
  cp33-abi3-musllinux_1_1_x86_64
  cp33-abi3-musllinux_1_0_x86_64
  cp33-abi3-linux_x86_64
  cp32-abi3-musllinux_1_2_x86_64
  cp32-abi3-musllinux_1_1_x86_64
  cp32-abi3-musllinux_1_0_x86_64
  cp32-abi3-linux_x86_64
  py39-none-musllinux_1_2_x86_64
  py39-none-musllinux_1_1_x86_64
  py39-none-musllinux_1_0_x86_64
  py39-none-linux_x86_64
  py3-none-musllinux_1_2_x86_64
  py3-none-musllinux_1_1_x86_64
  py3-none-musllinux_1_0_x86_64
  py3-none-linux_x86_64
  py38-none-musllinux_1_2_x86_64
  py38-none-musllinux_1_1_x86_64
  py38-none-musllinux_1_0_x86_64
  py38-none-linux_x86_64
  py37-none-musllinux_1_2_x86_64
  py37-none-musllinux_1_1_x86_64
  py37-none-musllinux_1_0_x86_64
  py37-none-linux_x86_64
  py36-none-musllinux_1_2_x86_64
  py36-none-musllinux_1_1_x86_64
  py36-none-musllinux_1_0_x86_64
  py36-none-linux_x86_64
  py35-none-musllinux_1_2_x86_64
  py35-none-musllinux_1_1_x86_64
  py35-none-musllinux_1_0_x86_64
  py35-none-linux_x86_64
  py34-none-musllinux_1_2_x86_64
  py34-none-musllinux_1_1_x86_64
  py34-none-musllinux_1_0_x86_64
  py34-none-linux_x86_64
  py33-none-musllinux_1_2_x86_64
  py33-none-musllinux_1_1_x86_64
  py33-none-musllinux_1_0_x86_64
  py33-none-linux_x86_64
  py32-none-musllinux_1_2_x86_64
  py32-none-musllinux_1_1_x86_64
  py32-none-musllinux_1_0_x86_64
  py32-none-linux_x86_64
  py31-none-musllinux_1_2_x86_64
  py31-none-musllinux_1_1_x86_64
  py31-none-musllinux_1_0_x86_64
  py31-none-linux_x86_64
  py30-none-musllinux_1_2_x86_64
  py30-none-musllinux_1_1_x86_64
  py30-none-musllinux_1_0_x86_64
  py30-none-linux_x86_64
  cp39-none-any
  py39-none-any
  py3-none-any
  py38-none-any
  py37-none-any
  py36-none-any
  py35-none-any
  py34-none-any
  py33-none-any
  py32-none-any
  py31-none-any
  py30-none-any

/(^o^)\

The container apparently relies on musl libc instead of glibc, and awscrt does not provide pre-built binaries for such an environment. I have just filed the issue, but it will probably take a long time to get official binaries.

mochipon commented 3 years ago

I am not familiar with the culture of Home Assistant, but I am 99% sure that installing various dependencies (e.g., cmake, python3-dev etc.) into the homeassistant container is the wrong way.

I found custom_deps add-on that installs dependencies under /config/deps. However, in Home Assistant Operating System environment, which I believe is the most commonly used, they should be installed globally in the container, not in /config/deps. But, again, installing awscrt at the container fails due to the lack of build dependencies.

I actually lost the right way to go. I decided to suspend this at this moment, and will start to create a script like mqtt2sesame. It is not a straightforward approach, but a pretty realistic compromise.