home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.71k stars 30.84k forks source link

Implement Somfy local API in Overkiz integration #69558

Closed iMicknl closed 12 months ago

iMicknl commented 2 years ago

The problem

Somfy just announced the Somfy TaHoma Developer Mode, which offers a local API on eligble TaHoma boxes (TaHoma V2, TaHoma switch, TaHoma DIN-Rail v1 & v2).

They also announced that they are sunsetting the Somfy Open API, which is used by the Somfy integration. The API will be supported until June 21st 2022.

The local API is based on the same architecture as the current Overkiz integration in core, thus it would make sense to sunset the Somfy integration and add local support to the Overkiz integration.

Full Announcement > Dear customer, > > We are glad to contact you today for the release of a new service we call Developer Mode, available for the different types of TaHoma boxes*. > > This new service allows to activate a local API on your TaHoma box and finally connect third-party software to your equipment. A complete documentation of the service is available on [GitHub](https://somfy.us17.list-manage.com/track/click?u=2969767755c736684ad240968&id=acdead4d39&e=cc7b34f13b). In a nutshell, the API allows to monitor and control the devices which are paired locally with your TaHoma box without the constraint of going through our servers. Thanks to the new Developer Mode, you can easily integrate your Somfy equipment with third-party home automation softwares. > > **Support** > Our support teams are available for any problems or questions regarding the use or operation of the TaHoma system. > However, for questions related to the development of third party software using the API, please refer to the page mentioned above for further details. > Finally, for problems or questions concerning the use of said software, it is necessary to contact the supplier or developer of the chosen solution directly for assistance. > > **Warning** > The applications proposed by Somfy to use its boxes and connected solutions employ a certain number of rules designed to preserve the integrity of your equipment. Please be careful when using the API so as not to damage them. Somfy declines all responsibility for inappropriate use. Similarly, the use of the TaHoma application in conjunction with the API may cause conflicts or contrary actions for which Somfy cannot be held responsible. Also, to ensure the proper functioning of your box, be sure to limit the demands on it. > > **Sunsetting Somfy Open API** > It is always hard to say goodbye but Developer Mode is so much better ! Its release therefore announces the depreciation of the Somfy Open API (cloud-based) as the new service will provide a larger number of features (scenarios and group commands being included) but also a larger number of supported devices. Finally, the Developer Mode, by its local nature, avoid any downtime issue or traffic limitation. > > If you are a Somfy Open API customer, from the entire Somfy team, we’d like to apologize for any inconvenience this may cause you. We’re committed to making the transition as smooth as possible and that’s why we’ll continue to support this API until June 21st 2022. > > Thank you for your understanding and we hope you will enjoy this new service. > > *Eligible TaHoma Boxes: TaHoma V2, TaHoma switch, TaHoma DIN-Rail v1 & v2 >

TODO

Integration causing the issue

overkiz, somfy

Link to integration documentation on our website

https://www.home-assistant.io/integrations/overkiz/ https://www.home-assistant.io/integrations/somfy/

probot-home-assistant[bot] commented 2 years ago

overkiz documentation overkiz source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @vlebourl, @tetienne, mind taking a look at this issue as it has been labeled with an integration (overkiz) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

downdrown commented 2 years ago

This actually sounds awesome! I have had quite a lot of issues with the cloud API limitations. Is there anything I can help with? I'm really looking forward to this being live in the Overkiz integration! 🚀

iMicknl commented 2 years ago

This actually sounds awesome! I have had quite a lot of issues with the cloud API limitations. Is there anything I can help with? I'm really looking forward to this being live in the Overkiz integration! 🚀

We have a proof of concept working, however we wait until a fix on Somfy's side is released (https://github.com/Somfy-Developer/Somfy-TaHoma-Developer-Mode/issues/4). Until then, we cannot move forward.

EDelsman commented 2 years ago

Grateful for all your effort, but I am getting nervous. The fix this was waiting for seems fixed some time ago, and the old integration is deprecated. Wasn't this supposed to be in the 2022.6 release? This is needed withing three weeks, so it cannot wait till the next major release 2022.7.

XalaTheShepard commented 2 years ago

@EDelsman , if I am not mistaking the depreciation of the Somfy API only affects the Somfy integration and not the Overkiz integration since they both use different login authentifications.

EDelsman commented 2 years ago

Thanks. Let's hope you are indeed not mistaking ;-)

XalaTheShepard commented 2 years ago

It was also mentioned in the 2022.6.0 release notes

EDelsman commented 2 years ago

I read those, but they just said: Switch to Overkiz. So I turned to the documentation, that states: "The Somfy Open API (cloud-based) has been deprecated in favor of the Somfy TaHoma Developer Mode and will shut down after June 21st, 2022. The Overkiz integration will support this new local API and can already be used to control your Somfy devices via the cloud."

So that the first deprecated cloud based is different from the second was not clear to me. I read in it that I should switch to local instead (Which I greatly prefer).

XalaTheShepard commented 2 years ago

They use different logins.

donparlor commented 2 years ago

For those using Somfy MyLink, does this deprecated Somfy integration will affect our HA instance?

iMicknl commented 2 years ago

For those using Somfy MyLink, does this deprecated Somfy integration will affect our HA instance?

Since it is a separate integration, I would assume you won’t face any issues. This will use a different connection than the deprecated ‘Open with Somfy API’.

donparlor commented 2 years ago

Ok great! I guess you are right, I don't feel on a hurry anymore 😂

Have a good day!

chheiss commented 2 years ago

And news here? Local access would be extremely great! I can test, if that helps.

Mariusthvdb commented 2 years ago

so do: https://community.home-assistant.io/t/overkiz-api-and-somfy-api/61448/1829

rjlee commented 2 years ago

Adding a report here as per request in: https://community.home-assistant.io/t/overkiz-api-and-somfy-api/61448/1882

Results from testing the local integration branch following the instructions here: https://community.home-assistant.io/t/overkiz-api-and-somfy-api/61448/1829

My Tahoma Box is: https://www.somfy.me/en-gc/products/2401346/tahoma-box-home-automation and 'Developer Mode' is activated via the Somfy site.

HA version:

Home Assistant 2022.10.4
Frontend 20221010.0 - latest

Observed Behaviour

Autodiscovery of my Tahoma Hub occurs, although multiple instances of the same Hub are detected, although only one has the gateway.local address, others just prompt for the username and password.

Picking the one with the gateway.local address prompts for the username and password with the gateway address prepopulated:

screencapture-ha

Adding my username and password, this then completes, but the following error is shown in the home-assistant.log and the Overkiz integration is marked as 'Failed to Setup'.

Logger: homeassistant.config_entries
Source: custom_components/overkiz/__init__.py:64
Integration: Overkiz
First occurred: 10:48:16 (1 occurrences)
Last logged: 10:48:16

Error setting up entry gateway-XXXX-XXXX-XXXX.local:8443 for overkiz
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 365, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/overkiz/__init__.py", line 64, in async_setup_entry
    token = entry.data[CONF_TOKEN]
KeyError: 'token'
iMicknl commented 2 years ago

Thanks @rjlee! I will have a look why this can happen. Are there no other errors in the log? It seems that there is no token generated in the config flow, thus the next steps fail as well. I will see if I can make this more robust in an updated version :).

rjlee commented 2 years ago

No problem, thanks for the hard work. A quick review of the logs doesn't show any additional errors:

grep -i overkiz home-assistant.log
2022-10-19 09:47:25.572 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration overkiz which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2022-10-19 09:48:16.837 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry gateway-XXX-XXXX-XXXX.local:8443 for overkiz
  File "/config/custom_components/overkiz/__init__.py", line 64, in async_setup_entry
slyoldfox commented 2 years ago

@iMicknl

I had the same error locally and added some debug strings.

If I understand correctly, it seems that async_validate_input drops back to the else: statement. The check:

68         if user_input[CONF_HUB] == LOCAL:
69             LOGGER.error("LOCAL")
70             session = async_create_clientsession(self.hass)

Does not match because the value is actually somfy_europe. After changing that check I was able to setup the integration correctly (not sure if it's now actually talking locally) :-)

rjlee commented 2 years ago

I've done a bit more debugging. I've enabled debug and I now see this logline:

CONFIGURING LOCAL INTEGRATION

So, it's activating:

    # Local API vs Cloud API
    # TODO add a helper function to see if local API
    if entry.data.get(CONF_HOST):
        LOGGER.debug("CONFIGURING LOCAL INTEGRATION")
        host = entry.data[CONF_HOST]
        token = entry.data[CONF_TOKEN]

        # Verify SSL blocked by https://github.com/Somfy-Developer/Somfy-TaHoma-Developer-Mode/issues/5
        # Somfy (self-signed) SSL cert uses the wrong common name
        session = async_create_clientsession(hass, verify_ssl=False)

Permalink

Which fails on:

File "/config/custom_components/overkiz/__init__.py", line 67, in async_setup_entry
    token = entry.data[CONF_TOKEN]
KeyError: 'token'

Dumping entry.data gives:

{'host': 'gateway-xxxx-xxxx-xxxx.local:8443', 'username': 'a@b.com', 'password': 'mypassword', 'hub': 'somfy_europe'}

From searching the code, I can't see anywhere that CONF_TOKEN gets set though, so I assume that's the issue.

Then, as per https://github.com/home-assistant/core/issues/69558#issuecomment-1284398066

I tried to force local instantiation via changing:

68         if user_input[CONF_HUB] == LOCAL:
69             LOGGER.error("LOCAL")
70             session = async_create_clientsession(self.hass)

To

68         if user_input[CONF_HUB] == 'somfy_europe':
69             LOGGER.error("LOCAL")
70             session = async_create_clientsession(self.hass)

This seemed to get further, but ultimately ended up with an error from pyoverkiz:

Not such token with UUID: aaa-bbb-ccc-ddd

Dumping token and uuid both seem to have valid values FWIW. Checking pyoverkiz shows the latest version is installed in the docker container:

 pip list | grep pyover
pyoverkiz                        1.5.5

At that point, I'm stuck, so hopefully that's helpful.

slyoldfox commented 2 years ago

@rjlee I think I had this at one point as well.

I'm not sure what I did though. Maybe the token is cached on disk and it didn't delete it (I think I saw that skimming through the code?).

Did you delete the integration after changing the line and restart - then readded it?

rjlee commented 2 years ago

After some debugging, I figured it out. The gateway-XXX-XXXX-XXXX.local:8443 doesn't appear to be resolvable on my network, so setting it to the IP address of my Tahama Box 192.168.x.x:8443 and the following change made it work for me:

LOCAL = "somfy_europe"
#LOCAL = "local"
LOCAL_HUB = {
    LOCAL: OverkizServer(
        name="Somfy TaHoma Developer Mode (local API)",
        endpoint="",
        manufacturer="Somfy",
        configuration_url=None,
    )
}

So as per https://github.com/home-assistant/core/issues/69558#issuecomment-1284398066.

@slyoldfox thanks for the help.

@iMicknl FYI - on the issue I experienced and a potential fix.

The only issue that remains is the autodiscovery of multiple instances of the Tahoma hub on the devices page, but that's more an annoyance than a blocker.

Hope that helps.

slyoldfox commented 2 years ago

Ah yah. That was it lol. The exception ended there but the root cause was an Address Could Not Be Resolved exception.

We might need to fix that first. The possible reason is that this is discovered using mdns (?) but my freshly setup ubuntu server doesn't hook into that.

I ended up adding it to my /etc/hosts file:

192.168.2.30 gateway-2017-0514-1111.local

I'm not sure if the hub responds with its IP address somewhere so we can use that instead during the setup?

iMicknl commented 2 years ago

@slyoldfox that is interesting. My preference is to use the mdns address, but the Config Flow will accept the IP address as well for cases where the mdns address cannot be resolved.

slyoldfox commented 2 years ago

Well yes of course the mdns address must be the first option. But if the actual resolving fails during config flow, it would be interesting to have a better handling:

slyoldfox commented 2 years ago

For reference this is the stacktrace:

2022-10-20 15:45:00.418 ERROR (MainThread) [custom_components.overkiz] Not such token with UUID: f5a3dcdd-ac10-3e01-6199-5f1124cfffbf
Traceback (most recent call last):
  File "/home/hass/homeassistant/lib/python3.10/site-packages/aiohttp/connector.py", line 1154, in _create_direct_connection
    hosts = await asyncio.shield(host_resolved)
  File "/home/hass/homeassistant/lib/python3.10/site-packages/aiohttp/connector.py", line 880, in _resolve_host
    addrs = await self._resolver.resolve(host, port, family=self._family)
  File "/home/hass/homeassistant/lib/python3.10/site-packages/aiohttp/resolver.py", line 33, in resolve
    infos = await self._loop.getaddrinfo(
  File "/usr/lib/python3.10/asyncio/base_events.py", line 860, in getaddrinfo
    return await self.run_in_executor(
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

Traceback (most recent call last):
  File "/home/hass/.homeassistant/custom_components/overkiz/config_flow.py", line 112, in async_validate_input
    await local_client.login()
  File "/home/hass/homeassistant/lib/python3.10/site-packages/pyoverkiz/client.py", line 159, in login
    await self.register_event_listener()
  File "/home/hass/homeassistant/lib/python3.10/site-packages/backoff/_async.py", line 133, in retry
    ret = await target(*args, **kwargs)
  File "/home/hass/homeassistant/lib/python3.10/site-packages/pyoverkiz/client.py", line 528, in register_event_listener
    response = await self.__post("events/register")
  File "/home/hass/homeassistant/lib/python3.10/site-packages/pyoverkiz/client.py", line 775, in __post
    async with self.session.post(
  File "/home/hass/homeassistant/lib/python3.10/site-packages/aiohttp/client.py", line 1138, in __aenter__
    self._resp = await self._coro
  File "/home/hass/homeassistant/lib/python3.10/site-packages/aiohttp/client.py", line 535, in _request
    conn = await self._connector.connect(
  File "/home/hass/homeassistant/lib/python3.10/site-packages/aiohttp/connector.py", line 542, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/home/hass/homeassistant/lib/python3.10/site-packages/aiohttp/connector.py", line 907, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/home/hass/homeassistant/lib/python3.10/site-packages/aiohttp/connector.py", line 1166, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host gateway-2017-0459-8156.local:8443 ssl:default [Temporary failure in name resolution]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/hass/.homeassistant/custom_components/overkiz/config_flow.py", line 245, in async_step_local
    user_input = await self.async_validate_input(user_input)
  File "/home/hass/.homeassistant/custom_components/overkiz/config_flow.py", line 114, in async_validate_input
    await client.delete_local_token(gateway_id, uuid)
  File "/home/hass/homeassistant/lib/python3.10/site-packages/backoff/_async.py", line 133, in retry
    ret = await target(*args, **kwargs)
  File "/home/hass/homeassistant/lib/python3.10/site-packages/pyoverkiz/client.py", line 727, in delete_local_token
    await self.__delete(f"config/{gateway_id}/local/tokens/{uuid}")
  File "/home/hass/homeassistant/lib/python3.10/site-packages/pyoverkiz/client.py", line 793, in __delete
    await self.check_response(response)
  File "/home/hass/homeassistant/lib/python3.10/site-packages/pyoverkiz/client.py", line 864, in check_response
    raise NotSuchTokenException(message)
pyoverkiz.exceptions.NotSuchTokenException: Not such token with UUID: f5a3dcdd-ac10-3e01-6399-5f1124ca0abf
HpNoTiQ56 commented 2 years ago

After some debugging, I figured it out. The gateway-XXX-XXXX-XXXX.local:8443 doesn't appear to be resolvable on my network, so setting it to the IP address of my Tahama Box 192.168.x.x:8443 and the following change made it work for me:

LOCAL = "somfy_europe"
#LOCAL = "local"
LOCAL_HUB = {
    LOCAL: OverkizServer(
        name="Somfy TaHoma Developer Mode (local API)",
        endpoint="",
        manufacturer="Somfy",
        configuration_url=None,
    )
}

So as per #69558 (comment).

@slyoldfox thanks for the help.

@iMicknl FYI - on the issue I experienced and a potential fix.

The only issue that remains is the autodiscovery of multiple instances of the Tahoma hub on the devices page, but that's more an annoyance than a blocker.

Hope that helps.

Thank you! I've managed to get it to work instantly by using IP!

nyroDev commented 2 years ago

@slyoldfox that is interesting. My preference is to use the mdns address, but the Config Flow will accept the IP address as well for cases where the mdns address cannot be resolved.

While I tested the local API, i did have the same issue: only IP address worked. In my understanding, it was due to the dev container and the way HA was loaded locally, which makes impossible to reach the host. it would need more testing while others elements will be finished, but IMHO this is not an issue real users will have.

diedvdyk commented 2 years ago

My Tahoma box registers itself in my DHCP as xxxx-xxxx-xxxx where they x's are the serial number of the box, no "gateway" infront of it and no .local after it . After entering xxxx-xxxx-xxxx.mylocaldomain.yy:8443 the local api works super (where mylocaldomain.yy is my local domain) . I hope this helps.

iMicknl commented 2 years ago

@diedvdyk do you have any special networking setup? I don’t think this is default behavior at all..

diedvdyk commented 2 years ago

@iMicknl It must has been changed in the past years. I remove my static lease and yes now it registers itself as gateway-xxxx-xxxx-xxxx . So you are right. But dont please the .local domain as default. It's usually used in mDNS what isnt configured well on most unix systems.

diedvdyk commented 2 years ago

Latest beta 2022.11b1 gives this error

2022-10-28 08:57:53.661 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing platform custom_components.overkiz.select Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 728, in get_platform cache[full_name] = self._import_platform(platform_name) File "/usr/src/homeassistant/homeassistant/loader.py", line 745, in _import_platform return importlib.import_module(f"{self.pkg_path}.{platform_name}") File "/usr/local/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/config/custom_components/overkiz/select.py", line 29, in class OverkizSelectDescription(SelectEntityDescription, OverkizSelectDescriptionMixin): File "/usr/local/lib/python3.10/dataclasses.py", line 1185, in dataclass return wrap(cls) File "/usr/local/lib/python3.10/dataclasses.py", line 1176, in wrap return _process_class(cls, init, repr, eq, order, unsafe_hash, File "/usr/local/lib/python3.10/dataclasses.py", line 1025, in _process_class _init_fn(all_init_fields, File "/usr/local/lib/python3.10/dataclasses.py", line 546, in _init_fn raise TypeError(f'non-default argument {f.name!r} ' TypeError: non-default argument 'select_option' follows default argument 2022-10-28 08:57:53.707 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform overkiz.select: Platform not found (Exception importing custom_components.overkiz.select).

iMicknl commented 2 years ago

@diedvdyk please download the latest version. I just rebased it on dev. There has been a breaking change in core (select entity) which caused this.

@iMicknl It must has been changed in the past years. I remove my static lease and yes now it registers itself as gateway-xxxx-xxxx-xxxx . So you are right. But dont please the .local domain as default. It's usually used in mDNS what isnt configured well on most unix systems.

I will have a look. We will need to see what the best default is after user testing (with supported HA installations), for power users they can change it manually for sure.

diedvdyk commented 2 years ago

@iMicknl Downloading the latest version solved the error. Thanks.

dick1980 commented 2 years ago

Just installed this newer version after the previous one broke after core update (had it working for about 3 months now). I'm now receiving an "unknown error" upon starting the integration flow from the "Configure" button in the integrations view, and then selecting the local API option.

Core log: Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 82, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper result = await method(view, request, data, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 280, in async_configure result = await self._async_handle_step( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/config/custom_components/overkiz/config_flow.py", line 141, in async_step_user return await self.async_step_local() File "/config/custom_components/overkiz/config_flow.py", line 302, in async_step_local description_placeholders=description_placeholders, NameError: name 'description_placeholders' is not defined

I've tried configuring a new instance (auto discovery already shows 5...), but that function does not respond (unable to click on it).

HpNoTiQ56 commented 2 years ago

Same problem here : My log : Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 225, in async_init flow, result = await task File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in _async_init result = await self._async_handle_step(flow, flow.init_step, data, init_done) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/config/custom_components/overkiz/config_flow.py", line 340, in async_step_zeroconf return await self.async_step_local() File "/config/custom_components/overkiz/config_flow.py", line 302, in async_step_local description_placeholders=description_placeholders, NameError: name 'description_placeholders' is not defined

chheiss commented 2 years ago

Same problem here! Not working anymore since update to 2022.11.1, even with current dev repository version.

iMicknl commented 2 years ago

I will have a look. Thanks for reporting.

iMicknl commented 2 years ago

@chheiss, @HpNoTiQ56, @dick1980 fixed! If you download the latest version, it will work again.

HpNoTiQ56 commented 2 years ago

@chheiss, @HpNoTiQ56, @dick1980 fixed! If you download the latest version, it will work again.

Auto config works but token error is back even using ip adress : `Logger: homeassistant.config_entries Source: custom_components/overkiz/init.py:64 Integration: Custom Overkiz PR#71644 First occurred: 20:13:12 (1 occurrences) Last logged: 20:13:12

Error setting up entry 192.168.1.19:8443 for overkiz Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 365, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/overkiz/init.py", line 64, in async_setup_entry token = entry.data[CONF_TOKEN] KeyError: 'token'`

Can't manually add new connection (click on button won't go any further!)

chheiss commented 2 years ago

I am getting these:

2022-11-05 21:40:24.100 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration overkiz which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2022-11-05 21:40:24.106 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration overkiz which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2022-11-05 21:40:33.100 ERROR (SyncWorker_6) [homeassistant.util.package] Unable to install package pyoverkiz==1.4.2: ERROR: Cannot install pyoverkiz==1.4.2 because these package versions have conflicting dependencies. 2022-11-05 21:40:35.185 ERROR (SyncWorker_6) [homeassistant.util.package] Unable to install package pyoverkiz==1.4.2: ERROR: Cannot install pyoverkiz==1.4.2 because these package versions have conflicting dependencies. 2022-11-05 21:40:37.142 ERROR (SyncWorker_6) [homeassistant.util.package] Unable to install package pyoverkiz==1.4.2: ERROR: Cannot install pyoverkiz==1.4.2 because these package versions have conflicting dependencies. 2022-11-05 21:40:37.143 ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration overkiz: Requirements for overkiz not found: ['pyoverkiz==1.4.2'].

dick1980 commented 2 years ago

@chheiss, @HpNoTiQ56, @dick1980 fixed! If you download the latest version, it will work again.

That worked like a charm, thanks!

Not completely out of the woods yet, though. Now the local API is back up and running, I see an issue that I've already noticed before. All entities become unavailable with a frequent interval, exactly either on the minute or half a minute. Interval between this status is infrequent, but always exactly timed to the interval. See attached screenshot.

Scherm­afbeelding 2022-11-06 om 12 14 46

I'm using a 2019 Tahoma Box.

iMicknl commented 2 years ago

Let's discuss here: https://community.home-assistant.io/t/overkiz-integration-local-api-development-testers-topic/485264. I wonder why some people face the token error, are there no other statements in the log?

oscy commented 2 years ago

After some debugging, I figured it out. The gateway-XXX-XXXX-XXXX.local:8443 doesn't appear to be resolvable on my network, so setting it to the IP address of my Tahama Box 192.168.x.x:8443 and the following change made it work for me:

LOCAL = "somfy_europe"
#LOCAL = "local"
LOCAL_HUB = {
    LOCAL: OverkizServer(
        name="Somfy TaHoma Developer Mode (local API)",
        endpoint="",
        manufacturer="Somfy",
        configuration_url=None,
    )
}

So as per #69558 (comment).

@slyoldfox thanks for the help.

@iMicknl FYI - on the issue I experienced and a potential fix.

The only issue that remains is the autodiscovery of multiple instances of the Tahoma hub on the devices page, but that's more an annoyance than a blocker.

Hope that helps.

@rjlee
which file and what exactly was edited/replaced by:

LOCAL = "somfy_europe"

LOCAL = "local"

LOCAL_HUB = { LOCAL: OverkizServer( name="Somfy TaHoma Developer Mode (local API)", endpoint="", manufacturer="Somfy", configuration_url=None, ) }

rjlee commented 2 years ago

https://github.com/iMicknl/home-assistant-core/blob/5057da1b73fc207084a4b2892ceac8cfd8318bcb/homeassistant/components/overkiz/config_flow.py

@oscy just changing the value of LOCAL

oscy commented 2 years ago

@rjlee Thank you!

Seems like I got it to work now. The file looks a bit different now but editing these two lines:

47 LOCAL = "somfy_europe" 75 if user_input[CONF_HUB] == "somfy_europe":

And then the token problem disappeared when setting up.

oscy commented 2 years ago

Shortlived happiness. After a short instance of time I lose my devices. From the log I can see following error:

Felet härrör från en anpassad integration.

Logger: custom_components.overkiz
Source: helpers/update_coordinator.py:151
Integration: Custom Overkiz PR#71644
First occurred: 8 november 2022 22:02:57 (18 occurrences)
Last logged: 8 november 2022 23:47:08

Error requesting device events data: Cannot connect to host gateway-xxxx-xxxx-xxxx.local:8443 ssl:default [Invalid argument]

and also:

Unexpected error fetching device events data: "No registered event listener." Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh self.data = await self._async_update_data() File "/config/custom_components/overkiz/coordinator.py", line 71, in _async_update_data events = await self.client.fetch_events() File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 151, in retry ret = await target(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 151, in retry ret = await target(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 151, in retry ret = await target(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/pyoverkiz/client.py", line 552, in fetch_events response = await self.__post(f"events/{self.event_listener_id}/fetch") File "/usr/local/lib/python3.10/site-packages/pyoverkiz/client.py", line 778, in __post await self.check_response(response) File "/usr/local/lib/python3.10/site-packages/pyoverkiz/client.py", line 877, in check_response raise Exception(message if message else result) Exception: "No registered event listener."

ced236 commented 1 year ago

Hey there,

I have the feeling that the new integration (Overkiz way) works only for the Tahoma box. Does it work for the simple "Somfy protect pack" meaning only the alarm without the box? It seems to me that it does not work in my case (version 2022.10) but I must admit I have not checked yet the last version of the code. Anyway, I would be glad to contribute to support the simple pack "Somfy Protect" if needed.

vialcollet commented 1 year ago

Hi all Great work with adding support for the local API! When will this be deployed?

slyoldfox commented 1 year ago

There are still some open todo items as you can see above?