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
69.72k stars 28.88k forks source link

Traccar: wrong status & battery_level after 2024.5 (and position as well) #116628

Open ildar170975 opened 2 months ago

ildar170975 commented 2 months ago

The problem

In 2024.5 for all my devices - status & battery_level are wrong.

Take this: image

which is in fact (from a web page) image (and battery_level is a correct value)

Or this: image which is in fact: image

Or this: image with this history for the status: image although the device was seen a few minute ago in fact: image and it's last status was image

No messages in Log: image

What version of Home Assistant Core has the issue?

2024.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

traccar server

Link to integration documentation on our website

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

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

home-assistant[bot] commented 2 months ago

Hey there @ludeeus, mind taking a look at this issue as it has been labeled with an integration (traccar_server) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `traccar_server` 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 traccar_server` 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)


traccar_server documentation traccar_server source (message by IssueLinks)

ildar170975 commented 2 months ago

After a manual reloading the integration - info is valid again. But the issue is that data should not become invalid.

If anything prevents the integration to work properly (internet issues, timeouts etc) - there are should be corr. messages in Log.

ildar170975 commented 2 months ago

And binary_sensors for "status" are unknown - WTH? This sensors for status LOOKS normal: image

In fact some of them are unknown: image

And this is not just a "displayed state" - it seems to be a real state: image

The source value could be online or unknown - then WTH a binary_sensor is used? Why not a sensor? If you have chosen a binary_sensor - then make it on / off, not on / unknown.

Hint: the unknown state in considered by users as "there is smth wrong with my sensor". In this particular case the unknown value for a source status is absolutely normal value - it merely means "no updates from a device within some period".

ildar170975 commented 1 month ago

Moreover - a device_tracker state becomes outdated as well, even when a status sensor is ON. Before 2024.5 it was working fine.

ildar170975 commented 1 month ago

Anyone from Dev team - are you going to do anything about Traccar? Trackers stop being updated after a few hours after HA reboot. See no feedback here.

ludeeus commented 1 month ago

Until you can provide the logs for whats happening on your system (hint, mine does not have these symptoms), there is not really much to look at. The data is updated over a WebSocket connection to the traccar server, so a) that connection stopped (which would have produced logs) or b) your server stopped sending data.

ildar170975 commented 1 month ago

Can you tell me what logs are needed? There is nothing in Log related to Traccar (except a "Waiting on integrations to complete setup" with a long list of integrations).

As I already described:

ildar170975 commented 1 month ago

@ludeeus Tell me, are you trying to re-establish a connection to Traccar server after loosing an access to Internet? Guess - not. I see that for every device_tracker a value of last_updated is immediately before some "no internet access" event.

ludeeus commented 1 month ago

Guess - not.

.... πŸ™„

https://github.com/home-assistant/core/blob/dev/homeassistant/components/traccar_server/coordinator.py#L228-L238

ildar170975 commented 1 month ago

As I said already - I see no messages in Log. Are you willing to fix the issue? Then at least tell me how I can help you.

ivanfmartinez commented 1 month ago

Can you tell me what logs are needed? There is nothing in Log related to Traccar (except a "Waiting on integrations to complete setup" with a long list of integrations).

As I already described:

  • reboot HA
  • sensors show correct data (at least same as reported by traccar-web)
  • after several hours (I could not touch HA at all) - sensors stuck on their values

Have you set debug for traccar in your logging configuration ?

  homeassistant.components.traccar_server: debug
  pytraccar: debug

I have in enabled debug in my logs and apparently the integration is retrying fine after problem with server access.

  File "/usr/src/homeassistant/homeassistant/components/traccar_server/coordinator.py", line 198, in import_events
    events = await self.client.get_reports_events(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pytraccar/client.py", line 145, in get_reports_events
    response: list[ReportsEventeModel] = await self._call_api(
                                         ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pytraccar/client.py", line 105, in _call_api
    raise TraccarConnectionException(
pytraccar.exceptions.TraccarConnectionException: Could not communicate with Traccar - Cannot connect to host XXXXXXXXX:443 ssl:default [None]
ildar170975 commented 1 month ago

Have you set debug for traccar in your logging configuration ?

No, using default settings for logger. That is why I said several times that there is no messages in log & asked how I can get more info.

Shall I add the "pytraccar: debug" line as well?

ivanfmartinez commented 1 month ago

Have you set debug for traccar in your logging configuration ?

No, using default settings for logger. That is why I said several times that there is no messages in log & asked how I can get more info.

Shall I add the "pytraccar: debug" line as well?

I made this to try to find a problem in my environment that occurred sometimes and apparenrly is not ocurring on 2024.5 anymore.

using debug will use more space, but maybe can help you to find the source of your problem.

ildar170975 commented 1 month ago

With these settings

logger:
  default: warn
  logs:
    homeassistant.components.traccar_server: debug
    pytraccar: debug

I see this Log (filtered by "traccar" word):

ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

The last message was at ~18:26, at bout same time I rebooted my router: ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

Now it is 18:43, sensors are not updating, no new "Received subscription data" messages in Log.

Then I reloaded the integration manually at ~18:45:

ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

And again sensors are updated:

ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

If the new updated integration needs to be manually reloaded after rebooting a router - I would not call this a proper change.

Caldin-Maldin commented 1 month ago

Hello, I have the same problem. Trackers selectively stop showing the correct state and position, and freeze in a certain place, although everything is displayed correctly on the web page. This started after the update to XA 2024.5. Before this there were no problems for two years... There is no information about errors in the logs.

Rebooting the integration helps. After this, all sensors and trackers display the correct information and position.

Caldin-Maldin commented 1 month ago

Added to see logs

logger:
  default: warn
  logs:
    homeassistant.components.traccar_server: debug
    pytraccar: debug

And it turns out that at a certain time there is a last entry regarding traccar and that’s it, sensor updates stop there. The same time is listed in the last_updated attribute

Caldin-Maldin commented 1 month ago

I noticed one more thing. All trackers immediately stop updating in XA, but if one of these trackers is rebooted by the XA service

service: homeassistant.reload_config_entry
data: {}
target:
  entity_id: device_tracker.Ρ…Ρ…Ρ…Ρ…Ρ…Ρ…Ρ…Ρ…

then the rest are also updated and show the correct state.

ildar170975 commented 1 month ago

but if one of these trackers is rebooted by the XA service

Probably because all trackers have same config entry.

Caldin-Maldin commented 1 month ago

всС Ρ‚Ρ€Π΅ΠΊΠ΅Ρ€Ρ‹ ΠΈΠΌΠ΅ΡŽΡ‚ ΠΎΠ΄ΠΈΠ½Π°ΠΊΠΎΠ²ΡƒΡŽ запись Π² ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΈ

Π­Ρ‚ΠΎ-Ρ‚ΠΎ понятно))) Π’Π°ΠΌ ΡƒΠ΄Π°Π»ΠΎΡΡŒ ΠΊΠ°ΠΊ-Ρ‚ΠΎ Ρ€Π΅ΡˆΠΈΡ‚ΡŒ ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΡƒ?

ildar170975 commented 3 weeks ago

@ludeeus Can you at least leave some feedback?

ivanfmartinez commented 3 weeks ago

I have tried many times in my environment to block the connection between traccar and homeassistant DROPing and REJECTing packets. And it returns correctly.

I use a remote traccar 6.1 with https and my homeassistant runs on docker x86_64. Maybe the users that are having trouble have a different environment that creates an error that integration cannot recover and require the reload to restart.

As workaround until someone give a log that contains information to track the problem I suggest to check last_updated / last_changed and reload if is outdated.

To get other dates from traccar this commit make available as attributes : https://github.com/ivanfmartinez/home-assistant-core/commit/328e01ea4459cffb1040ad20fb981df2c15e6189

ildar170975 commented 3 weeks ago

I use a remote traccar 6.1 with https and my homeassistant runs on docker x86_64. Maybe the users that are having trouble have a different environment that creates an error that integration cannot recover and require the reload to restart.

My setup is: HA in docker, Traccar demo server. To reproduce - simply reboot a router. Interesting thing is that there is no error-like messages in Log (see my post) in case of any failure.

As workaround until someone give a log that contains information to track the problem I suggest to check last_updated / last_changed and reload if is outdated.

This is what I do now to reload Traccar integration: -- there is a PING binary_sensor to check Internet availability (OFF - no internet) periodically; -- there are automations which check that binary_sensor; if it was OFF then became ON -> a custom event "internet_restored" is sent; -- some automation reloads Traccar config entry when that "internet_restored" event comes.

Caldin-Maldin commented 2 weeks ago

@ildar170975, @ludeeus

I found out that this problem arose with the transition to version HA 2024.3.

Now on the "combat" server HA 2024.2.5, on the "test" server - 2024.3.3. I temporarily turn off the Internet, literally for a second, all sensor updates on the β€œtest” server stop, on the β€œcombat” server everything works.

On the "test" server - 2024.3.3. (installed in a virtual machine, debian, supervisor), nothing is installed except Traccar integration, clean server.

ildar170975 commented 2 weeks ago

In my case it stopped working after update to 2024.5. I am absolutely sure about it since never miss a HA update. Router is rebooted automatically every day at 06:00 for last few years. So, after 2024.5 see no Traccar updates after any router's reboot.

May be simply reproduced by unplugging an Ethernet cable from a HA machine. Besides - as I demonstrated earlier - there are NO messages in LOG. Even with debug messages ON.

Caldin-Maldin commented 2 weeks ago

@ildar170975 Here's my option. The first server is the main one, 2024.2 The second is test, 2024.3 If the Internet is briefly disconnected and then turned back on, the first server continues to update data, but the

https://github.com/home-assistant/core/assets/79503021/37e1ee1b-609d-4113-a294-2ffc5665937a

second one stops.

ildar170975 commented 2 weeks ago

@Caldin-Maldin Thanks for the test! Well, let's say that it is not really important in which particular version it was broken. In your case it happened in 2024.3, in my case in 2024.5. The issue is that it was BROKEN, and I wonder why it is being ignored by HA dev team.

rickgardner077 commented 1 week ago

I think I have the same problem. Traccar stops sending data after some undefined time. Reloading the integration immediately remedies the situation. I will take a look into the logs and provide more details asap.

Running HA: Core 2024.6.4 Supervisor 2024.06.0 Operating System 12.3 Frontend 20240610.1

Traccar on the official paid version of Traccar at server.traccar.com