From b643b45ca080c8d3b61cc29f044fdbf7ebb689c8 Mon Sep 17 00:00:00 2001 From: Brian May Date: Thu, 23 Nov 2023 19:06:51 +1100 Subject: [PATCH] Add charging_state to VehicleSummary (#3471) * Add charging_state to VehicleSummary Fixes: #3078 * WIP --- lib/teslamate/vehicles/vehicle/summary.ex | 3 ++- test/teslamate/vehicles/vehicle/charging_test.exs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/teslamate/vehicles/vehicle/summary.ex b/lib/teslamate/vehicles/vehicle/summary.ex index f55aa75fc2..29f8e0b846 100644 --- a/lib/teslamate/vehicles/vehicle/summary.ex +++ b/lib/teslamate/vehicles/vehicle/summary.ex @@ -6,7 +6,7 @@ defmodule TeslaMate.Vehicles.Vehicle.Summary do alias TeslaMate.Log.Car defstruct ~w( - car display_name state since healthy latitude longitude heading battery_level usable_battery_level + car display_name state since healthy latitude longitude heading battery_level charging_state usable_battery_level ideal_battery_range_km est_battery_range_km rated_battery_range_km charge_energy_added speed outside_temp inside_temp is_climate_on is_preconditioning locked sentry_mode plugged_in scheduled_charging_start_time charge_limit_soc charger_power windows_open doors_open @@ -84,6 +84,7 @@ defmodule TeslaMate.Vehicles.Vehicle.Summary do # Charge State battery_level: charge(vehicle, :battery_level), + charging_state: charge(vehicle, :charging_state), charge_current_request: charge(vehicle, :charge_current_request), charge_current_request_max: charge(vehicle, :charge_current_request_max), charge_energy_added: charge(vehicle, :charge_energy_added), diff --git a/test/teslamate/vehicles/vehicle/charging_test.exs b/test/teslamate/vehicles/vehicle/charging_test.exs index 7ad386076c..106d64dfbc 100644 --- a/test/teslamate/vehicles/vehicle/charging_test.exs +++ b/test/teslamate/vehicles/vehicle/charging_test.exs @@ -91,6 +91,7 @@ defmodule TeslaMate.Vehicles.Vehicle.ChargingTest do assert_receive {:pubsub, {:broadcast, _, _, %Summary{state: :online, since: ^s2}}} + assert_receive {:pubsub, {:broadcast, _, _, %Summary{state: :online}}} refute_receive _ end @@ -151,6 +152,7 @@ defmodule TeslaMate.Vehicles.Vehicle.ChargingTest do assert_receive {:pubsub, {:broadcast, _, _, %Summary{state: :online}}} + assert_receive {:pubsub, {:broadcast, _, _, %Summary{state: :online}}} refute_receive _ end