去掉老床垫相关功能
This commit is contained in:
@@ -4,7 +4,6 @@ using Evergreen.Health.Application.Health.Devices.Contracts;
|
||||
using Evergreen.Health.Application.Health.Devices.Discovery;
|
||||
using Evergreen.Health.Application.Health.Devices.Environment;
|
||||
using Evergreen.Health.Application.Health.Devices.Lighting;
|
||||
using Evergreen.Health.Application.Health.Devices.Mattress;
|
||||
using Evergreen.Health.Application.Health.Integrations.HomeAssistant;
|
||||
using Evergreen.Health.Application.Health.Integrations.MiAirX;
|
||||
using Evergreen.Health.Application.Health.Models;
|
||||
@@ -26,9 +25,8 @@ public sealed class SceneLightingIntegrationTests
|
||||
private static SceneLightOptions StripSettings() => new() { Key = "sleep-light-strip", Name = "测试助眠灯带", EntityId = Strip, SleepEffect = "助眠模式" };
|
||||
private static HomeAssistantOptions Settings() => new()
|
||||
{
|
||||
Entities = new() { AmbientLight = Primary, Climate = Climate, Temperature = Temperature,
|
||||
MattressLeftHeatingLevel = "number.left_heat", MattressRightHeatingLevel = "number.right_heat" },
|
||||
AdditionalSleepLights = [StripSettings()], SleepScene = new() { EnableMattress = true }
|
||||
Entities = new() { AmbientLight = Primary, Climate = Climate, Temperature = Temperature },
|
||||
AdditionalSleepLights = [StripSettings()]
|
||||
};
|
||||
private static HomeAssistantState Light(string id, string state = "off", string[]? effects = null) => new()
|
||||
{
|
||||
@@ -62,7 +60,7 @@ public sealed class SceneLightingIntegrationTests
|
||||
public DeviceActionRunner Runner { get; }
|
||||
public DeviceModuleRegistry Modules { get; }
|
||||
public HealthSceneCoordinator Coordinator { get; }
|
||||
public Fixture(bool mattress = false)
|
||||
public Fixture()
|
||||
{
|
||||
Gateway = new() { Time = Time };
|
||||
Gateway.States[Primary] = Light(Primary); Gateway.States[Strip] = Light(Strip);
|
||||
@@ -77,7 +75,6 @@ public sealed class SceneLightingIntegrationTests
|
||||
new ConfiguredSleepLightModule(Runner, StripSettings(), Lights.ForEntity(Strip)),
|
||||
new ClimateModule(Runner, Options)
|
||||
};
|
||||
if (mattress) modules.Add(new MattressModule(Runner, Options));
|
||||
Modules = new(modules);
|
||||
Coordinator = new(Modules, Runner, Gateway, Lights, new FakeMusic());
|
||||
}
|
||||
@@ -89,10 +86,10 @@ public sealed class SceneLightingIntegrationTests
|
||||
LastReported = Time.GetUtcNow(), Attributes = JsonSerializer.SerializeToElement(new { unit_of_measurement = "°C" })
|
||||
};
|
||||
else Gateway.States.TryRemove(Temperature, out _);
|
||||
var comfort = new MattressComfortService(Gateway, new IndoorEnvironmentReader(Options, Time), Options)
|
||||
var comfort = new EnvironmentAdviceService(Gateway, new IndoorEnvironmentReader(Options, Time), Options)
|
||||
.Get(null, Gateway.States);
|
||||
var config = new PersonalizedSceneConfig { LightColorTemperatureKelvin = 3000 };
|
||||
MattressComfortService.ApplyTo(config, comfort);
|
||||
EnvironmentAdviceService.ApplyTo(config, comfort);
|
||||
RoomTemperaturePolicy.PickTargetForSession(config.ClimateAdvice);
|
||||
return new(config, "balanced");
|
||||
}
|
||||
@@ -134,7 +131,7 @@ public sealed class SceneLightingIntegrationTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task BothLightsReachZeroAndOnlyOriginalLightKeepsMassageShutdownHook()
|
||||
public async Task BothLightsReachZeroAndOnlyOriginalLightKeepsLightOffEvent()
|
||||
{
|
||||
var f = new Fixture();
|
||||
try
|
||||
@@ -171,21 +168,21 @@ public sealed class SceneLightingIntegrationTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(15, "heat", 1)]
|
||||
[InlineData(30, "cool", 0)]
|
||||
[InlineData(22, "off", 0)]
|
||||
[InlineData(24, "off", 0)]
|
||||
[InlineData(25, "off", 0)]
|
||||
public async Task EnvironmentSensorDrivesActualSceneClimateAndBothHeatingLevels(double room, string mode, int heating)
|
||||
[InlineData(15, "heat")]
|
||||
[InlineData(30, "cool")]
|
||||
[InlineData(22, "off")]
|
||||
[InlineData(24, "off")]
|
||||
[InlineData(25, "off")]
|
||||
public async Task EnvironmentSensorDrivesActualSceneClimateWithoutRetiredHeating(double room, string mode)
|
||||
{
|
||||
var f = new Fixture(mattress: true);
|
||||
var f = new Fixture();
|
||||
try
|
||||
{
|
||||
var prepared = f.Prepare(room);
|
||||
var result = await CompleteAsync(f.Coordinator.ExecutePreparedSleepAsync(_ => Task.FromResult(prepared), default), f.Time);
|
||||
Assert.True(result.Success); Assert.Equal(mode, result.ClimateAdvice!.Mode);
|
||||
Assert.False(result.ClimateAdvice.PendingIntegration);
|
||||
foreach (var id in new[] { "number.left_heat", "number.right_heat" }) Assert.Equal(heating.ToString(), f.Gateway.States[id].State);
|
||||
Assert.DoesNotContain(f.Gateway.Calls, call => call.EntityId is "number.left_heat" or "number.right_heat");
|
||||
if (mode == "off")
|
||||
{
|
||||
Assert.Null(result.ClimateAdvice.TargetTemperatureCelsius);
|
||||
@@ -211,11 +208,10 @@ public sealed class SceneLightingIntegrationTests
|
||||
var prepared = f.Prepare(null);
|
||||
var result = await f.Coordinator.ExecuteAsync("sleep", prepared.Config, "balanced", default);
|
||||
Assert.Equal("unavailable", result.ClimateAdvice!.Mode);
|
||||
Assert.Equal(0, prepared.Config.MattressHeatingLevel);
|
||||
Assert.DoesNotContain(f.Gateway.Calls, call => call.EntityId == Climate);
|
||||
f.Prepare(15); f.Time.Advance(TimeSpan.FromMinutes(31));
|
||||
var comfort = new MattressComfortService(f.Gateway, new IndoorEnvironmentReader(f.Options, f.Time), f.Options).Get(null, f.Gateway.States);
|
||||
Assert.Equal("unavailable", comfort.ClimateAdvice.Mode); Assert.Equal(0, comfort.HeatingLevel);
|
||||
var comfort = new EnvironmentAdviceService(f.Gateway, new IndoorEnvironmentReader(f.Options, f.Time), f.Options).Get(null, f.Gateway.States);
|
||||
Assert.Equal("unavailable", comfort.ClimateAdvice.Mode);
|
||||
}
|
||||
finally { await f.Lights.StopAsync(default); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user