Add demand window sensor for amberelectric (#121356)

This commit is contained in:
Xidorn Quan
2024-07-06 20:28:52 +10:00
committed by GitHub
parent be0cf545b2
commit 2bc7904b51
5 changed files with 123 additions and 15 deletions

View File

@@ -105,7 +105,7 @@ async def setup_general_and_feed_in(hass: HomeAssistant) -> AsyncGenerator[Mock]
async def test_general_price_sensor(hass: HomeAssistant, setup_general: Mock) -> None:
"""Test the General Price sensor."""
assert len(hass.states.async_all()) == 5
assert len(hass.states.async_all()) == 6
price = hass.states.get("sensor.mock_title_general_price")
assert price
assert price.state == "0.08"
@@ -143,7 +143,7 @@ async def test_general_price_sensor(hass: HomeAssistant, setup_general: Mock) ->
@pytest.mark.usefixtures("setup_general_and_controlled_load")
async def test_general_and_controlled_load_price_sensor(hass: HomeAssistant) -> None:
"""Test the Controlled Price sensor."""
assert len(hass.states.async_all()) == 8
assert len(hass.states.async_all()) == 9
price = hass.states.get("sensor.mock_title_controlled_load_price")
assert price
assert price.state == "0.08"
@@ -165,7 +165,7 @@ async def test_general_and_controlled_load_price_sensor(hass: HomeAssistant) ->
@pytest.mark.usefixtures("setup_general_and_feed_in")
async def test_general_and_feed_in_price_sensor(hass: HomeAssistant) -> None:
"""Test the Feed In sensor."""
assert len(hass.states.async_all()) == 8
assert len(hass.states.async_all()) == 9
price = hass.states.get("sensor.mock_title_feed_in_price")
assert price
assert price.state == "-0.08"
@@ -188,7 +188,7 @@ async def test_general_forecast_sensor(
hass: HomeAssistant, setup_general: Mock
) -> None:
"""Test the General Forecast sensor."""
assert len(hass.states.async_all()) == 5
assert len(hass.states.async_all()) == 6
price = hass.states.get("sensor.mock_title_general_forecast")
assert price
assert price.state == "0.09"
@@ -230,7 +230,7 @@ async def test_general_forecast_sensor(
@pytest.mark.usefixtures("setup_general_and_controlled_load")
async def test_controlled_load_forecast_sensor(hass: HomeAssistant) -> None:
"""Test the Controlled Load Forecast sensor."""
assert len(hass.states.async_all()) == 8
assert len(hass.states.async_all()) == 9
price = hass.states.get("sensor.mock_title_controlled_load_forecast")
assert price
assert price.state == "0.09"
@@ -254,7 +254,7 @@ async def test_controlled_load_forecast_sensor(hass: HomeAssistant) -> None:
@pytest.mark.usefixtures("setup_general_and_feed_in")
async def test_feed_in_forecast_sensor(hass: HomeAssistant) -> None:
"""Test the Feed In Forecast sensor."""
assert len(hass.states.async_all()) == 8
assert len(hass.states.async_all()) == 9
price = hass.states.get("sensor.mock_title_feed_in_forecast")
assert price
assert price.state == "-0.09"
@@ -278,7 +278,7 @@ async def test_feed_in_forecast_sensor(hass: HomeAssistant) -> None:
@pytest.mark.usefixtures("setup_general")
def test_renewable_sensor(hass: HomeAssistant) -> None:
"""Testing the creation of the Amber renewables sensor."""
assert len(hass.states.async_all()) == 5
assert len(hass.states.async_all()) == 6
sensor = hass.states.get("sensor.mock_title_renewables")
assert sensor
assert sensor.state == "51"
@@ -287,7 +287,7 @@ def test_renewable_sensor(hass: HomeAssistant) -> None:
@pytest.mark.usefixtures("setup_general")
def test_general_price_descriptor_descriptor_sensor(hass: HomeAssistant) -> None:
"""Test the General Price Descriptor sensor."""
assert len(hass.states.async_all()) == 5
assert len(hass.states.async_all()) == 6
price = hass.states.get("sensor.mock_title_general_price_descriptor")
assert price
assert price.state == "extremely_low"
@@ -298,7 +298,7 @@ def test_general_and_controlled_load_price_descriptor_sensor(
hass: HomeAssistant,
) -> None:
"""Test the Controlled Price Descriptor sensor."""
assert len(hass.states.async_all()) == 8
assert len(hass.states.async_all()) == 9
price = hass.states.get("sensor.mock_title_controlled_load_price_descriptor")
assert price
assert price.state == "extremely_low"
@@ -307,7 +307,7 @@ def test_general_and_controlled_load_price_descriptor_sensor(
@pytest.mark.usefixtures("setup_general_and_feed_in")
def test_general_and_feed_in_price_descriptor_sensor(hass: HomeAssistant) -> None:
"""Test the Feed In Price Descriptor sensor."""
assert len(hass.states.async_all()) == 8
assert len(hass.states.async_all()) == 9
price = hass.states.get("sensor.mock_title_feed_in_price_descriptor")
assert price
assert price.state == "extremely_low"