Ludy87 / xplora_watch

Xplora® Watch Home Assistant Integration
MIT License
50 stars 6 forks source link

[🐛 BUG] Battery showing -1 and tracker not updating #47

Closed westis closed 2 years ago

westis commented 2 years ago

System Health details

System Information

version core-2022.8.7
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.10.5
os_name Linux
os_version 5.15.60
arch x86_64
timezone Europe/Stockholm
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4790 Installed Version | 1.27.1 Stage | running Available Repositories | 1109 Downloaded Repositories | 16
AccuWeather can_reach_server | ok -- | -- remaining_requests | 48
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | 18 september 2022 02:00 relayer_connected | true remote_enabled | true remote_connected | true alexa_enabled | true google_enabled | true remote_server | eu-west-2-5.ui.nabu.casa can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 8.5 -- | -- update_channel | stable supervisor_version | supervisor-2022.08.5 agent_version | 1.2.1 docker_version | 20.10.14 disk_total | 30.8 GB disk_used | 7.9 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | SSH & Web Terminal (12.0.2), Studio Code Server (5.3.0), Node-RED (13.3.2), File editor (5.3.3), SONOS AudioClip TTS (2.0.3), Mosquitto broker (6.1.3), Zigbee2MQTT (1.27.2-1)
Dashboards dashboards | 4 -- | -- resources | 6 views | 5 mode | storage
Recorder oldest_recorder_run | 23 augusti 2022 11:08 -- | -- current_recorder_run | 2 september 2022 11:45 estimated_db_size | 149.34 MiB database_engine | sqlite database_version | 3.38.5
Spotify api_endpoint_reachable | ok -- | --

Checklist

Describe the issue

I often lose contact with watches and as a result battery level displays as -1 and the device tracker is not updating position.

I get the error above, stating I need to restart the watch(es). Is there no way to reconnect to the watch other than restarting the watch? Why does this happen frequently? Does it have to do with logging in with the same account in the app (an issue I don't understand the instructions for how to avoid)?

Reproduction steps

Happens regularly, although I haven't yet identified the cause in order to reproduce it.

Debug logs

Logger: custom_components.xplora_watch.device_tracker
Source: custom_components/xplora_watch/device_tracker.py:173
Integration: Xplora® Watch (documentation, issues)
First occurred: 1 september 2022 23:01:08 (1300 occurrences)
Last logged: 11:38:40

no Data from Xplora Server: Watch ID xxxxxxxx, restart your Watch and try again!
no Data from Xplora Server: Watch ID xxxxxxxx, restart your Watch and try again!
westis commented 2 years ago

Actually, now that I added logger to configuration.yaml and restarted I can again get info from the watches, without me having restarted them. Not sure if the restart was what made it work again. And as stated before, not sure what's causing regularly losing contact with the watches.

Florian-Schmidt commented 2 years ago

Same here!

As I‘m checking standby duration for guarantee reasons I needed to start to check it. Until now it was a nice to have feature.

I guess restarting HA isn't a solution as I‘m doing every update. But I'll check again.

Florian-Schmidt commented 2 years ago

Ok it seems as the watch must be on and then restarting HA seems to be a workaround.

westis commented 2 years ago

Both my boys' watches stopped reporting at the same time last night. This is what the log says. If something like this happen, could the integration somehow restart the service? Since a restart of HA seems to help.

Error is from a custom integration.

Logger: homeassistant.helpers.entity
Source: custom_components/xplora_watch/binary_sensor.py:115
Integration: Xplora® Watch (documentation, issues)
First occurred: 00:12:11 (2 occurrences)
Last logged: 00:12:11

Update for binary_sensor.boy1_watch_state_xxxxxxxxxxxxxxxxxxxxxxxxxx fails
Update for binary_sensor.boy2_watch_state_xxxxxxxxxxxxxxxxxxxxxxxxxx fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1064, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1049, in create_connection
    sock = await self._connect_sock(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 960, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 500, in sock_connect
    return await fut
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 505, in _sock_connect
    sock.connect(address)
OSError: [Errno 101] Network unreachable

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 514, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 709, in async_device_update
    raise exc
  File "/config/custom_components/xplora_watch/binary_sensor.py", line 175, in async_update
    await self.__update()
  File "/config/custom_components/xplora_watch/binary_sensor.py", line 145, in __update
    self.__default_attr(await self.__isOnline())
  File "/config/custom_components/xplora_watch/binary_sensor.py", line 115, in __isOnline
    if (await self._controller.askWatchLocate(wuid=self._watch_id) is True) or (
  File "/usr/local/lib/python3.10/site-packages/pyxplora_api/pyxplora_api_async.py", line 397, in askWatchLocate
    return (await self._gqlHandler.askWatchLocate_a(wuid)).get("askWatchLocate", False)
  File "/usr/local/lib/python3.10/site-packages/pyxplora_api/gql_handler_async.py", line 84, in askWatchLocate_a
    res: Dict[str, Any] = (await self.runAuthorizedGqlQuery_a(gq.WATCH_Q.get("askLocateQ", ""), {"uid": wuid})).get(
  File "/usr/local/lib/python3.10/site-packages/pyxplora_api/gql_handler_async.py", line 42, in runAuthorizedGqlQuery_a
    return await self.runGqlQuery_a(query, variables)
  File "/usr/local/lib/python3.10/site-packages/pyxplora_api/gql_handler_async.py", line 35, in runGqlQuery_a
    data: Dict[str, Any] = await gqlClient.execute_async(query=query, variables=variables)
  File "/usr/local/lib/python3.10/site-packages/python_graphql_client/graphql_client.py", line 70, in execute_async
    async with session.post(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 1138, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 535, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 542, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 907, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.myxplora.com:443 ssl:default [Network unreachable]
Ludy87 commented 2 years ago

good morning, my guess is the myxplora service. The servers are not configured well. Both of my clocks are not in the right locations on many days. If the clock has no network connection for a longer period of time, the server sends back -1. Unfortunately, I have no influence, xplora is also not interested in communicating with me.

Florian-Schmidt commented 2 years ago

Ok, I guess it‘s the same problem like in the Xplora app. It‘s disconnecting silently very often.

I just had another -1 for our watch. I‘ll check it during the next hours and try an automation like I did for another integration with disconnections.

if this should work, I‘ll post the necessary code.

Sgh79 commented 2 years ago

Many thanks in advance. I encountered the same problem with the xplora watch from my daughter. After restart of HA the service was back and the trackers says it is "At home".

Florian-Schmidt commented 2 years ago

Unfortunately refreshing the entity by an automation (solved an similar issue for another integration) seems not to be enough. 😌

westis commented 2 years ago

Unfortunately refreshing the entity by an automation (solved an similar issue for another integration) seems not to be enough. 😌

That's too bad... What is happening with a restart of HA that refreshing of the entity isn't doing? Could there be something else with the integration that needs a restart?

If we are many contacting Xplora about this, maybe they can find interest in at least responding? What should we tell me in order to get a useful response?

Florian-Schmidt commented 2 years ago

Ha restart will load all integrations completely new. Perhaps there‘s a kind of complete new connection to Xplora server.

Contacting Xplora could be interesting as the app seems to loose connection also. This would be independent of HA.

westis commented 2 years ago

What's weird now is that even when other entities update in HA, the device tracker doesn't return any positional information since some time yesterday. In the Xplora Android app the position is up to date though. Not sure how comes that it is no longer available in HA? It says source_type: null.

ravor-org commented 2 years ago

I have the same problem. Restarting HA typically solves the problem, but this isn't even a workaround. If I can support somehow, I would be glad to assist.

westis commented 2 years ago

Since it's a Swedish company we could have some success in at least getting a creative response by writing in Swedish.

Could we summarize the main issues, potential causes to them and what we feel needs to be fixed in order to make the watch useful for us? Then I or someone else who is Swedish could write an email "on behalf of the Home Assistant community".

Even if they feel that some of these issues are not important to their business model, at least GPS tracking and battery status are important USPs for Xplora and should just work. And even if they want users to use their app, these things are often not even working reliably there.

And obviously they don't have a public API that is intended to be used the way we want to use it. But a reliable API should be in the interest of the company...

So, could we summarize issues, causes and what we need to be fixed?

ravor-org commented 2 years ago

Nevertheless it looks like this implementation is not resilient enough to workaround the errors. Could it be, that the session, that is initialized during integration startup is somehow invalidated and needs to be relogged? Or the controller is misbehaving? I've added pyexplorer_api to the logging of my homeassistant for the time being. Unfortunately both components are not very verbose, when it comes to logging. No offense! :)

westis commented 2 years ago

Yeah, if restarting HA solves issues, there should be a way for the integration to restart services when receiving errors from the Xplora side.

westis commented 2 years ago

@Ludy87 How to update to include the latest fix? What does the fix do in terms of fixing GPS data and battery status?

Florian-Schmidt commented 2 years ago

@westis It is Seems to be a commit for a bugfixing branch and not an update yet.

Sgh79 commented 1 year ago

Hello, since two days i notice a strong battery darin from the xolora watch (X5). Is anybody noticing the Same? Recent Update was done in the watch. Mit freundlichen GrüßenSascha GuthAm 09.09.2022 10:23 schrieb westis @.***>: @Ludy87 How to update to include the latest fix? What does the fix do in terms of fixing GPS data and battery status?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

Florian-Schmidt commented 1 year ago

Hello, since two days i notice a strong battery darin from the xolora watch (X5). Is anybody noticing the Same? Recent Update was done in the watch. Mit freundlichen GrüßenSascha GuthAm 09.09.2022 10:23 schrieb westis @.>: @Ludy87 How to update to include the latest fix? What does the fix do in terms of fixing GPS data and battery status? —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.>

I had the same some weeks ago and opened a Xplora ticket already. Then I checked integration configuration and found a refresh period. Changing the interval to 3600 seconds solved the issue and I closed Xplora ticket again.

Ludy87 commented 1 year ago

Hello, since two days i notice a strong battery darin from the xolora watch (X5). Is anybody noticing the Same? Recent Update was done in the watch. Mit freundlichen GrüßenSascha GuthAm 09.09.2022 10:23 schrieb westis @.>: @Ludy87 How to update to include the latest fix? What does the fix do in terms of fixing GPS data and battery status? —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.>

Info: https://github.com/Ludy87/xplora_watch/issues/24#issuecomment-1270090147

At the moment it is only possible with an admin account