flobz / psa_car_controller

Control psa car with connected_car v4 API.
GNU General Public License v3.0
385 stars 196 forks source link

Weather API KeyError #611

Closed rouke-broersma closed 5 months ago

rouke-broersma commented 9 months ago

Describe the bug Open Weather not working with exception

To Reproduce Steps to reproduce the behavior:

  1. what command did you use Happens whenever psacc tries to get the current temperature, I assume when a new trip is recorded.
  2. when the bug append ? Happens whenever psacc tries to get the current temperature, I assume when a new trip is recorded.
  3. Does it persist after restarting the program? Yes
  4. Does it persist after recreate config by going to http://server_address:port/config? Yes

Config file

{
    "abrp": {
        "abrp_enable_vin": [],
        "token": ""
    },
    "client_id": "--client-id",
    "client_secret": "--client-secret--",
    "co2_signal_api": "--co2-signal-api-key--",
    "country_code": "GB",
    "customer_id": "--customer-id--",
    "proxies": {
        "http": "",
        "https": ""
    },
    "realm": "clientsB2CPeugeot",
    "refresh_token": "--token--",
    "remote_refresh_token": "--token--",
    "weather_api": "--token--"
}

Environment (please complete the following information):

Additional context It seems like the API has changed, the temp now seems to be under the key "main" instead of "current":

HTTP/1.1 200 OK
Server: openresty
Date: Fri, 15 Sep 2023 15:27:10 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 475
Connection: close
X-Cache-Key: /data/2.5/weather?exclude=minutely,hourly,daily,alerts&lat=xx&lon=yy&units=metric
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST
{
  "coord": {
    "lon": xx,
    "lat": yy
  },
  "weather": [
    {
      "id": 803,
      "main": "Clouds",
      "description": "broken clouds",
      "icon": "04d"
    }
  ],
  "base": "stations",
  "main": {
    "temp": 22.61,
    "feels_like": 22.47,
    "temp_min": 21.62,
    "temp_max": 24.05,
    "pressure": 1015,
    "humidity": 59
  },
  "visibility": 10000,
  "wind": {
    "speed": 2.57,
    "deg": 140
  },
  "clouds": {
    "all": 75
  },
  "dt": 1694791630,
  "sys": {
    "type": 2,
    "id": 2009772,
    "country": "NL",
    "sunrise": 1694754652,
    "sunset": 1694800428
  },
  "timezone": 7200,
  "id": 2751582,
  "name": "zzz",
  "cod": 200
}

I'm also wondering why we don't get this data from the car, since the API seems to respond with the current temperature as measured by the car. Is that temperature inaccurate?

Bushrider commented 1 month ago

Hi, Can you give an example of the syntax for the config.ini file. My api is ok but can't figure out how to correctly edit the config.ini file. Thx