diff --git a/lib/teslamate/settings/car_settings.ex b/lib/teslamate/settings/car_settings.ex
index 2e8a8777..434cd14c 100644
--- a/lib/teslamate/settings/car_settings.ex
+++ b/lib/teslamate/settings/car_settings.ex
@@ -8,8 +8,6 @@ defmodule TeslaMate.Settings.CarSettings do
field :suspend_min, :integer, default: 21
field :suspend_after_idle_min, :integer, default: 15
- field :req_no_shift_state_reading, :boolean, default: false
- field :req_no_temp_reading, :boolean, default: false
field :req_not_unlocked, :boolean, default: true
field :free_supercharging, :boolean, default: false
@@ -22,8 +20,6 @@ defmodule TeslaMate.Settings.CarSettings do
@all_fields [
:suspend_min,
:suspend_after_idle_min,
- :req_no_shift_state_reading,
- :req_no_temp_reading,
:req_not_unlocked,
:free_supercharging,
:use_streaming_api
diff --git a/lib/teslamate/vehicles/vehicle.ex b/lib/teslamate/vehicles/vehicle.ex
index c88db08f..3afa8cd4 100644
--- a/lib/teslamate/vehicles/vehicle.ex
+++ b/lib/teslamate/vehicles/vehicle.ex
@@ -1219,18 +1219,6 @@ defmodule TeslaMate.Vehicles.Vehicle do
{:keep_state_and_data, [broadcast_summary(), schedule_fetch(data)]}
- {:error, :shift_state} ->
- if suspend?,
- do: Logger.warn("Shift state reading prevents car to go to sleep", car_id: car.id)
-
- {:keep_state, %Data{data | last_used: DateTime.utc_now()}, schedule_fetch(data)}
-
- {:error, :temp_reading} ->
- if suspend?,
- do: Logger.warn("Temperature readings prevents car to go to sleep", car_id: car.id)
-
- {:keep_state, %Data{data | last_used: DateTime.utc_now()}, schedule_fetch(data)}
-
{:error, :cannot_determine_location} ->
Logger.warn("Cannot determine vehicle position", car_id: car.id)
@@ -1271,16 +1259,6 @@ defmodule TeslaMate.Vehicles.Vehicle do
%CarSettings{req_not_unlocked: true}} ->
{:error, :unlocked}
- {%Vehicle{drive_state: %Drive{shift_state: shift_state}},
- %CarSettings{req_no_shift_state_reading: true}}
- when not is_nil(shift_state) ->
- {:error, :shift_state}
-
- {%Vehicle{climate_state: %Climate{outside_temp: out_t, inside_temp: in_t}},
- %CarSettings{req_no_temp_reading: true}}
- when not is_nil(out_t) or not is_nil(in_t) ->
- {:error, :temp_reading}
-
{%Vehicle{}, %CarSettings{}} ->
:ok
end
diff --git a/lib/teslamate_web/templates/settings/index.html.leex b/lib/teslamate_web/templates/settings/index.html.leex
index 19de5537..c398b442 100644
--- a/lib/teslamate_web/templates/settings/index.html.leex
+++ b/lib/teslamate_web/templates/settings/index.html.leex
@@ -71,18 +71,6 @@
-
-
- <%= checkbox(f, :req_no_shift_state_reading) %>
- <%= gettext("No shift state reading") %>
-
-
-
-
- <%= checkbox(f, :req_no_temp_reading) %>
- <%= gettext("No temperature readings") %>
-
-
<%= checkbox(f, :req_not_unlocked) %>
@@ -92,9 +80,6 @@
-
- <%= gettext("Some firmware versions stop reporting temperatures or the shift state before the car is ready to sleep. Enabling these options will wait for the readings to stop.") %>
-
diff --git a/priv/repo/migrations/20200401171402_remove_sleep_mode_requirements.exs b/priv/repo/migrations/20200401171402_remove_sleep_mode_requirements.exs
new file mode 100644
index 00000000..6ce0b848
--- /dev/null
+++ b/priv/repo/migrations/20200401171402_remove_sleep_mode_requirements.exs
@@ -0,0 +1,10 @@
+defmodule TeslaMate.Repo.Migrations.RemoveSleepModeRequirements do
+ use Ecto.Migration
+
+ def change do
+ alter table(:car_settings) do
+ remove(:req_no_shift_state_reading, :boolean, null: false, default: false)
+ remove(:req_no_temp_reading, :boolean, null: false, default: false)
+ end
+ end
+end
diff --git a/test/teslamate/settings_test.exs b/test/teslamate/settings_test.exs
index 0a56f891..feeb8e6c 100644
--- a/test/teslamate/settings_test.exs
+++ b/test/teslamate/settings_test.exs
@@ -120,8 +120,6 @@ defmodule TeslaMate.SettingsTest do
@update_attrs %{
suspend_min: 60,
suspend_after_idle_min: 60,
- req_no_shift_state_reading: false,
- req_no_temp_reading: false,
req_not_unlocked: true,
free_supercharging: true,
use_streaming_api: true
@@ -129,8 +127,6 @@ defmodule TeslaMate.SettingsTest do
@invalid_attrs %{
suspend_min: nil,
suspend_after_idle_min: nil,
- req_no_shift_state_reading: nil,
- req_no_temp_reading: nil,
req_not_unlocked: nil,
free_supercharging: nil,
use_streaming_api: nil
@@ -143,8 +139,6 @@ defmodule TeslaMate.SettingsTest do
assert settings.id == car.settings_id
assert settings.suspend_min == 21
assert settings.suspend_after_idle_min == 15
- assert settings.req_no_shift_state_reading == false
- assert settings.req_no_temp_reading == false
assert settings.req_not_unlocked == true
assert settings.free_supercharging == false
assert settings.use_streaming_api == false
@@ -162,8 +156,6 @@ defmodule TeslaMate.SettingsTest do
assert settings.id == car.settings_id
assert settings.suspend_min == 60
assert settings.suspend_after_idle_min == 60
- assert settings.req_no_shift_state_reading == false
- assert settings.req_no_temp_reading == false
assert settings.req_not_unlocked == true
assert settings.free_supercharging == true
assert settings.use_streaming_api == true
@@ -191,8 +183,6 @@ defmodule TeslaMate.SettingsTest do
Settings.update_car_settings(settings, @invalid_attrs)
assert errors_on(changeset) == %{
- req_no_shift_state_reading: ["can't be blank"],
- req_no_temp_reading: ["can't be blank"],
req_not_unlocked: ["can't be blank"],
suspend_after_idle_min: ["can't be blank"],
suspend_min: ["can't be blank"],
diff --git a/test/teslamate/vehicles/vehicle/suspend_logging_test.exs b/test/teslamate/vehicles/vehicle/suspend_logging_test.exs
index 405a2a2e..30772d9d 100644
--- a/test/teslamate/vehicles/vehicle/suspend_logging_test.exs
+++ b/test/teslamate/vehicles/vehicle/suspend_logging_test.exs
@@ -220,46 +220,6 @@ defmodule TeslaMate.Vehicles.Vehicle.SuspendLoggingTest do
assert {:error, :charging_in_progress} = Vehicle.suspend_logging(name)
end
- test "cannot be suspended if outside_temp is not nil", %{test: name} do
- not_supendable =
- online_event(
- drive_state: %{timestamp: 0, latitude: 0.0, longitude: 0.0},
- climate_state: %{outside_temp: 20.0}
- )
-
- events = [
- {:ok, online_event()},
- {:ok, not_supendable}
- ]
-
- :ok = start_vehicle(name, events, settings: %{req_no_temp_reading: true})
-
- date = DateTime.from_unix!(0, :millisecond)
- assert_receive {:start_state, _, :online, date: ^date}
-
- assert {:error, :temp_reading} = Vehicle.suspend_logging(name)
- end
-
- test "cannot be suspended if inside_temp is not nil", %{test: name} do
- not_supendable =
- online_event(
- drive_state: %{timestamp: 0, latitude: 0.0, longitude: 0.0},
- climate_state: %{inside_temp: 20.0}
- )
-
- events = [
- {:ok, online_event()},
- {:ok, not_supendable}
- ]
-
- :ok = start_vehicle(name, events, settings: %{req_no_temp_reading: true})
-
- date = DateTime.from_unix!(0, :millisecond)
- assert_receive {:start_state, _, :online, date: ^date}
-
- assert {:error, :temp_reading} = Vehicle.suspend_logging(name)
- end
-
test "suspends when charging is complete", %{test: name} do
now_ts = DateTime.utc_now() |> DateTime.to_unix(:millisecond)
diff --git a/test/teslamate/vehicles/vehicle/suspend_test.exs b/test/teslamate/vehicles/vehicle/suspend_test.exs
index abf8fe0c..4850f701 100644
--- a/test/teslamate/vehicles/vehicle/suspend_test.exs
+++ b/test/teslamate/vehicles/vehicle/suspend_test.exs
@@ -448,109 +448,4 @@ defmodule TeslaMate.Vehicles.Vehicle.SuspendTest do
refute_receive _, 50
end
end
-
- describe "req_no_shift_state_reading" do
- @tag :capture_log
- test "does not suspend if shift_state is not nil", %{test: name} do
- not_supendable =
- online_event(
- drive_state: %{timestamp: 0, shift_state: "P", latitude: 0.0, longitude: 0.0}
- )
-
- events = [
- {:ok, online_event()},
- {:ok, not_supendable}
- ]
-
- sudpend_after_idle_ms = 10
- suspend_ms = 100
-
- :ok =
- start_vehicle(name, events,
- req_no_shift_state_reading: true,
- suspend_after_idle_min: round(sudpend_after_idle_ms / 60),
- suspend_min: suspend_ms
- )
-
- assert_receive {:start_state, car, :online, date: _}
- assert_receive {:insert_position, ^car, %{}}
- assert_receive {:pubsub, {:broadcast, _server, _topic, %Summary{state: :online}}}
- refute_receive _, round(suspend_ms * 0.5)
-
- refute_receive _
- end
- end
-
- describe "req_no_temp_reading" do
- @tag :capture_log
- test "does not suspend if outside_temp is not nil", %{test: name} do
- not_supendable =
- online_event(
- drive_state: %{timestamp: 0, latitude: 0.0, longitude: 0.0},
- climate_state: %{outside_temp: 20.0}
- )
-
- events = [
- {:ok, online_event()},
- {:ok, not_supendable}
- ]
-
- sudpend_after_idle_ms = 10
- suspend_ms = 100
-
- :ok =
- start_vehicle(name, events,
- settings: %{
- req_no_temp_reading: true,
- suspend_after_idle_min: round(sudpend_after_idle_ms / 60),
- suspend_min: suspend_ms
- }
- )
-
- date = DateTime.from_unix!(0, :millisecond)
- assert_receive {:start_state, car, :online, date: ^date}
- assert_receive {:insert_position, ^car, %{}}
-
- assert_receive {:pubsub, {:broadcast, _, _, %Summary{state: :online, outside_temp: 20.0}}}
-
- refute_receive _, round(suspend_ms * 0.5)
-
- refute_receive _
- end
-
- @tag :capture_log
- test "does not suspend if inside_temp is not nil", %{test: name} do
- not_supendable =
- online_event(
- drive_state: %{timestamp: 0, latitude: 0.0, longitude: 0.0},
- climate_state: %{inside_temp: 20.0}
- )
-
- events = [
- {:ok, online_event()},
- {:ok, not_supendable}
- ]
-
- sudpend_after_idle_ms = 10
- suspend_ms = 100
-
- :ok =
- start_vehicle(name, events,
- settings: %{
- req_no_temp_reading: true,
- suspend_after_idle_min: round(sudpend_after_idle_ms / 60),
- suspend_min: suspend_ms
- }
- )
-
- assert_receive {:start_state, car, :online, date: _}
- assert_receive {:insert_position, ^car, %{}}
-
- assert_receive {:pubsub, {:broadcast, _, _, %Summary{state: :online, inside_temp: 20.0}}}
-
- refute_receive _, round(suspend_ms * 0.5)
-
- refute_receive _
- end
- end
end
diff --git a/test/teslamate_web/live/car_summary_live_test.exs b/test/teslamate_web/live/car_summary_live_test.exs
index c091036a..f4cfe81d 100644
--- a/test/teslamate_web/live/car_summary_live_test.exs
+++ b/test/teslamate_web/live/car_summary_live_test.exs
@@ -88,12 +88,6 @@ defmodule TeslaMateWeb.CarLive.SummaryTest do
vehicle_state: %{timestamp: 0, locked: false, car_version: ""}},
{"Sentry mode is enabled", 0, "online", %{req_not_unlocked: true},
vehicle_state: %{timestamp: 0, sentry_mode: true, locked: true, car_version: ""}},
- {"Shift state present", 0, "online", %{req_no_shift_state_reading: true},
- [drive_state: %{latitude: 0.0, longitude: 0.0, shift_state: "P"}]},
- {"Temperature readings", 0, "online", %{req_no_temp_reading: true},
- climate_state: %{outside_temp: 10.0}},
- {"Temperature readings", 1, "online", %{req_no_temp_reading: true},
- climate_state: %{inside_temp: 10.0}},
{"Preconditioning", 0, "online", %{}, climate_state: %{is_preconditioning: true}},
{"Driver present", 0, "online", %{},
vehicle_state: %{timestamp: 0, is_user_present: true, car_version: ""}},
diff --git a/test/teslamate_web/live/settings_test.exs b/test/teslamate_web/live/settings_test.exs
index 0a85a968..835c36c7 100644
--- a/test/teslamate_web/live/settings_test.exs
+++ b/test/teslamate_web/live/settings_test.exs
@@ -287,29 +287,12 @@ defmodule TeslaMateWeb.SettingsLiveTest do
] = Floki.find(html, "#car_settings_#{car.id}_suspend_after_idle_min")
end
- test "shows false, false, true by default", %{conn: conn} do
- car =
- car_fixture(
- settings: %{
- req_no_shift_state_reading: false,
- req_no_temp_reading: false,
- req_not_unlocked: true
- }
- )
+ test "By default, the vehicle must be locked to fall asleep", %{conn: conn} do
+ car = car_fixture(settings: %{req_not_unlocked: true})
assert {:ok, _view, html} = live(conn, "/settings")
html = Floki.parse_document!(html)
- assert [] =
- html
- |> Floki.find("#car_settings_#{car.id}_req_no_shift_state_reading")
- |> Floki.attribute("checked")
-
- assert [] =
- html
- |> Floki.find("#car_settings_#{car.id}_req_no_temp_reading")
- |> Floki.attribute("checked")
-
assert ["checked"] =
html
|> Floki.find("#car_settings_#{car.id}_req_not_unlocked")
@@ -322,8 +305,6 @@ defmodule TeslaMateWeb.SettingsLiveTest do
settings: %{
suspend_min: 21,
suspend_after_idle_min: 15,
- req_no_shift_state_reading: false,
- req_no_temp_reading: false,
req_not_unlocked: true,
free_supercharging: false,
use_streaming_api: false
@@ -352,28 +333,6 @@ defmodule TeslaMateWeb.SettingsLiveTest do
assert [settings] = Settings.get_car_settings()
assert settings.suspend_after_idle_min == 30
- assert ["checked"] =
- render_change(view, :change, %{
- "car_settings_#{car.id}" => %{req_no_shift_state_reading: true}
- })
- |> Floki.parse_document!()
- |> Floki.find("#car_settings_#{car.id}_req_no_shift_state_reading")
- |> Floki.attribute("checked")
-
- assert [settings] = Settings.get_car_settings()
- assert settings.req_no_shift_state_reading == true
-
- assert ["checked"] =
- render_change(view, :change, %{
- "car_settings_#{car.id}" => %{req_no_temp_reading: true}
- })
- |> Floki.parse_document!()
- |> Floki.find("#car_settings_#{car.id}_req_no_temp_reading")
- |> Floki.attribute("checked")
-
- assert [settings] = Settings.get_car_settings()
- assert settings.req_no_temp_reading == true
-
assert [] =
render_change(view, :change, %{
"car_settings_#{car.id}" => %{req_not_unlocked: false}