bogosj / tesla

Provides a wrapper around the API to easily query and command a Telsa car.
Other
23 stars 18 forks source link

Timestamps changed? #12

Closed andig closed 3 years ago

andig commented 3 years ago

Not sure if this is my mistake but it seems as if the tesla API might have changed its timestamp format:

{
    "response": {
        "battery_heater_on": false,
        "battery_level": 57,
        "battery_range": 186.49,
        "charge_current_request": 6,
        "charge_current_request_max": 6,
        "charge_enable_request": true,
        "charge_energy_added": 0.1,
        "charge_limit_soc": 90,
        "charge_limit_soc_max": 100,
        "charge_limit_soc_min": 50,
        "charge_limit_soc_std": 90,
        "charge_miles_added_ideal": 0.5,
        "charge_miles_added_rated": 0.5,
        "charge_port_cold_weather_mode": false,
        "charge_port_door_open": true,
        "charge_port_latch": "Engaged",
        "charge_rate": 4.8,
        "charge_to_max_range": false,
        "charger_actual_current": 6,
        "charger_phases": 1,
        "charger_pilot_current": 6,
        "charger_power": 1,
        "charger_voltage": 220,
        "charging_state": "Charging",
        "conn_charge_cable": "IEC",
        "est_battery_range": 135.85,
        "fast_charger_brand": "<invalid>",
        "fast_charger_present": false,
        "fast_charger_type": "<invalid>",
        "ideal_battery_range": 186.49,
        "managed_charging_active": false,
        "managed_charging_start_time": null,
        "managed_charging_user_canceled": false,
        "max_range_charge_counter": 1,
        "minutes_to_full_charge": 4080,
        "not_enough_power_to_heat": null,
        "scheduled_charging_pending": false,
        "scheduled_charging_start_time": null,
        "time_to_full_charge": 68.0,
        "timestamp": 1614069716042,
        "trip_charging": false,
        "usable_battery_level": 55,
        "user_charge_enable_request": null
    }
}
parsing time "1614069715531" as ""2006-01-02T15:04:05Z07:00"": cannot parse "1614069715531" as """

Looks like unix timestamp (millis?) instead of formatted time. Can anyone confirm?

andig commented 3 years ago

/cc @michaelharo seems this was broken by https://github.com/bogosj/tesla/commit/2faf60331bee60936fba82b6a2f2ee60211fbb71? Imho the timestamps won't unserialize into time.Time as you've expected.

michaelharo commented 3 years ago

Indeed a bug not caught by tests. :-(