Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
bramstroker committed Jun 24, 2023
1 parent 1bf8a12 commit cd1bcc6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Expand Up @@ -3,7 +3,6 @@
"measure_method": "manual",
"measure_device": "NOUS A1Z",
"name": "FRITZ!Repeater 1200 AX",
"standby_power": 0,
"sensor_config": {
"power_sensor_naming": "{} Device Power",
"energy_sensor_naming": "{} Device Energy"
Expand Down
42 changes: 42 additions & 0 deletions tests/power_profile/device_types/test_network.py
@@ -0,0 +1,42 @@
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant

from tests.common import run_powercalc_setup
from tests.conftest import MockEntityWithModel


async def test_network_device(
hass: HomeAssistant,
mock_entity_with_model_information: MockEntityWithModel,
) -> None:
"""
Test that smart plug can be setup from profile library
"""
binary_sensor_id = "binary_sensor.wifi_repeater"
manufacturer = "AVM"
model = "FRITZ!Repeater 1200 AX"

mock_entity_with_model_information(
entity_id=binary_sensor_id,
manufacturer=manufacturer,
model=model,
)

power_sensor_id = "sensor.wifi_repeater_device_power"

await run_powercalc_setup(hass, {})

power_state = hass.states.get(power_sensor_id)
assert power_state
assert power_state.state == "unavailable"

hass.states.async_set(binary_sensor_id, STATE_ON)
await hass.async_block_till_done()

assert hass.states.get(power_sensor_id).state == "3.00"

hass.states.async_set(binary_sensor_id, STATE_OFF)
await hass.async_block_till_done()

assert hass.states.get(power_sensor_id).state == "0.00"

0 comments on commit cd1bcc6

Please sign in to comment.