This commit is contained in:
fuenmao
2026-11-12 15:45:52 +08:00
parent 61e25175db
commit 718b138033
30 changed files with 1511 additions and 99 deletions
@@ -16,6 +16,7 @@ internal sealed class FakeHaGateway : IHomeAssistantGateway
public string? FailEntity { get; set; }
public int ReadsToFail { get; set; }
public string? CoverCloseResult { get; set; }
public string? HumidifierTurnOnResult { get; set; }
public TimeProvider Time { get; set; } = TimeProvider.System;
public Task<IReadOnlyList<HomeAssistantState>> GetStatesAsync(CancellationToken cancellationToken = default)
@@ -34,6 +35,7 @@ internal sealed class FakeHaGateway : IHomeAssistantGateway
if (entity == FailEntity) throw new IOException("模拟设备命令失败");
var state = service switch
{
"turn_on" when domain == "humidifier" && HumidifierTurnOnResult is not null => HumidifierTurnOnResult,
"turn_on" => "on", "turn_off" => "off",
"close_cover" when CoverCloseResult is not null => CoverCloseResult,
"select_option" => data["option"]!.ToString()!,