v0.14.12
This commit is contained in:
+16
-6
@@ -78,8 +78,9 @@ fn notification_settings(settings: &RuntimeSettings) -> NotificationSettingsView
|
||||
|
||||
fn home_assistant_settings(settings: &RuntimeSettings) -> HomeAssistantSettingsView {
|
||||
HomeAssistantSettingsView {
|
||||
url: settings.home_assistant.url.clone(),
|
||||
token_configured: !settings.home_assistant.token.trim().is_empty(),
|
||||
url: home_assistant::effective_url(&settings.home_assistant),
|
||||
auth_mode: home_assistant::auth_mode().to_string(),
|
||||
token_configured: home_assistant::token_configured(&settings.home_assistant),
|
||||
outdoor_entity_id: settings.home_assistant.outdoor_entity_id.clone(),
|
||||
sensor_stale_after_seconds: settings.home_assistant.sensor_stale_after_seconds,
|
||||
allow_invalid_tls: settings.home_assistant.allow_invalid_tls,
|
||||
@@ -693,8 +694,13 @@ fn apply_home_assistant_update(
|
||||
current: &HomeAssistantSettings,
|
||||
input: HomeAssistantSettingsUpdate,
|
||||
) -> HomeAssistantSettings {
|
||||
let supervisor_managed = home_assistant::uses_supervisor_auth();
|
||||
let mut next = HomeAssistantSettings {
|
||||
url: input.url,
|
||||
url: if supervisor_managed {
|
||||
current.url.clone()
|
||||
} else {
|
||||
input.url
|
||||
},
|
||||
token: current.token.clone(),
|
||||
outdoor_entity_id: input.outdoor_entity_id,
|
||||
sensor_stale_after_seconds: input.sensor_stale_after_seconds.clamp(30, 86_400),
|
||||
@@ -702,8 +708,10 @@ fn apply_home_assistant_update(
|
||||
sensor_aliases: input.sensor_aliases,
|
||||
flow_inputs: input.flow_inputs,
|
||||
};
|
||||
if let Some(token) = input.token {
|
||||
next.token = token;
|
||||
if !supervisor_managed {
|
||||
if let Some(token) = input.token {
|
||||
next.token = token;
|
||||
}
|
||||
}
|
||||
next
|
||||
}
|
||||
@@ -720,7 +728,9 @@ async fn update_home_assistant_settings(
|
||||
normalize_sensor_aliases(&mut next);
|
||||
validate_flow_shared_inputs(&mut next, &state)?;
|
||||
canonicalize_home_assistant_entities(&mut next);
|
||||
validate_home_assistant_url(&next)?;
|
||||
if !home_assistant::uses_supervisor_auth() {
|
||||
validate_home_assistant_url(&next)?;
|
||||
}
|
||||
settings.home_assistant = next.clone();
|
||||
settings.outdoor_assist_enabled = input.outdoor_assist_enabled;
|
||||
state.db.save_runtime_settings(&settings)?;
|
||||
|
||||
Reference in New Issue
Block a user