Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for HomeAssistant core #3

Open
chemelli74 opened this issue Nov 19, 2023 · 36 comments
Open

Support for HomeAssistant core #3

chemelli74 opened this issue Nov 19, 2023 · 36 comments

Comments

@chemelli74
Copy link

Hi,

is core supported somehow ?

Thank you in advance

@kevdliu
Copy link
Owner

kevdliu commented Nov 20, 2023

Yes, this is the custom component for home assistant core: https://github.com/kevdliu/hacs-anylist

@kevdliu kevdliu closed this as completed Nov 20, 2023
@chemelli74
Copy link
Author

Yes, this is the custom component for home assistant core: https://github.com/kevdliu/hacs-anylist

I read that:

This integration requires Home Assistant Addon For Anylist.

so seems not for core.
Am I missing something ?

@kevdliu
Copy link
Owner

kevdliu commented Nov 21, 2023

Oh are you referring to the "Home Assistant Core" installation method (https://www.home-assistant.io/installation/) where you're running home assistant in a python virtual environment?

@chemelli74
Copy link
Author

Oh are you referring to the "Home Assistant Core" installation method (https://www.home-assistant.io/installation/) where you're running home assistant in a python virtual environment?

Yes, Home Assistant Core ;-)
You can run it in several way, currently I run a docker image for it.

@chemelli74
Copy link
Author

Any news on that topic ?
Thank you

@kevdliu
Copy link
Owner

kevdliu commented Nov 23, 2023

Hmm so the addon itself only runs on HassOS I believe but all it contains is a nodejs server that serves requests for the anylist custom integration and that can technically run anywhere. If you download the index.js file from the repo you can modify the email, password, and port constants to your own and run the node server wherever you like.

@kevdliu
Copy link
Owner

kevdliu commented Dec 6, 2023

Just an update, I’m currently working on packaging the nodejs server in the addon into a standalone executable that the integration can execute so hopefully in the future the addon won’t be needed anymore.

@raducotescu
Copy link

I’m currently working on packaging the nodejs server in the addon into a standalone executable that the integration can execute

That would be amazing!

@kevdliu kevdliu reopened this Dec 14, 2023
@kevdliu
Copy link
Owner

kevdliu commented Dec 14, 2023

I just released a new version of the integration that adds support for binary servers. Instead of installing the addon, you can download the precompiled binary from here https://github.com/kevdliu/hassio-addon-anylist/releases (make sure to choose the right binary based on your OS and architecture). During installation of the integration, you can choose between using the addon server or the binary server. If you select the binary server option, you just have to enter the file path of the server binary file and your anylist email and password. The integration will then handle starting the server and passing it your anylist credentials.

The binary builds are also reproducible so you can verify its integrity by running the build command here https://github.com/kevdliu/hassio-addon-anylist/blob/main/anylist/build-anylist.txt and comparing the checksum of the resulting binary.

@kevdliu
Copy link
Owner

kevdliu commented Dec 14, 2023

It's pretty experimental so let me know if you run into any issues

@chemelli74
Copy link
Author

Hi @kevdliu sorry not reacting before but for some reason I was not notified of new activity on this issue.
Will test asap.

I would suggest an improvement on the installation method: why not asking the arch if the user select binary server and download the bits as part of the process ?

@chemelli74
Copy link
Author

vscode ➜ /workspaces/core/config$ python
Python 3.11.4 (main, Jun  7 2023, 18:32:58) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.system()
'Linux'
>>> platform.machine()
'x86_64'
>>> 

@chemelli74
Copy link
Author

index-linuxstatic-x64 is not working here:

OSError: [Errno 8] Exec format error: '/config/anylist-server'

Using Core docker container, that shows:

homeassistant-dev:/config# uname -a
Linux homeassistant-dev 4.4.302+ #69057 SMP Mon Nov 13 14:19:30 CST 2023 x86_64 Linux

@kevdliu
Copy link
Owner

kevdliu commented Feb 11, 2024

@chemelli74 could you tried the new binary I uploaded (https://github.com/kevdliu/hassio-addon-anylist/releases/download/v1.7.0b/index-linux-x64)? I only have an ARM linux computer so cannot test x86_64 linux myself.

@kevdliu
Copy link
Owner

kevdliu commented Feb 11, 2024

Hi @kevdliu sorry not reacting before but for some reason I was not notified of new activity on this issue. Will test asap.

I would suggest an improvement on the installation method: why not asking the arch if the user select binary server and download the bits as part of the process ?

Yeah I plan on eventually updating the setup wizard to include downloading the binaries as well. This is just a MVP to test how feasible the binary server installation method is.

@chemelli74
Copy link
Author

@chemelli74 could you tried the new binary I uploaded (https://github.com/kevdliu/hassio-addon-anylist/releases/download/v1.7.0b/index-linux-x64)? I only have an ARM linux computer so cannot test x86_64 linux myself.

Will do asap.

@chemelli74
Copy link
Author

I installed this index-linuxstatic-x64 and this is the result at each integration reload:

2024-02-14 12:05:56.306 INFO (MainThread) [anylist] Server binary successfully started
2024-02-14 12:05:56.306 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Anylist for todo
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 444, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/todo/__init__.py", line 201, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 183, in async_setup_entry
    raise ValueError("Config entry has already been setup!")
ValueError: Config entry has already been setup!
2024-02-14 12:05:56.710 INFO (anylist) [anylist] Server port: 28597
2024-02-14 12:05:56.710 INFO (anylist) [anylist] IP filter: 127.0.0.1
2024-02-14 12:05:56.710 INFO (anylist) [anylist] Credentials file: /config/.anylist_credentials

@dinki
Copy link

dinki commented Feb 25, 2024

@chemelli74 @kevdliu Did you guys manage to get this working? I too am using HA in Docker with the same arch that chemeli74 posted above.

@chemelli74
Copy link
Author

Hi @dinki , I did a step forward but still not working for me. Did you try on you side ?

@dinki
Copy link

dinki commented Feb 26, 2024

@chemelli74 I did give it a go but unfortunately this is what I see in the logs:

2024-02-25 17:27:41.317 ERROR (MainThread) [homeassistant.components.todo] Error while setting up anylist platform for todo
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1119, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1101, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1004, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 637, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 677, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 28597)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 344, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/anylist/todo.py", line 19, in async_setup_entry
    code, lists = await hass.data[DOMAIN].get_lists()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/anylist/__init__.py", line 284, in get_lists
    async with session.get(self.get_server_url("lists")) as response:
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 578, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 911, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1235, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1204, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1000, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 127.0.0.1:28597 ssl:default [Connect call failed ('127.0.0.1', 28597)]

Side note, it sure would be nice if HA addons would be generic enough to move to Docker. Seems like we can make any device we want work with HA but the addons are not so easy to push to Docker. Kind of ironic I think.

I've built some Docker containers before but never created my own Docker file. I think this might not be too difficult to create but I just don't have enough time to devote to trying :(

@kevdliu
Copy link
Owner

kevdliu commented Feb 26, 2024

Been busy for a while and hasn't gotten a chance to look at this. I'm working on creating a generic docker image that should work with normal docker installations.

I installed this index-linuxstatic-x64 and this is the result at each integration reload:

2024-02-14 12:05:56.306 INFO (MainThread) [anylist] Server binary successfully started
2024-02-14 12:05:56.306 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Anylist for todo
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 444, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/todo/__init__.py", line 201, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 183, in async_setup_entry
    raise ValueError("Config entry has already been setup!")
ValueError: Config entry has already been setup!
2024-02-14 12:05:56.710 INFO (anylist) [anylist] Server port: 28597
2024-02-14 12:05:56.710 INFO (anylist) [anylist] IP filter: 127.0.0.1
2024-02-14 12:05:56.710 INFO (anylist) [anylist] Credentials file: /config/.anylist_credentials

That error makes it look like there are multiple instances of the integration configured, which is currently not supported. Did you remove the integration before adding it back?

@chemelli74 I did give it a go but unfortunately this is what I see in the logs:

2024-02-25 17:27:41.317 ERROR (MainThread) [homeassistant.components.todo] Error while setting up anylist platform for todo
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1119, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1101, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1004, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 637, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 677, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 28597)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 344, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/anylist/todo.py", line 19, in async_setup_entry
    code, lists = await hass.data[DOMAIN].get_lists()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/anylist/__init__.py", line 284, in get_lists
    async with session.get(self.get_server_url("lists")) as response:
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 578, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 911, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1235, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1204, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1000, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 127.0.0.1:28597 ssl:default [Connect call failed ('127.0.0.1', 28597)]

Side note, it sure would be nice if HA addons would be generic enough to move to Docker. Seems like we can make any device we want work with HA but the addons are not so easy to push to Docker. Kind of ironic I think.

I've built some Docker containers before but never created my own Docker file. I think this might not be too difficult to create but I just don't have enough time to devote to trying :(

Are you using host or bridged networking for the HA container?

@chemelli74
Copy link
Author

That error makes it look like there are multiple instances of the integration configured, which is currently not supported. Did you remove the integration before adding it back?

Nope, I didn't.
Will try later

@chemelli74
Copy link
Author

Double checked, I have only 1 instance:

image

@dinki
Copy link

dinki commented Feb 27, 2024

Are you using host or bridged networking for the HA container?

I'm using host.

@kevdliu
Copy link
Owner

kevdliu commented Feb 28, 2024

Double checked, I have only 1 instance:

image

You mentioned the error message appears when you're restarting the integration. Does it also appear on boot if you restart home assistant?

@kevdliu
Copy link
Owner

kevdliu commented Feb 28, 2024

@chemelli74 I did give it a go but unfortunately this is what I see in the logs:

2024-02-25 17:27:41.317 ERROR (MainThread) [homeassistant.components.todo] Error while setting up anylist platform for todo
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1119, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1101, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1004, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 637, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 677, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 28597)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 344, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/anylist/todo.py", line 19, in async_setup_entry
    code, lists = await hass.data[DOMAIN].get_lists()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/anylist/__init__.py", line 284, in get_lists
    async with session.get(self.get_server_url("lists")) as response:
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 578, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 911, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1235, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1204, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1000, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 127.0.0.1:28597 ssl:default [Connect call failed ('127.0.0.1', 28597)]

Side note, it sure would be nice if HA addons would be generic enough to move to Docker. Seems like we can make any device we want work with HA but the addons are not so easy to push to Docker. Kind of ironic I think.

I've built some Docker containers before but never created my own Docker file. I think this might not be too difficult to create but I just don't have enough time to devote to trying :(

I've created a generic docker image for this addon. Check out docker-compose.yaml in the repo, or use the docker run command inside run-docker.txt

@chemelli74
Copy link
Author

Double checked, I have only 1 instance

You mentioned the error message appears when you're restarting the integration. Does it also appear on boot if you restart home assistant?

Yes, but seems not always

@dinki
Copy link

dinki commented Mar 1, 2024

I've created a generic docker image for this addon. Check out docker-compose.yaml in the repo, or use the docker run command inside run-docker.txt

Thank you for taking the time to do this! I'm happy to report it is working great. I do have a quick fix bug report for you though, the docker compose you have has an error. You should be using:

image: kevdliu/anylist

right now it is set to:

image: anylist

Which doesn't work as the repository is missing.

Again, many thanks!

@kevdliu
Copy link
Owner

kevdliu commented Mar 1, 2024

I've created a generic docker image for this addon. Check out docker-compose.yaml in the repo, or use the docker run command inside run-docker.txt

Thank you for taking the time to do this! I'm happy to report it is working great. I do have a quick fix bug report for you though, the docker compose you have has an error. You should be using:

image: kevdliu/anylist

right now it is set to:

image: anylist

Which doesn't work as the repository is missing.

Again, many thanks!

Good catch! Just updated the file.

@kevdliu
Copy link
Owner

kevdliu commented Mar 1, 2024

Double checked, I have only 1 instance

You mentioned the error message appears when you're restarting the integration. Does it also appear on boot if you restart home assistant?

Yes, but seems not always

Are you able to test the docker image? Could you see if the same error occurs when setting up the integration with docker instead?

@chemelli74
Copy link
Author

I was able to make it working in the end!

Please allow the ability to remove the "AnyList" description in front of all lists.

@kevdliu
Copy link
Owner

kevdliu commented Mar 22, 2024

I was able to make it working in the end!

Please allow the ability to remove the "AnyList" description in front of all lists.

Just pushed a new version that removes the prefix. You should be able to rename the list entity within home assistant.

@chemelli74
Copy link
Author

Thank you !!!

@kevdliu
Copy link
Owner

kevdliu commented Apr 16, 2024

@chemelli74 Out of curiosity are you using the binary server installation method or docker?

@chemelli74
Copy link
Author

@chemelli74 Out of curiosity are you using the binary server installation method or docker?

Binary server so far.

@chemelli74
Copy link
Author

Any a new version / release in sight ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants