This commit is contained in:
fuenmao
2026-10-09 18:06:11 +08:00
parent e6b90a06ab
commit 2d44cc3966
17 changed files with 1161 additions and 264 deletions
@@ -88,6 +88,7 @@ public sealed class HomeAssistantDeviceCatalog
Category = category,
Online = isOnline,
PrimaryControlEntityId = primaryControlEntityId,
DefaultLightEffect = DefaultLightEffect(primaryControlEntityId),
Entities = entityOutputs,
Metrics = metrics
});
@@ -125,12 +126,16 @@ public sealed class HomeAssistantDeviceCatalog
DeviceId = $"fallback_{module.Key}", ModuleKey = module.Key, Name = module.DisplayName,
Category = module.Category, Online = entityOutputs.Any(entity => entity.Available),
PrimaryControlEntityId = FindPrimaryControlEntityId(module.Category, entityOutputs),
DefaultLightEffect = DefaultLightEffect(module.PrimaryEntityId),
Entities = entityOutputs, Metrics = ExtractDeviceMetrics(module.Category, entityOutputs)
});
}
return list;
}
private string? DefaultLightEffect(string? entityId) => _options.AdditionalSleepLights.FirstOrDefault(light =>
string.Equals(light.EntityId, entityId, StringComparison.OrdinalIgnoreCase))?.SleepEffect;
private string? FindPrimaryControlEntityId(
string category,
IReadOnlyList<HomeAssistantEntityOutput> entities)
@@ -301,6 +306,7 @@ public sealed class HomeAssistantDeviceCatalog
"friendly_name", "unit_of_measurement", "device_class",
"current_humidity", "humidity", "mode", "fan_mode", "percentage",
"brightness", "color_temp", "color_temp_kelvin",
"supported_color_modes", "color_mode", "min_color_temp_kelvin", "max_color_temp_kelvin", "effect_list", "effect",
"volume_level", "is_volume_muted", "media_title",
"battery_level", "temperature", "options", "min", "max", "step", "hvac_modes", "supported_features",
"current_temperature", "temperature_unit", "min_temp", "max_temp", "target_temp_step",