Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sensor available/unavailable cycle on v1.70 #530

Open
thewolfman56 opened this issue Aug 22, 2024 · 19 comments
Open

Sensor available/unavailable cycle on v1.70 #530

thewolfman56 opened this issue Aug 22, 2024 · 19 comments

Comments

@thewolfman56
Copy link

I have an automation that lets me know when my wife's expedition goes below a certain threshold of miles left in the tank. This automation recently started firing every hour. I checked the sensor history for the vehicle and it appears that there is now a cycle that the sensor is available for 30 minutes, then unavailable for 30 minutes.

Here is the history of the door sensor for example.

image

@hroling
Copy link

hroling commented Sep 6, 2024

I have the same issue with my Ford EcoSport. (Installed 1.70 Yesterday)

image

@hroling
Copy link

hroling commented Sep 10, 2024

It looks that if you refresh every 15 minutens, this issue is solved. I created an automation like this one.

alias: "Auto: Ford EcoSport refresh"
description: ""
trigger:
  - platform: time_pattern
    minutes: /15
condition: []
action:
  - action: fordpass.refresh_status
    data: {}
mode: single 

@thewolfman56
Copy link
Author

It looks that if you refresh every 15 minutens, this issue is solved. I created an automation like this one.

Thanks. I'll try that. I used to have a similar automation for my MyDolphin pool robot cleaner that would reload the integration whenever the AWS broker connection became unavailable.

@JackKlaasing
Copy link

It looks that if you refresh every 15 minutens, this issue is solved. I created an automation like this one.

alias: "Auto: Ford EcoSport refresh"
description: ""
trigger:
  - platform: time_pattern
    minutes: /15
condition: []
action:
  - action: fordpass.refresh_status
    data: {}
mode: single 

And at the setup of the fordpass, the standard api refresh polling rate is 900s
What do you enter there, so you will not get banned?

@hroling
Copy link

hroling commented Sep 18, 2024

It looks that if you refresh every 15 minutens, this issue is solved. I created an automation like this one.

alias: "Auto: Ford EcoSport refresh"
description: ""
trigger:
  - platform: time_pattern
    minutes: /15
condition: []
action:
  - action: fordpass.refresh_status
    data: {}
mode: single 

And at the setup of the fordpass, the standard api refresh polling rate is 900s What do you enter there, so you will not get banned?

It solved the issue for a week but it is back....

image

@Milkysunshine
Copy link

Same issue here.

Here's the log entry:

First occurred: October 10, 2024 at 12:10:54 PM (58 occurrences)
Last logged: 9:59:27 AM

Error fetching fordpass data: Error communicating with FordPass for redacted vin

@Milkysunshine
Copy link

Milkysunshine commented Oct 28, 2024

I was able to get around this bug.

I reconfigured the FordPass integration to refresh every 180000000 seconds... (50,000) hours.

I already had this script I used on occasion if I wanted a manual update:

alias: Update FordPass
sequence:
  - action: fordpass.refresh_status
    metadata: {}
    data: {}
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  - action: fordpass.poll_api
    metadata: {}
    data: {}
description: ""

I am guessing it would work with a shorter than 1 minute delay, but I have not tested it. This works reliably for me at 60 seconds.

So I created an automation that calls the script every 20 minutes: ( I kept it 20 to not overload the api, to avoid bans, and I personally don't need the information updated any more frequently than that. )

alias: "Time: Update FordPass every 20 minutes"
description: ""
triggers:
  - trigger: time_pattern
    minutes: /20
conditions: []
actions:
  - action: script.update_fordpass
    metadata: {}
    data: {}
mode: single

I have not had a single failed update since doing this.

Screenshot 2024-10-28 084814

I'm not sure why the built in polling doesn't work reliably, but this does... I didn't look into the source code.

I hope this helps others with the problem, or helps pinpoint the issue.

@hroling
Copy link

hroling commented Oct 28, 2024

Tried. Thanks for the tip

It is not working for me. 30 min block vs 15 min block.

@Milkysunshine
Copy link

Milkysunshine commented Oct 28, 2024

Did you reconfigure the integration and set the refresh time to a stupid hugh number?

@hroling
Copy link

hroling commented Oct 29, 2024

Did you reconfigure the integration and set the refresh time to a stupid hugh number?

Forgotten.... Set it now to 180000000.

Thanks and wait for the data.

@thewolfman56
Copy link
Author

I was able to get around this bug.

I'm not sure why the built in polling doesn't work reliably, but this does... I didn't look into the source code.

I hope this helps others with the problem, or helps pinpoint the issue.

@Milkysunshine Thanks for sharing this. I was still getting only blocks of updates (seemed like every other day), but I'll try this script and automation. I only disabled my other refresh automation for now in case i have to revert to it, but hoping your combination works.

@gmbrown21
Copy link

I was still getting only blocks of updates (seemed like every other day), but I'll try this script and automation. I only disabled my other refresh automation for now in case i have to revert to it, but hoping your combination works.

I noticed that I was only getting updates when my car was "active"--like if the car was connected to the EVSE and actively charging, or if I was driving or had just parked. Over night, there would be no updates. My assumption was that the car perhaps went into "dormant" mode when it had nothing new to report that was relevant to the entities created by the integration, and maybe that the integration similarly did not actively refresh the status itself if it discovered nothing new from the API, unless I were to do something like call the refresh service manually or lock or unlock the doors with the integration. That seemed reasonable to me, though I kind of get the idea that that isn't necessarily the expected behavior.

@hroling
Copy link

hroling commented Oct 29, 2024

No blocks with unavailable anymore but also no new information. Still the data of Yesterday.

Searching for the issues :) :)

@thewolfman56
Copy link
Author

The new automation seems to be working better than what I had before. The vehicle has been idle for 6 hours, but this is the outside temp sensor (best one I could think of that would be changing while sitting).

image

@Milkysunshine
Copy link

It definitely isn't a cure... more of a band-aid to prevent the stretches of unavailable data.

I say that because the home assistant log still shows errors.

Logger: homeassistant.components.script.update_fordpass
Source: helpers/script.py:525
integration: Script (documentation, issues)
First occurred: October 27, 2024 at 12:35:53 PM (93 occurrences)
Last logged: 9:45:53 AM

Update FordPass: Error executing script. Unexpected error for call_service at pos 1: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 716, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 468, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 463, in _make_request
    httplib_response = conn.getresponse()
                       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 1428, in getresponse
    response.begin()
  File "/usr/local/lib/python3.12/http/client.py", line 331, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 300, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 667, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 802, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/retry.py", line 552, in increment
    raise six.reraise(type(error), error, _stacktrace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/packages/six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 716, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 468, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 463, in _make_request
    httplib_response = conn.getresponse()
                       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 1428, in getresponse
    response.begin()
  File "/usr/local/lib/python3.12/http/client.py", line 331, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/http/client.py", line 300, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/fordpass/__init__.py", line 86, in async_refresh_status_service
    await hass.async_add_executor_job(
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/fordpass/__init__.py", line 157, in refresh_status
    status = coordinator.vehicle.request_update(vin)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/fordpass/fordpass_new.py", line 590, in request_update
    self.__acquire_token()
  File "/config/custom_components/fordpass/fordpass_new.py", line 331, in __acquire_token
    result = self.refresh_token_func(data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/fordpass/fordpass_new.py", line 262, in refresh_token_func
    response = session.post(
               ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 637, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 682, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

The 'Remote end closed connection without response' persisted occasionally even when I set the "refresh" rate to 30 minutes.

I just changed it to 45 minutes in order to see if it is some sort or rate limit being imposed by the server.

@thewolfman56
Copy link
Author

It definitely isn't a cure... more of a band-aid to prevent the stretches of unavailable data.

I say that because the home assistant log still shows errors.

I don't think anyone thinks that needing to add an automation to refresh the integration is a cure, but it makes the integration work better for now while the developer has a chance to figure it our in the long run. A similar situation happened with my pool robot custom integration. I had to add an automation that would reload the integration whenever it was disconnected. Luckily, the developers of the integration added a sensor to monitor the connection to AWS, so it was easy to implement the automation while they worked on a solution. They eventually figured it out, but it took them a while.

@hroling
Copy link

hroling commented Oct 30, 2024

I looks like it is working after the restart of Home Assistent. We know more tomorrow. :)
image

@gmbrown21
Copy link

It definitely isn't a cure... more of a band-aid to prevent the stretches of unavailable data.

I say that because the home assistant log still shows errors.

I don't think anyone thinks that needing to add an automation to refresh the integration is a cure, but it makes the integration work better for now while the developer has a chance to figure it our in the long run.

Your automation does work well, except, at least with my car (Mustang Mach-E), it seems to lead to a slow, but steady, drain of the 12V battery. Shutting off the automation overnight also seems to have stopped the drain. I'm either going to have to have it run less often than every 20 minutes or run it manually or find another way for it to run often enough to be useful without draining the battery.

@Milkysunshine
Copy link

Your automation does work well, except, at least with my car (Mustang Mach-E), it seems to lead to a slow, but steady, drain of the 12V battery. Shutting off the automation overnight also seems to have stopped the drain. I'm either going to have to have it run less often than every 20 minutes or run it manually or find another way for it to run often enough to be useful without draining the battery.

You could add a conditional check to the automation that tells it not to update between x and y times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants