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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poll Nissan servers for battery updates #44826

Merged
merged 8 commits into from
Jul 12, 2021
Merged

Commits on Jan 4, 2021

  1. Poll Nissan servers for battery updates

    Restore the previous behaviour of checking the "OperationDateAndTime" value in the returned battery status, issuing a new battery check request if it hasn't changed. Also add the sleeps as discovered by @irekzielinski
    bwduncan committed Jan 4, 2021
    Configuration menu
    Copy the full SHA
    df4064f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    55a8539 View commit details
    Browse the repository at this point in the history
  3. Check for start_date is None

    Nissan may not return a start date, which is fine, but in that case we just have to return the data we have, instead of trying another 9 times and then returning it anyway.
    bwduncan committed Jan 4, 2021
    Configuration menu
    Copy the full SHA
    cb04252 View commit details
    Browse the repository at this point in the history

Commits on Jan 5, 2021

  1. Simplify start date check

    `start_date is not None` can be simplified to just `start_date` thanks to @hencoappel
    
    Move static method `_extract_start_date` out of `LeafStore` since it doesn't really belong there (Maybe it should move to pycarwings2?) and to keep black happy. Makes the code look much cleaner to me.
    bwduncan committed Jan 5, 2021
    Configuration menu
    Copy the full SHA
    85ce087 View commit details
    Browse the repository at this point in the history

Commits on Jan 8, 2021

  1. Check get_latest_battery_status return

    A few days of testing reveals that this method can return None. In an ideal world this function would just raise an exception, but here we are...
    bwduncan committed Jan 8, 2021
    Configuration menu
    Copy the full SHA
    eeba2d5 View commit details
    Browse the repository at this point in the history

Commits on Jan 20, 2021

  1. More failure modes

    pycarwings2 can raise an exception if Nissan returns an empty list where battery records should be. My car stopped talking to me this week and this got the component completely stuck. Guard against this.
    
    I got the logic wrong. If we failed to get an initial "start_date", we can't know if the data has been refreshed, we just have to trust the Nissan servers and return the first data they give us. (OR, if we did get a start_date, wait until it has changed)
    bwduncan committed Jan 20, 2021
    Configuration menu
    Copy the full SHA
    c1f6723 View commit details
    Browse the repository at this point in the history

Commits on Apr 2, 2021

  1. Check server_info, catch TypeError

    server_info can be None, so make sure that it is valid before passing it to _extract_start_date.
    
    If you leave the car for a couple of weeks, the API behaves even more strangely. Later calls to get_latest_battery_status will also fail, and there's nothing we can do about that, so just add TypeError to the list of exceptions which will log an error and return None
    bwduncan committed Apr 2, 2021
    Configuration menu
    Copy the full SHA
    c06fe80 View commit details
    Browse the repository at this point in the history

Commits on Jun 11, 2021

  1. Limit MAX_RESPONSE_ATTEMPTS to 3

    If the Nissan servers aren't responding, it seems unlikely that more than 3 retries will be helpful. If they are really stuck, reducing the limit reduces the load on the servers by ~3. Sometimes, the servers need a delay of about a minute to get the data, so at least 2 retries are often necessary.
    bwduncan committed Jun 11, 2021
    Configuration menu
    Copy the full SHA
    e38595b View commit details
    Browse the repository at this point in the history