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
71.13k stars 29.8k forks source link

Overkiz occasionally fails to connect with Somfy Tahoma Switch (local API) #108595

Open mf22433 opened 7 months ago

mf22433 commented 7 months ago

The problem

I see an issue that occurs from time to time with the Overkiz integration (error reports in the journal). I use this integration in combination with a Somfy Tahoma Switch to control 7 indoor stores and 3 outdoor screens (nothing else).
When it happens I lose connectivity with all stores/screens (the icons are grayed out). I believe it can reconnect by itself because I see that the journal mentions 42 occurences of this issue and I did not reload the integration 42 times, but sometime it happens when I want to activate the stores and then I have to reload the integration to fix it.

Note that Home Assistant OS (running in a VM on a QNAP NAS) and Tahoma Switch are on the same vlan.

Extract from the journal: _Logger: homeassistant.components.overkiz Source: helpers/update_coordinator.py:332 Integration: Overkiz (documentation, issues) First occurred: 09:02:49 (42 occurrences) Last logged: 17:52:26

Error fetching device events data: Failed to connect._

What version of Home Assistant Core has the issue?

2024-1-5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Overkiz

Link to integration documentation on our website

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

Diagnostics information

config_entry-overkiz-0f79b18d9073b8a79acd4d88a25ce006.json.txt

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 7 months ago

Hey there @imicknl, @vlebourl, @tetienne, @nyrodev, 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!

Code owner commands Code owners of `overkiz` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign overkiz` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


overkiz documentation overkiz source (message by IssueLinks)

mf22433 commented 7 months ago

After further check in the journals, I can see that this error actually happens very frequently (almost every 5min), the stores and screens become unknown. The connection is then restored automatically.

thikade commented 7 months ago

Seeing exactly the same issue as @mf22433, after switching from Cloud API to local API yesterday by uninstalling then re-installing integration. Basically it works, but devices go offline repeatedly (icons are grayed out). They come back online after few minutes. Also on HA version 2024-1-5, using latest Overkiz integration with a Somfy Tahoma/Connexoon device in local mode.

iMicknl commented 7 months ago

I can reproduce this, and will need to look further into this. We already retry multiple times when this error message occurs, but will probably need to make it even more robust. The error itself is hard to change and it seems that occasionally, the Somfy hub doesn't reply back..

Error fetching device events data: Failed to connect.

mf22433 commented 7 months ago

@thikade so you didn't see this issue when using the Cloud API? I went straight to the local API but perhaps if that fix the issue I may give a go at the Cloud API.

OrbitingOcelot commented 7 months ago

Same problem after switching to local API. @mf22433 for me the cloud API which I have used for years did not have this behaviour, but there were other issues (like servers offline d/t maintanence etc.) @iMicknl does this mean the somfy box randomly stops working? If so, is this something we can help by reporting upstream to the Somfy guys?

thikade commented 7 months ago

@mf22433 yes - no such problems with cloud API in the past ~1 year. I have just switched back to cloud API, and it works fine again. Wanted to get rid of cloud access, but this will have to wait ...

iMicknl commented 7 months ago

@OrbitingOcelot not sure. This error message is very generic and comes from the underlying HTTP libraries that we use... Often this means that the server refuses to connect / is not responding.

mathieudutour commented 7 months ago

I now have this error every 5min for a few days, which makes the integration kind of unusable with the Local API... It used to work perfectly fine last week.

I'm not sure if it's related but I've been notified of an update on the Tahoma app - and it seems like it started failing all the time after that 🤔

Anything I can do to help with this?

mija87 commented 6 months ago

I also have this issue.. Someone have a fix for it?

mathieudutour commented 6 months ago

FWIW, it doesn't happen for me anymore, not sure why...

t0k4rt commented 6 months ago

Just installed a tahoma box v2 in local mode i've got the same problem:

state is unavailable state is unknown velux has been closed repeating very frequently

@iMicknl Ho can I help debugging ?

t0k4rt commented 6 months ago

@iMicknl it seems to be related to the local url broadcasted. When I use the .local url I can see these errors in the logs:

2024-02-23 20:23:26.604 INFO (MainThread) [backoff] Backing off fetch_events(...) for 0.3s (aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host gateway-xxxx-xxxx-xxxx.local:8443 ssl:<ssl.SSLContext object at 0xffff7a916ed0> [Invalid argument])
2024-02-23 20:23:26.617 ERROR (MainThread) [homeassistant.components.overkiz] Error fetching device events data: Failed to connect.

This seems resolved if I setup the integration using the ip of the box

mija87 commented 6 months ago

Is it still stable withe the IP adess?

t0k4rt commented 6 months ago

@mija87 Yes it's stable ! On my setup the issue seems to be related to hassio_dns. I'm investigating

iMicknl commented 6 months ago

Do you use Unifi by any chance? I face similar issues (already since development) and on the community forum, more people with Unifi face issues. Not sure if it is related to Unifi, but good to find out.

mija87 commented 6 months ago

I use Unifi indeed, I just changed the api back to local via IP adress in of the local adres. Testing that out..

t0k4rt commented 6 months ago

No I'm not using unifi. I've got on openwrt router in my setup.

But I noticed that I cannot ping anymore all .local domains from all homeassistant containers (hassio_cli, dns and so on) and the box where homeassistant supervised is installed too. So gateway-xxxx-xxxx-xxxx.local is no more reachable.

But I can reach gateway-xxxx-xxxx-xxxx.local from any other machine on the network so I suspect it comes from dns configuration on my home assistant setup.

Which was kind of confirmed when I checked systemd-resolved and found these messages:

févr. 26 21:30:43 radxa-e25 systemd-resolved[11924]: mDNS-IPv4: There appears to be another mDNS responder running, or previously systemd-resolved crashed with some outstanding transfers.
févr. 26 21:30:43 radxa-e25 systemd-resolved[11924]: mDNS-IPv6: There appears to be another mDNS responder running, or previously systemd-resolved crashed with some outstanding transfers.

So I think the issue is related to that.

miezie commented 6 months ago

Do you use Unifi by any chance? I face similar issues (already since development) and on the community forum, more people with Unifi face issues. Not sure if it is related to Unifi, but good to find out.

I experience the same with a Fritz 7590 and some repeaters. So I think it is not related to Unifi alone.

monogalactico commented 5 months ago

Same problems with Tahoma local mode. Any suggestion? Thanks!

iMicknl commented 5 months ago

@monogalactico have you tried connection to the IP directly?

mathieudutour commented 5 months ago

How can you see the IP of the Tahoma box?

CyrilleHome commented 5 months ago

hello, I have the same problem, since last night I have this [homeassistant.components.overkiz] Error fetching device events data: Failed to connect. All elements are OFF. How can I fix this ?

CyrilleHome commented 5 months ago

@monogalactico have you tried connection to the IP directly?

how we can do this ? sorry I'm a newbie !

t0k4rt commented 5 months ago

@CyrilleHome @mathieudutour You should be able to list all devices and their respective ips when connecting on your home router. You should find some tutorials on the internet depending on your isp. Then I advise you to set a static ip to your Tahoma box. If that does not work you can scan your network to retrieve your overkiz box ip (With for example https://angryip.org/download/). Your box should appear as gateway-xxxx-xxxx-xxxx.local

iMicknl commented 5 months ago

@CyrilleHome please create a new issue and include your diagnostics. This is not related.

MarcoL1975 commented 5 months ago

Had the same problem and fixed it by using the IP address of the Somfy box instead of the gateway-xxxx-xxxx-xxxx.local name.

swappie-d commented 5 months ago

I have a similar problem: TaHoma switch worked fine with local API since I start using it a few weeks ago. Yesterday, the TaHoma switch was offline, but came online again after a few hours. This morning I updated HA to 2024.4.2, and afterwards the switch wasn't available anymore. After removing and re-adding the integration it says 'Failed to connect' when trying to connect to the TaHoma switch with correct password and 'Authentication failed' with a wrong password, so it does find the IP (connected to the IP of the switch). Just switched to cloud API, that works fine...

iMicknl commented 5 months ago

@swappie-d this is not correct. The "Authentication failed" refers to the connection with the Cloud API. First time set-up, we need the Cloud API to generate a token for the local API. Your "Failed to connect" message refers to the local API indeed, are you sure you can ping the mDNS or IP from Home Assistant?

For all, I would switch to the IP address, the mDNS resolving is not stable at all. Will have a look into this, but not sure where the culprit might be...

swappie-d commented 5 months ago

@iMicknl I just tried to ping it from HA, it responds 'connected'. However, when I enter 123.456.789.123:8443 as host, same error: Failed to connect.

sebastienserre commented 4 months ago

Hello, What are the credential required for CLoud install? I've the same issu with Local API. Or how to change to the IP in the LocalAPI setings ? Thanks

miezie commented 4 months ago

Do you use Unifi by any chance? I face similar issues (already since development) and on the community forum, more people with Unifi face issues. Not sure if it is related to Unifi, but good to find out.

I experience the same with a Fritz 7590 and some repeaters. So I think it is not related to Unifi alone.

Has there been an update on the TaHoma Switch? It seems more stable since a few weeks..

asemev commented 4 months ago

I have exactly the same issue (disconnecting every 5 minutes and reconnecting by itself). I have also been using local API. After reading the comment hee i switched now to cloud API and will see how stable this is. I have all my house window shutters automated based on this integration and sometimes i wake up and see that the shutters havent opened andf its because of this issue. Also in the night sometimes the shutters dont close because of this. So hopefully the local API will be fixed soon or the cloud API will be stable. Thanks!

Schwebebahn commented 4 months ago

It was asked several times, but I did not see an answer: How can I change the name to IP?

laszlojakab commented 4 months ago

@Schwebebahn

It was asked several times, but I did not see an answer: How can I change the name to IP?

You can change in config/.storage/core.config_entries. Look for overkiz in config. Change title and data/host to your-device-ip:8443.

Restart HA.

Marcus59 commented 3 months ago

Hello,

When I try to replace the hostname by my device ip, it doesn't work, overkiz integration indicate "connection failed, retrying" (I cannot manage to have more detailed log, but I'm quite a newbie on homeassistant)

Is there anything to do to be able to use ip adress instead of hostname ? maybe router side ?

I can ping the hostname and the ip adress of the Tahoma Switch from home assistant without errors

JTT22 commented 3 months ago

I got the same connect issues on a Unifi system, if switched to IP I get other setup issues.

martinpelant commented 3 months ago

I have the same issue with both .local and ip address - the Tahoma switch goes frequently unreachable and then back online. I have unifi and I can ping my Tahoma fine from unifi console. Cloud integration was stable until an outage this week which prompted me to switch to local API

wergio commented 3 months ago

fixed for me specifying the ip (and no flag in "verify ssl", don't know if it matters), but i was forced to delete and recreate everything. editing config/.storage/core.config_entries wasn't working for me, even with restart

JTT22 commented 3 months ago

fixed for me specifying the ip (and no flag in "verify ssl", don't know if it matters), but i was forced to delete and recreate everything. editing config/.storage/core.config_entries wasn't working for me, even with restart

Could you share how your config section look?

wergio commented 3 months ago

fixed for me specifying the ip (and no flag in "verify ssl", don't know if it matters), but i was forced to delete and recreate everything. editing config/.storage/core.config_entries wasn't working for me, even with restart

Could you share how your config section look?

the config before was like this: { "entry_id": "89ea361183f0797d08e3beeefea08486", "version": 1, "minor_version": 1, "domain": "overkiz", "title": "Tahoma Piano Terra", "data": { "host": "gateway-2015-5223-9069.local:8443", "username": "USERNAME", "password": "PASSWORD", "verify_ssl": true, "hub": "somfy_europe", "api_type": "local", "token": "665b167da2359d32966d" }, "options": {}, "pref_disable_new_entities": false, "pref_disable_polling": false, "source": "user", "unique_id": "2015-5223-9069", "disabled_by": null }

putting the ip 192.168.1.157:8443 in data-host (and even title) didn't work, I always got "connection failed" in every moment (not random) I don't remember if after recreating from scrath the token was changed but after deleting and recreating with the interface, everything worked correctly

JTT22 commented 3 months ago

How do I specify the IP, I get connection failed every time I try in both UI and file.

iMicknl commented 3 months ago

Best would be to add your thoughts in https://github.com/Somfy-Developer/Somfy-TaHoma-Developer-Mode/issues/131#issuecomment-2143742424, if your box goes offline all the time.

It seems there is a problem with Home Assistant and the zeroconf connection, causing the frequent disconnects (for a very short time). However, if you are connected via IP and you are still having issues where the box goes offline, it might be related to the issue above.

@JTT22 no need to change any files. If you want to connect via IP, just enter the IP address with the correct port, e.g. "192.1.1.100:8443". If you get "Failed to connect", you are not able to connect to this IP via Home Assistant and this is not something the integration can solve. Make sure to disable "Verify SSL", since there is no valid certificate for your local IP.

tamzenn commented 3 months ago

Hello I tried to use the local API today, but I have had exactly the same issue (disconnecting every few minutes and reconnecting by itself after a few minutes). I have also tried to use IP directly, but the issue remains. I finally switched back to cloud API, and it works fine.

TheGroundZero commented 2 months ago

I'm also experiencing disconnects. Somfy TaHoma switch connected to a UniFi network without internet connectivity, using local API.

I have now switched to the TaHoma over to a network that does have internet, let's see if that fixes things.

Configuring the integration using the device's IP address was giving me errors, by the way. So I set it up using it's hostname again.

mathieudutour commented 2 months ago

Same, when trying to setup the integration with the IP address, I got

Logger: homeassistant.components.overkiz
Source: components/overkiz/config_flow.py:232
integration: Overkiz ([documentation](https://www.home-assistant.io/integrations/overkiz), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+overkiz%22))
First occurred: 10:02:57 AM (2 occurrences)
Last logged: 10:03:07 AM

Unknown error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/overkiz/config_flow.py", line 232, in async_step_local
    user_input = await self.async_validate_input(user_input)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/overkiz/config_flow.py", line 69, in async_validate_input
    user_input[CONF_TOKEN] = await self._create_local_api_token(
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/overkiz/config_flow.py", line 413, in _create_local_api_token
    await local_client.login()
  File "/usr/local/lib/python3.12/site-packages/pyoverkiz/client.py", line 191, in login
    await self.register_event_listener()
  File "/usr/local/lib/python3.12/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyoverkiz/client.py", line 584, in register_event_listener
    response = await self.__post("events/register")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyoverkiz/client.py", line 918, in __post
    await self.check_response(response)
  File "/usr/local/lib/python3.12/site-packages/pyoverkiz/client.py", line 981, in check_response
    raise NotAuthenticatedException(message)
pyoverkiz.exceptions.NotAuthenticatedException: Not authenticated

even tho when I use the same username and password with the hostname, it works

iMicknl commented 2 months ago

@TheGroundZero, @mathieudutour this is another issue, please create a new issue for your issue.

mathieudutour commented 2 months ago

I don't think it's really off-topic since the recommended workaround for this issue is to use the ip address but sure, I'll open a new issue

misku commented 2 months ago

UPDATE: Local API for an unknown reason was not available also using the terminal (curl):

$ curl -k -X 'GET' 'https://{my_IP}:8443/enduser-mobile-web/1/enduserAPI/apiVersion' -H 'accept: application/json'
curl: (7) Failed to connect to {my_IP} port 8443 after 5 ms: Couldn't connect to server

In my case it was not an Overkiz problem, but the Somfy Tahoma Switch problem. After rebooting Somfy Tahoma Switch once again, I could connect to the local API again via terminal. Home Assistant Overkiz setup also worked then. Apparently this hardware is not very reliable.


ORIGINAL POST: I'm getting the same problem. In my case I had to restart Tahoma Box as well as Home Assistant. After that the connection would fail and never come back (local API). Removing and starting from scratch also gives me "Failed to connect".

Interesting highlights:

Core
2024.7.1
Supervisor
2024.06.2
Operating System
12.4
Frontend
20240705.0

What's the path to the log file or how can I access the journal to get some more information?

Marcus59 commented 2 months ago

I finally made it using the gui (specifing th IP when adding the integration) after several atempt. I don't know if I was doing something wrong during my previous attempts (don't think so). Now it's working