2020-09-08 06:37:44 +00:00
|
|
|
"""Tests for the Plugwise Sensor integration."""
|
|
|
|
|
2022-02-10 19:41:30 +00:00
|
|
|
from unittest.mock import MagicMock
|
2020-09-08 06:37:44 +00:00
|
|
|
|
2022-02-10 19:41:30 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2020-09-08 06:37:44 +00:00
|
|
|
|
2022-02-10 19:41:30 +00:00
|
|
|
from tests.common import MockConfigEntry
|
2020-09-08 06:37:44 +00:00
|
|
|
|
|
|
|
|
2022-02-10 19:41:30 +00:00
|
|
|
async def test_adam_climate_sensor_entities(
|
|
|
|
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
|
|
|
|
) -> None:
|
|
|
|
"""Test creation of climate related sensor entities."""
|
2020-09-08 06:37:44 +00:00
|
|
|
state = hass.states.get("sensor.adam_outdoor_temperature")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2020-09-08 06:37:44 +00:00
|
|
|
assert float(state.state) == 7.81
|
|
|
|
|
|
|
|
state = hass.states.get("sensor.cv_pomp_electricity_consumed")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2020-09-08 06:37:44 +00:00
|
|
|
assert float(state.state) == 35.6
|
|
|
|
|
2022-02-08 18:08:01 +00:00
|
|
|
state = hass.states.get("sensor.onoff_water_temperature")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2020-09-08 06:37:44 +00:00
|
|
|
assert float(state.state) == 70.0
|
|
|
|
|
|
|
|
state = hass.states.get("sensor.cv_pomp_electricity_consumed_interval")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2020-09-08 06:37:44 +00:00
|
|
|
assert float(state.state) == 7.37
|
|
|
|
|
|
|
|
await hass.helpers.entity_component.async_update_entity(
|
|
|
|
"sensor.zone_lisa_wk_battery"
|
|
|
|
)
|
|
|
|
|
|
|
|
state = hass.states.get("sensor.zone_lisa_wk_battery")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2020-11-08 17:09:43 +00:00
|
|
|
assert int(state.state) == 34
|
2020-09-08 06:37:44 +00:00
|
|
|
|
|
|
|
|
2022-02-10 19:41:30 +00:00
|
|
|
async def test_anna_as_smt_climate_sensor_entities(
|
|
|
|
hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry
|
|
|
|
) -> None:
|
2020-09-08 06:37:44 +00:00
|
|
|
"""Test creation of climate related sensor entities."""
|
2022-02-08 18:08:01 +00:00
|
|
|
state = hass.states.get("sensor.opentherm_outdoor_temperature")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2022-02-08 10:13:05 +00:00
|
|
|
assert float(state.state) == 3.0
|
2020-09-08 06:37:44 +00:00
|
|
|
|
2022-02-08 18:08:01 +00:00
|
|
|
state = hass.states.get("sensor.opentherm_water_temperature")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2020-09-08 06:37:44 +00:00
|
|
|
assert float(state.state) == 29.1
|
|
|
|
|
|
|
|
state = hass.states.get("sensor.anna_illuminance")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2020-09-08 06:37:44 +00:00
|
|
|
assert float(state.state) == 86.0
|
|
|
|
|
|
|
|
|
2022-02-10 19:41:30 +00:00
|
|
|
async def test_anna_climate_sensor_entities(
|
|
|
|
hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry
|
|
|
|
) -> None:
|
2022-03-13 18:37:59 +00:00
|
|
|
"""Test creation of climate related sensor entities."""
|
2022-02-08 18:08:01 +00:00
|
|
|
state = hass.states.get("sensor.opentherm_outdoor_temperature")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2022-02-08 10:13:05 +00:00
|
|
|
assert float(state.state) == 3.0
|
2020-11-17 01:54:44 +00:00
|
|
|
|
|
|
|
|
2022-02-10 19:41:30 +00:00
|
|
|
async def test_p1_dsmr_sensor_entities(
|
|
|
|
hass: HomeAssistant, mock_smile_p1: MagicMock, init_integration: MockConfigEntry
|
|
|
|
) -> None:
|
2020-09-08 06:37:44 +00:00
|
|
|
"""Test creation of power related sensor entities."""
|
|
|
|
state = hass.states.get("sensor.p1_net_electricity_point")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2022-02-08 10:13:05 +00:00
|
|
|
assert float(state.state) == -2816.0
|
2020-09-08 06:37:44 +00:00
|
|
|
|
|
|
|
state = hass.states.get("sensor.p1_electricity_consumed_off_peak_cumulative")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2021-01-08 01:44:00 +00:00
|
|
|
assert float(state.state) == 551.09
|
2020-09-08 06:37:44 +00:00
|
|
|
|
|
|
|
state = hass.states.get("sensor.p1_electricity_produced_peak_point")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2022-02-08 10:13:05 +00:00
|
|
|
assert float(state.state) == 2816.0
|
2020-09-08 06:37:44 +00:00
|
|
|
|
|
|
|
state = hass.states.get("sensor.p1_electricity_consumed_peak_cumulative")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2021-01-08 01:44:00 +00:00
|
|
|
assert float(state.state) == 442.932
|
2020-09-08 06:37:44 +00:00
|
|
|
|
|
|
|
state = hass.states.get("sensor.p1_gas_consumed_cumulative")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2020-11-17 01:54:44 +00:00
|
|
|
assert float(state.state) == 584.85
|
2020-11-08 17:09:43 +00:00
|
|
|
|
|
|
|
|
2022-02-10 19:41:30 +00:00
|
|
|
async def test_stretch_sensor_entities(
|
|
|
|
hass: HomeAssistant, mock_stretch: MagicMock, init_integration: MockConfigEntry
|
|
|
|
) -> None:
|
2020-11-08 17:09:43 +00:00
|
|
|
"""Test creation of power related sensor entities."""
|
|
|
|
state = hass.states.get("sensor.koelkast_92c4a_electricity_consumed")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2021-01-08 01:44:00 +00:00
|
|
|
assert float(state.state) == 50.5
|
2020-11-08 17:09:43 +00:00
|
|
|
|
|
|
|
state = hass.states.get("sensor.droger_52559_electricity_consumed_interval")
|
2022-02-10 19:41:30 +00:00
|
|
|
assert state
|
2021-01-08 01:44:00 +00:00
|
|
|
assert float(state.state) == 0.0
|