mirror of
https://github.com/teslamate-org/teslamate.git
synced 2026-01-24 21:06:08 +08:00
Update the default sleep requirements
… so that the car does not need to be locked to go to sleep.
This commit is contained in:
@@ -7,7 +7,7 @@ defmodule TeslaMate.Settings.CarSettings do
|
||||
schema "car_settings" do
|
||||
field :suspend_min, :integer, default: 21
|
||||
field :suspend_after_idle_min, :integer, default: 15
|
||||
field :req_not_unlocked, :boolean, default: true
|
||||
field :req_not_unlocked, :boolean, default: false
|
||||
field :free_supercharging, :boolean, default: false
|
||||
field :use_streaming_api, :boolean, default: true
|
||||
|
||||
|
||||
@@ -288,8 +288,7 @@
|
||||
@summary.state == :online and
|
||||
!@summary.sentry_mode and
|
||||
!@summary.is_user_present and
|
||||
!@summary.is_preconditioning and
|
||||
@summary.locked->
|
||||
!@summary.is_preconditioning ->
|
||||
link gettext("try to sleep"), to: "#", phx_click: "suspend_logging",
|
||||
class: "button is-info is-small is-outlined is-fullwidth" <>
|
||||
(if @loading, do: " is-loading", else: "")
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
defmodule TeslaMate.Repo.Migrations.ChangeSleepRequirementsDefault do
|
||||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
alter table(:car_settings) do
|
||||
modify(:req_not_unlocked, :boolean, null: false, default: false)
|
||||
end
|
||||
end
|
||||
|
||||
def down do
|
||||
alter table(:car_settings) do
|
||||
modify(:req_not_unlocked, :boolean, null: false, default: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -141,7 +141,7 @@ 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_not_unlocked == true
|
||||
assert settings.req_not_unlocked == false
|
||||
assert settings.free_supercharging == false
|
||||
assert settings.use_streaming_api == true
|
||||
end
|
||||
|
||||
@@ -94,13 +94,13 @@ defmodule TeslaMateWeb.CarLive.SummaryTest do
|
||||
end
|
||||
|
||||
for {msg, status, settings, attrs} <- [
|
||||
{"Car is unlocked", "online", %{},
|
||||
{"Car is unlocked", "online", %{req_not_unlocked: true},
|
||||
vehicle_state: %{timestamp: 0, locked: false, car_version: ""}},
|
||||
{"Doors are open", "online", %{},
|
||||
vehicle_state: %{timestamp: 0, df: 1, dr: 0, pf: 0, pr: 0, car_version: ""}},
|
||||
{"Trunk is open", "online", %{},
|
||||
vehicle_state: %{timestamp: 0, rt: 1, ft: 0, car_version: ""}},
|
||||
{"Sentry mode is enabled", "online", %{req_not_unlocked: true},
|
||||
{"Sentry mode is enabled", "online", %{},
|
||||
vehicle_state: %{timestamp: 0, sentry_mode: true, locked: true, car_version: ""}},
|
||||
{"Preconditioning", "online", %{}, climate_state: %{is_preconditioning: true}},
|
||||
{"Driver present", "online", %{},
|
||||
|
||||
@@ -272,7 +272,7 @@ defmodule TeslaMateWeb.SettingsLiveTest do
|
||||
assert [] = Floki.find(html, "#car_settings_#{car.id}_suspend_min")
|
||||
assert [] = Floki.find(html, "#car_settings_#{car.id}_suspend_after_idle_min")
|
||||
|
||||
assert ["checked"] =
|
||||
assert [] =
|
||||
html
|
||||
|> Floki.find("#car_settings_#{car.id}_req_not_unlocked")
|
||||
|> Floki.attribute("checked")
|
||||
|
||||
Reference in New Issue
Block a user