v0.14.12
This commit is contained in:
@@ -27,7 +27,7 @@ async fn export_configuration(
|
||||
|
||||
fn validate_configuration_header(export: &ConfigurationExport) -> Result<(), AppError> {
|
||||
if export.format_version != 3 {
|
||||
return Err(AppError::BadRequest("unsupported configuration export version; version 3 is required by GREE Controller 0.14.11".into()));
|
||||
return Err(AppError::BadRequest("unsupported configuration export version; version 3 is required by GREE Controller 0.14.12".into()));
|
||||
}
|
||||
if export.settings.control_strategy != "setpoint" {
|
||||
return Err(AppError::BadRequest(
|
||||
|
||||
@@ -49,9 +49,10 @@ fn public_settings(settings: &RuntimeSettings) -> Value {
|
||||
"history_threshold_days": settings.influxdb.history_threshold_days,
|
||||
},
|
||||
"home_assistant": {
|
||||
"url": settings.home_assistant.url,
|
||||
"url": home_assistant::effective_url(&settings.home_assistant),
|
||||
"auth_mode": home_assistant::auth_mode(),
|
||||
"token": "",
|
||||
"token_configured": !settings.home_assistant.token.trim().is_empty(),
|
||||
"token_configured": home_assistant::token_configured(&settings.home_assistant),
|
||||
"outdoor_entity_id": settings.home_assistant.outdoor_entity_id,
|
||||
"sensor_stale_after_seconds": settings.home_assistant.sensor_stale_after_seconds,
|
||||
"allow_invalid_tls": settings.home_assistant.allow_invalid_tls,
|
||||
|
||||
+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