feat: migrate boiler control implementation to BoilerMonitor namespace and add budget handling logic
This commit is contained in:
@@ -31,15 +31,13 @@ public class NordPoolEntityServiceTests
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
result.Should().HaveCount(8);
|
||||
result.Should().HaveCount(6);
|
||||
result.Should().Contain(e => e.EntityId == "sensor.nordpool_last_update_time");
|
||||
result.Should().Contain(e => e.EntityId == "sensor.nordpool_current_price");
|
||||
result.Should().Contain(e => e.EntityId == "sensor.nordpool_today_prices");
|
||||
result.Should().Contain(e => e.EntityId == "sensor.nordpool_tomorrow_prices");
|
||||
result.Should().Contain(e => e.EntityId == "sensor.nordpool_today_tomorrow_prices");
|
||||
result.Should().Contain(e => e.EntityId == "sensor.nordpool_cheapest_intervals");
|
||||
result.Should().Contain(e => e.EntityId == "sensor.nordpool_boiler_water_ready");
|
||||
result.Should().Contain(e => e.EntityId == "switch.nordpool_boiler_skip_price_cap");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -76,9 +74,7 @@ public class NordPoolEntityServiceTests
|
||||
var result = _sut.GetInitEntitiesList("EUR/kWh");
|
||||
|
||||
// Assert
|
||||
result.Should().Contain(e => e.Domain == "sensor");
|
||||
result.Should().Contain(e => e.Domain == "switch");
|
||||
result.Should().OnlyContain(e => e.Domain == "sensor" || e.Domain == "switch");
|
||||
result.Should().OnlyContain(e => e.Domain == "sensor");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -106,7 +102,7 @@ public class NordPoolEntityServiceTests
|
||||
await _sut.CreateEntitiesAsync("EUR/kWh");
|
||||
|
||||
// Assert
|
||||
_entityManagerMock.Verify(em => em.CreateEntityAsync(It.IsAny<NordPoolEntity>()), Times.Exactly(8));
|
||||
_entityManagerMock.Verify(em => em.CreateEntityAsync(It.IsAny<NordPoolEntity>()), Times.Exactly(6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -130,7 +126,7 @@ public class NordPoolEntityServiceTests
|
||||
await _sut.CreateEntitiesAsync("EUR/kWh");
|
||||
|
||||
// Assert
|
||||
_entityManagerMock.Verify(em => em.CreateEntityAsync(It.IsAny<NordPoolEntity>()), Times.Exactly(8));
|
||||
_entityManagerMock.Verify(em => em.CreateEntityAsync(It.IsAny<NordPoolEntity>()), Times.Exactly(6));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -154,8 +150,6 @@ public class NordPoolEntityServiceTests
|
||||
_entityManagerMock.Verify(em => em.RemoveEntity("sensor.nordpool_tomorrow_prices"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.RemoveEntity("sensor.nordpool_today_tomorrow_prices"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.RemoveEntity("sensor.nordpool_cheapest_intervals"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.RemoveEntity("sensor.nordpool_boiler_water_ready"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.RemoveEntity("switch.nordpool_boiler_skip_price_cap"), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -256,13 +250,11 @@ public class NordPoolEntityServiceTests
|
||||
|
||||
// Assert
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_last_update_time", "unknown"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_current_price", "0"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_current_price", ""), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_today_prices", "0"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_tomorrow_prices", "0"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_today_tomorrow_prices", "unknown"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_cheapest_intervals", "0"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_boiler_water_ready", "unknown"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("switch.nordpool_boiler_skip_price_cap", "OFF"), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -284,7 +276,6 @@ public class NordPoolEntityServiceTests
|
||||
_entityManagerMock.Verify(em => em.SetEntityAttributes("sensor.nordpool_tomorrow_prices", It.IsAny<object>()), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityAttributes("sensor.nordpool_today_tomorrow_prices", It.IsAny<object>()), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityAttributes("sensor.nordpool_cheapest_intervals", It.IsAny<object>()), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityAttributes("sensor.nordpool_boiler_water_ready", It.IsAny<object>()), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -308,7 +299,7 @@ public class NordPoolEntityServiceTests
|
||||
[Fact]
|
||||
public async Task ResetEntitiesAsync_ShouldCallSetStateAndAttributesCorrectly()
|
||||
{
|
||||
// Arrange - 8 entities get state, 7 entities get attributes (switch has state only)
|
||||
// Arrange - 6 entities get state and attributes
|
||||
_entityManagerMock.Setup(em => em.SetEntityState(It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Returns(Task.CompletedTask);
|
||||
_entityManagerMock.Setup(em => em.SetEntityAttributes(It.IsAny<string>(), It.IsAny<object>()))
|
||||
@@ -318,8 +309,8 @@ public class NordPoolEntityServiceTests
|
||||
await _sut.ResetEntitiesAsync();
|
||||
|
||||
// Assert
|
||||
_entityManagerMock.Verify(em => em.SetEntityState(It.IsAny<string>(), It.IsAny<string>()), Times.Exactly(8));
|
||||
_entityManagerMock.Verify(em => em.SetEntityAttributes(It.IsAny<string>(), It.IsAny<object>()), Times.Exactly(7));
|
||||
_entityManagerMock.Verify(em => em.SetEntityState(It.IsAny<string>(), It.IsAny<string>()), Times.Exactly(6));
|
||||
_entityManagerMock.Verify(em => em.SetEntityAttributes(It.IsAny<string>(), It.IsAny<object>()), Times.Exactly(6));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -353,10 +344,7 @@ public class NordPoolEntityServiceTests
|
||||
SkipPriceCap = false,
|
||||
ConfiguredReadyBy = "06:00",
|
||||
IsNowCheap = false,
|
||||
NextCheapIntervalStart = null,
|
||||
WaterReady = false,
|
||||
BoilerSwitchState = "off",
|
||||
BoilerPowerWatts = 0.0
|
||||
NextCheapIntervalStart = null
|
||||
};
|
||||
}
|
||||
|
||||
@@ -381,7 +369,6 @@ public class NordPoolEntityServiceTests
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_tomorrow_prices", "1"), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_today_tomorrow_prices", It.Is<string>(s => s.Contains('-') && s.Contains(':'))), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_cheapest_intervals", It.IsAny<string>()), Times.Once);
|
||||
_entityManagerMock.Verify(em => em.SetEntityState("sensor.nordpool_boiler_water_ready", It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user