core
core copied to clipboard
ismartgate loses connectivity after HA restart
The problem
After any restart of HA, the gogogate/ismartgate loses connectivity to my ismartgate mini with the following (debug) error:
2023-06-02 09:22:35.100 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Home' for gogogate2 integration not ready yet: Error communicating with API: no element found: line 1, column 0; Retrying in background
Removing and re-adding the integration fixes it each time. The internal IP of the ismartgate hasn't changed.
Home Assistant 2023.5.4 Supervisor 2023.04.1 Operating System 10.2 Frontend 20230503.3 - latest
What version of Home Assistant Core has the issue?
2023.5.4
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
gogogate2/ismartgate
Link to integration documentation on our website
https://www.home-assistant.io/integrations/gogogate2
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
Hey there @vangorra, @bdraco, mind taking a look at this issue as it has been labeled with an integration (gogogate2
) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of gogogate2
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 gogogate2
Removes the current integration label and assignees on the issue, add the integration domain after the command.
(message by CodeOwnersMention)
gogogate2 documentation gogogate2 source (message by IssueLinks)
Same problem here. After every restart I need to remove and re-add the integration to make it work again. Any progress from code owners?
Which device are you using? iSmartGate or GoGoGate2?
Which device are you using? iSmartGate or GoGoGate2?
For me it's ismartgate mini
ismartgate mini for me as well. Same issue
Which device are you using? iSmartGate or GoGoGate2?
I'm using an iSmartgate mini
Just to add... for me the problem already started with 2023.5.0. Last working was 2023.4.6.
Same issue for me, iSmartgate Mini, started in 2023.5.x
Same issue as well, iSmartgate Mini
I have the same issue (and have an iSmartgate Mini) . Restarting homeassistant through the Developer Tools menu is often enough to resurrect the connectivity. Sometimes I have to do that more than once, though.
I also see the same errors with my gogogate2 controller. I ran the API code directly and still encounter the same issues. Digging deeper, the device itself is sporadically timing out, throwing an error, or returning incomplete/empty data. I'm confident the code is working nominally and this is a common issue with the gogogate device. Historically, I've seen these issues occur when the gogogate device is in a warm environment (over 90 fahrenheit) or exposed to high humidity (over 90%). In my area, a good rain causes these devices to go offline for a bit. I've included a screenshot of my HA history showing the current issue correlates with local high humidity.
I was only able to keep the device stable when using an ethernet adapter. I ended up switching all of my gates to esphome in the end.
I have my gate controller connected to Ethernet, it's better but still goes offline. The unit in my garage is wifi and never has an issue but the garage has predictable temperatures and a dehumidifier.
I don't see a correlation between temperature and connectivity to my iSmartgate mini (even though the temperature reaches almost 40°C). I am using wifi. The only noticeable link I can see is on homeassistant restart, the integration often fails to connect. I need to restart homeassistant multiple times before the connection is correctly established. The app on my phone works reliably, even when homeassistant is unable to connect.
My log entry says: home-assistant | 2023-06-21 16:32:54.435 DEBUG (MainThread) [homeassistant.config_entries] Config entry 'Garage' for gogogate2 integration not ready yet: Error communicating with API: no element found: line 1, column 0; Retrying in 10 seconds
, and repeats this without success. On a successful restart I see 2023-06-21 16:35:50.482 DEBUG (MainThread) [homeassistant.components.gogogate2.common] Finished fetching gogogate2 data in 1.346 seconds (success: True)
How could I validate the ismartgate device is at fault here (do you have a curl command that I can test with)
Yea sorry blaming the device is the wrong rabbit hole.
- It happened to a bunch of people at the same time (after an upgrade, but I didn't note which one for me)
- The device works completely fine (can go as long as I want it to) until I restart HA, which breaks it 100% of the time
- Removing and re-adding the integration fixes it 100% of the time
Nothing about the behavior points to the device.
@nakermann1973 the downstream library HA uses has a cli available and easily installed (https://github.com/vangorra/python_gogogate2_api).
@RyanAtTanagra there is evidence to suggest the device does have issues with environment but in your specific case, screenshots show something else is happening. I'm running the latest HA with two gogogate2 devices installed and have yet to reproduce the issue you are reporting.
@vangorra do you have a mini, by chance? So far everyone in this thread seems to be only having a problem with the mini. No idea what's different about those under the hood.
When using python_gogogate2_api, I am unable to run the info
command. I get an error:
File "/home/chris/pyenv/gogogate/lib/python3.11/site-packages/gogogate2_api/common.py", line 525, in element_to_ismartgate_info_response
door2=ismartgate_door_or_raise(2, element_or_raise(element, "door2")),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/chris/pyenv/gogogate/lib/python3.11/site-packages/gogogate2_api/common.py", line 466, in ismartgate_door_or_raise
apicode=element_text_or_raise(element, "apicode"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/chris/pyenv/gogogate/lib/python3.11/site-packages/gogogate2_api/common.py", line 386, in element_text_or_raise
raise TextEmptyException(tag)
gogogate2_api.common.TextEmptyException: Text was empty for tag 'apicode'.
With a few printf's I see the response from the device is
<response>
<user>admin</user>
<pin>111111</pin>
<lang>en</lang>
<timezone>A/B</timezone>
<model>ismartgateMINI</model>
<apiversion>3</apiversion>
<ismartgatename>Garage</ismartgatename>
<remoteaccessenabled>yes</remoteaccessenabled>
<remoteaccess>aaaaaaa.isgaccess.com</remoteaccess>
<firmwareversion>140</firmwareversion>
<newfirmware>no</newfirmware>
<door1>
<enabled>yes</enabled>
<permission>yes</permission>
<apicode>abcd1234abcd1234abcd1234</apicode>
<name>Main Door</name>
<mode>garage</mode>
<gate>no</gate>
<status>closed</status>
<sensor>yes</sensor>
<sensorid>17EA</sensorid>
<temperature>32.4</temperature>
<voltage>80</voltage>
<camera>no</camera>
<customimage>no</customimage>
<events>77</events>
<todayevents>8</todayevents>
</door1>
<door2>
<enabled>no</enabled>
<permission>no</permission>
<apicode></apicode>
<name>Door2</name>
<mode>garage</mode>
<gate>no</gate>
<status>undefined</status>
<sensor>no</sensor>
<camera>no</camera>
<customimage>no</customimage>
<events>0</events>
<todayevents>0</todayevents>
</door2>
<door3>
<enabled>no</enabled>
<permission>no</permission>
<apicode></apicode>
<name>Door2</name>
<mode>garage</mode>
<gate>no</gate>
<status>undefined</status>
<sensor>no</sensor>
<camera>no</camera>
<customimage>no</customimage>
<events>0</events>
<todayevents>0</todayevents>
</door3>
<network>
<ip>1.2.3.4</ip>
</network>
<wifi>
<SSID></SSID>
<linkquality></linkquality>
<signal></signal>
</wifi>
</response>
I am assuming this is a CLI bug, as it should probably just ignore doors which are disabled, and not try to parse the output.
The following patch in python_gogogate2_api/gogogate2_api/common.py
seems to get my cli info
command working reliably, even when the homeassistant integration is reporting errors.
448c448
< apicode=element_text_or_raise(element, "apicode"),
---
> apicode=element_text_or_none(element, "apicode"),
Excellent. I think this is enough to start. I have an ismartgate device for testing and will see what I can work out.
Additional update: after I have added some additional logging, I see:
home-assistant | 2023-06-22 16:04:11.688 DEBUG (MainThread) [homeassistant.config_entries] Config entry 'Garage' for gogogate2 integration not ready yet: Error communicating with API: ApiError('Code: 408 - Cannot connect: <Response [408 Timed out]>'); Retrying in 80 seconds
While this is happening, the CLI (with my small patch from above) works correctly
In _async_request
, I added:
if response.status_code != 200:
raise ApiError(response.status_code, f"Cannot connect: {response}")
OK, I think I have found the issue. If the initial connection fails, subsequent "retries" are actually not retried, but responded to from some cache. I updated my exception handling in AbstractGateApi._async_request
(in ismartgate/__init__.py
) to:
if response.status_code != 200:
raise ApiError(response.status_code, f"Cannot connect: {response}, {time.time()}")
All of the logs show the same timestamp (which seems wrong to me).
home-assistant | 2023-06-22 16:11:24.443 INFO (MainThread) [homeassistant.setup] Setting up gogogate2
home-assistant | 2023-06-22 16:11:24.443 INFO (MainThread) [homeassistant.setup] Setup of domain gogogate2 took 0.0 seconds
home-assistant | 2023-06-22 16:11:25.997 WARNING (MainThread) [homeassistant.components.gogogate2.common] Code: 408 - Cannot connect: <Response [408 Timed out]>, 1687443085.9977212
home-assistant | 2023-06-22 16:11:25.998 DEBUG (MainThread) [homeassistant.components.gogogate2.common] Finished fetching gogogate2 data in 1.531 seconds (success: False)
home-assistant | 2023-06-22 16:11:25.998 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Garage' for gogogate2 integration not ready yet: Error communicating with API: ApiError('Code: 408 - Cannot connect: <Response [408 Timed out]>, 1687443085.9977212'); Retrying in background
home-assistant | 2023-06-22 16:11:28.774 DEBUG (MainThread) [homeassistant.config_entries] Config entry 'Garage' for gogogate2 integration not ready yet: Error communicating with API: ApiError('Code: 408 - Cannot connect: <Response [408 Timed out]>, 1687443085.9977212'); Retrying in 10 seconds
home-assistant | 2023-06-22 16:11:38.995 DEBUG (MainThread) [homeassistant.config_entries] Config entry 'Garage' for gogogate2 integration not ready yet: Error communicating with API: ApiError('Code: 408 - Cannot connect: <Response [408 Timed out]>, 1687443085.9977212'); Retrying in 20 seconds
home-assistant | 2023-06-22 16:11:59.054 DEBUG (MainThread) [homeassistant.config_entries] Config entry 'Garage' for gogogate2 integration not ready yet: Error communicating with API: ApiError('Code: 408 - Cannot connect: <Response [408 Timed out]>, 1687443085.9977212'); Retrying in 40 seconds
home-assistant | 2023-06-22 16:12:39.186 DEBUG (MainThread) [homeassistant.config_entries] Config entry 'Garage' for gogogate2 integration not ready yet: Error communicating with API: ApiError('Code: 408 - Cannot connect: <Response [408 Timed out]>, 1687443085.9977212'); Retrying in 80 seconds
home-assistant | 2023-06-22 16:13:59.319 DEBUG (MainThread) [homeassistant.config_entries] Config entry 'Garage' for gogogate2 integration not ready yet: Error communicating with API: ApiError('Code: 408 - Cannot connect: <Response [408 Timed out]>, 1687443085.9977212'); Retrying in 80 seconds
home-assistant | 2023-06-22 16:15:19.494 DEBUG (MainThread) [homeassistant.config_entries] Config entry 'Garage' for gogogate2 integration not ready yet: Error communicating with API: ApiError('Code: 408 - Cannot connect: <Response [408 Timed out]>, 1687443085.9977212'); Retrying in 80 seconds
That does look wrong. I'll dig into that one too.
Regarding the apicode error you saw, I'll have a PR out to address that soon.
I have the same issue as well using the ismartgateMINI on Firmware: 130. A restart of Home Assistant seems to fix the isssue.
For what it's worth, if it helps clarify the root cause, I figured out another thing that causes HA to permanently lose connection to the ismartgate mini. I reconfigured our home network last week and took wifi offline a lot while doing so. Any time the wifi went down, even for a minute, when it came back up, HA couldn't see ismartgate. The ismartgate app could. So it seems like if HA loses connectivity at any point, it's permanent (even if the IP of the ismartgate didn't change). Removing and re-adding the integration always fixes it, first time.
it's interesting that restarting HA corrects it for some people, as that's never corrected it for me, and 100% of the time causes it to break until I re-add it.
it's interesting that restarting HA corrects it for some people, as that's never corrected it for me, and 100% of the time causes it to break until I re-add it.
Indeed... same here! Restarting HA causes the connection to break 100% of the time so very odd that for some people restarting HA actually fixes the issue...
I have a GogoGate2 and experience this. I can remove and then add the integration and it works then.
Having the same issue here as well. Stopped working after recent HA update.
Follow-up and more info on this issue. This commit to the upstream library fixes the issue: https://github.com/vangorra/python_gogogate2_api/commit/e4b8e5ea65be6bcb38a3cc54e5a5b1bc2201aa28
I edited /usr/local/lib/python3.11/site-packages/ismartgate/common.py directly and made the changes, restarted HA and my isg mini showed up and connected for the first time after a restart in months.
It looks like the official python library is a fork of this, so I guess we need them to pick up this change and do a release, and then have a future HA release use the new library?
And oddly enough 2023.8.0 made it so that patch doesn't fix it anymore, heh.