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

Fix errors from Timex.Timezone.local() during switchover to DST. #3848

Merged

Conversation

dyxyl
Copy link
Contributor

@dyxyl dyxyl commented Apr 16, 2024

During the hour of the switchover to DST at the end of March, errors like below were logged while the car was charging:

** (ArgumentError) time_zone_not_found
    (timex 3.7.11) lib/format/datetime/formatter.ex:55: Timex.Format.DateTime.Formatter.lformat!/4
    (teslamate 1.28.4) lib/teslamate_web/live/car_live/summary.html.heex:221: anonymous fn/2 in TeslaMateWeb.CarLive.Summary.render/1
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:398: Phoenix.LiveView.Diff.traverse/7
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:544: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
    (elixir 1.15.7) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:373: Phoenix.LiveView.Diff.traverse/7
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/diff.ex:139: Phoenix.LiveView.Diff.render/3
    (phoenix_live_view 0.18.18) lib/phoenix_live_view/channel.ex:833: Phoenix.LiveView.Channel.render_diff/3
Last message: %TeslaMate.Vehicles.Vehicle.Summary{car: %TeslaMate.Log.Car{__meta__: #Ecto.Schema.Metadata<:loaded, "cars">, id: 1, name: nil, efficiency: 0.15225, model: "3", trim_badging: "P74D", marketing_name: "LR AWD Performance", exterior_color: "DeepBlue", wheel_type: "Stiletto20DarkSquare", spoiler_type: "Passive", eid: <<redacted>>, vid: <<redacted>>, vin: "<<redacted>>", settings_id: 1, settings: %TeslaMate.Settings.CarSettings{__meta__: #Ecto.Schema.Metadata<:loaded, "car_settings">, id: 1, suspend_min: 21, suspend_after_idle_min: 15, req_not_unlocked: true, free_supercharging: false, use_streaming_api: true, car: #Ecto.Association.NotLoaded<association :car is not loaded>}, charging_processes: #Ecto.Association.NotLoaded<association :charging_processes is not loaded>, positions: #Ecto.Association.NotLoaded<association :positions is not loaded>, drives: #Ecto.Association.NotLoaded<association :drives is not loaded>, inserted_at: ~N[2020-03-05 00:16:49], updated_at: ~N[2023-02-17 00:29:21]}, display_name: "", state: :charging, since: ~U[2024-03-31 00:30:12.417247Z], healthy: true, latitude: <<redacted>>, longitude: <<redacted>>, heading: 283, battery_level: 38, charging_state: "Charging", usable_battery_level: 37, ideal_battery_range_km: 177.12, est_battery_range_km: 175.43, rated_battery_range_km: 177.12, charge_energy_added: 1.74, speed: nil, outside_temp: 12.5, inside_temp: 13.0, is_climate_on: false, is_preconditioning: false, locked: true, sentry_mode: false, plugged_in: true, scheduled_charging_start_time: ~U[2024-03-31 23:30:00Z], charge_limit_soc: 50, charger_power: 2, windows_open: false, doors_open: false, odometer: <<redacted>>, shift_state: nil, charge_port_door_open: true, time_to_full_charge: 3.92, charger_phases: 1, charger_actual_current: 10, charger_voltage: 237, version: "2024.8.7", update_available: false, update_version: "", is_user_present: false, geofence: %TeslaMate.Locations.GeoFence{__meta__: #Ecto.Schema.Metadata<:loaded, "geofences">, id: 1, name: "Home", latitude: nil, longitude: nil, radius: nil, billing_type: nil, cost_per_unit: nil, session_fee: nil, inserted_at: nil, ...}, model: "3", trim_badging: "P74D", exterior_color: "DeepBlue", wheel_type: "Stiletto20DarkSquare", spoiler_type: "Passive", trunk_open: false, frunk_open: false, elevation: 22, power: -2, charge_current_request: 10, ...}
2024-03-31 02:35:05.618 [error] GenServer #PID<0.20634.1> terminating

I've reported this as a bug in Timex at bitwalker/timex#755 but the problem can be avoided in TeslaMate with the attached pull request.

Copy link

netlify bot commented Apr 16, 2024

Deploy Preview for teslamate ready!

Name Link
🔨 Latest commit 87eff74
🔍 Latest deploy log https://app.netlify.com/sites/teslamate/deploys/661fa1b54c12730008868024
😎 Deploy Preview https://deploy-preview-3848--teslamate.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@JakobLichterfeld
Copy link
Collaborator

Good catch.
CI is failing, as the POT file is out of date. Please mix gettext.extract --merge to generate the new pot file and commit (see https://docs.teslamate.org/docs/development#update-pot-files-extract-messages-for-translation)

@JakobLichterfeld JakobLichterfeld added kind:bug Something isn't working area:teslamate Related to TeslaMate core labels Apr 16, 2024
@dyxyl
Copy link
Contributor Author

dyxyl commented Apr 16, 2024

Fixed now (sorry, I thought that error was just something random).

@brianmay
Copy link
Collaborator

Arggh. Not the first time I have had problems with Timex failing to deal with daylight savings correctly. bitwalker/timex#660

@dyxyl
Copy link
Contributor Author

dyxyl commented Apr 16, 2024

@brianmay I'm hopeful that Timex.local will also work for your time zone.

@JakobLichterfeld
Copy link
Collaborator

Fixed now (sorry, I thought that error was just something random).

Thanks. The PR is now a bit messy. As your branch was not up to date with latest master

@dyxyl
Copy link
Contributor Author

dyxyl commented Apr 17, 2024

I've merged the changes from the latest master if that makes any difference.

@JakobLichterfeld
Copy link
Collaborator

Thanks, was my bad, as the pot files really needed to be updated as the line number changes due to your change :-)

@JakobLichterfeld JakobLichterfeld merged commit 7a5625f into teslamate-org:master Apr 17, 2024
12 checks passed
@dyxyl dyxyl deleted the work-around-timex-bug-755 branch April 17, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:teslamate Related to TeslaMate core kind:bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants