Add alias to DOMAIN import in tests [a-d] (#125573)
parent
fe2402b611
commit
aab939cf6c
|
@ -10,7 +10,7 @@ from homeassistant.components.accuweather.const import (
|
|||
UPDATE_INTERVAL_DAILY_FORECAST,
|
||||
UPDATE_INTERVAL_OBSERVATION,
|
||||
)
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_PLATFORM
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -107,7 +107,7 @@ async def test_remove_ozone_sensors(
|
|||
) -> None:
|
||||
"""Test remove ozone sensors from registry."""
|
||||
entity_registry.async_get_or_create(
|
||||
SENSOR_PLATFORM,
|
||||
SENSOR_DOMAIN,
|
||||
DOMAIN,
|
||||
"0123456-ozone-0",
|
||||
suggested_object_id="home_ozone_0d",
|
||||
|
|
|
@ -18,7 +18,7 @@ from homeassistant.components.device_tracker import (
|
|||
CONF_CONSIDER_HOME,
|
||||
CONF_SCAN_INTERVAL,
|
||||
CONF_TRACK_NEW,
|
||||
DOMAIN,
|
||||
DOMAIN as DEVICE_TRACKER_DOMAIN,
|
||||
)
|
||||
from homeassistant.const import CONF_PLATFORM
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -73,7 +73,7 @@ async def test_do_not_see_device_if_time_not_updated(hass: HomeAssistant) -> Non
|
|||
|
||||
address = "DE:AD:BE:EF:13:37"
|
||||
name = "Mock device name"
|
||||
entity_id = f"{DOMAIN}.{slugify(name)}"
|
||||
entity_id = f"{DEVICE_TRACKER_DOMAIN}.{slugify(name)}"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.async_discovered_service_info"
|
||||
|
@ -101,7 +101,9 @@ async def test_do_not_see_device_if_time_not_updated(hass: HomeAssistant) -> Non
|
|||
CONF_TRACK_NEW: True,
|
||||
CONF_CONSIDER_HOME: timedelta(minutes=10),
|
||||
}
|
||||
result = await async_setup_component(hass, DOMAIN, {DOMAIN: config})
|
||||
result = await async_setup_component(
|
||||
hass, DEVICE_TRACKER_DOMAIN, {DEVICE_TRACKER_DOMAIN: config}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result
|
||||
|
||||
|
@ -136,7 +138,7 @@ async def test_see_device_if_time_updated(hass: HomeAssistant) -> None:
|
|||
|
||||
address = "DE:AD:BE:EF:13:37"
|
||||
name = "Mock device name"
|
||||
entity_id = f"{DOMAIN}.{slugify(name)}"
|
||||
entity_id = f"{DEVICE_TRACKER_DOMAIN}.{slugify(name)}"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.async_discovered_service_info"
|
||||
|
@ -164,7 +166,9 @@ async def test_see_device_if_time_updated(hass: HomeAssistant) -> None:
|
|||
CONF_TRACK_NEW: True,
|
||||
CONF_CONSIDER_HOME: timedelta(minutes=10),
|
||||
}
|
||||
result = await async_setup_component(hass, DOMAIN, {DOMAIN: config})
|
||||
result = await async_setup_component(
|
||||
hass, DEVICE_TRACKER_DOMAIN, {DEVICE_TRACKER_DOMAIN: config}
|
||||
)
|
||||
assert result
|
||||
|
||||
# Tick until device seen enough times for to be registered for tracking
|
||||
|
@ -215,7 +219,7 @@ async def test_preserve_new_tracked_device_name(hass: HomeAssistant) -> None:
|
|||
|
||||
address = "DE:AD:BE:EF:13:37"
|
||||
name = "Mock device name"
|
||||
entity_id = f"{DOMAIN}.{slugify(name)}"
|
||||
entity_id = f"{DEVICE_TRACKER_DOMAIN}.{slugify(name)}"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.async_discovered_service_info"
|
||||
|
@ -242,7 +246,9 @@ async def test_preserve_new_tracked_device_name(hass: HomeAssistant) -> None:
|
|||
CONF_SCAN_INTERVAL: timedelta(minutes=1),
|
||||
CONF_TRACK_NEW: True,
|
||||
}
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: config})
|
||||
assert await async_setup_component(
|
||||
hass, DEVICE_TRACKER_DOMAIN, {DEVICE_TRACKER_DOMAIN: config}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Seen once here; return without name when seen subsequent times
|
||||
|
@ -282,7 +288,7 @@ async def test_tracking_battery_times_out(hass: HomeAssistant) -> None:
|
|||
|
||||
address = "DE:AD:BE:EF:13:37"
|
||||
name = "Mock device name"
|
||||
entity_id = f"{DOMAIN}.{slugify(name)}"
|
||||
entity_id = f"{DEVICE_TRACKER_DOMAIN}.{slugify(name)}"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.async_discovered_service_info"
|
||||
|
@ -311,7 +317,9 @@ async def test_tracking_battery_times_out(hass: HomeAssistant) -> None:
|
|||
CONF_TRACK_BATTERY_INTERVAL: timedelta(minutes=2),
|
||||
CONF_TRACK_NEW: True,
|
||||
}
|
||||
result = await async_setup_component(hass, DOMAIN, {DOMAIN: config})
|
||||
result = await async_setup_component(
|
||||
hass, DEVICE_TRACKER_DOMAIN, {DEVICE_TRACKER_DOMAIN: config}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result
|
||||
|
||||
|
@ -348,7 +356,7 @@ async def test_tracking_battery_fails(hass: HomeAssistant) -> None:
|
|||
|
||||
address = "DE:AD:BE:EF:13:37"
|
||||
name = "Mock device name"
|
||||
entity_id = f"{DOMAIN}.{slugify(name)}"
|
||||
entity_id = f"{DEVICE_TRACKER_DOMAIN}.{slugify(name)}"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.async_discovered_service_info"
|
||||
|
@ -377,7 +385,9 @@ async def test_tracking_battery_fails(hass: HomeAssistant) -> None:
|
|||
CONF_TRACK_BATTERY_INTERVAL: timedelta(minutes=2),
|
||||
CONF_TRACK_NEW: True,
|
||||
}
|
||||
result = await async_setup_component(hass, DOMAIN, {DOMAIN: config})
|
||||
result = await async_setup_component(
|
||||
hass, DEVICE_TRACKER_DOMAIN, {DEVICE_TRACKER_DOMAIN: config}
|
||||
)
|
||||
assert result
|
||||
|
||||
# Tick until device seen enough times for to be registered for tracking
|
||||
|
@ -413,7 +423,7 @@ async def test_tracking_battery_successful(hass: HomeAssistant) -> None:
|
|||
|
||||
address = "DE:AD:BE:EF:13:37"
|
||||
name = "Mock device name"
|
||||
entity_id = f"{DOMAIN}.{slugify(name)}"
|
||||
entity_id = f"{DEVICE_TRACKER_DOMAIN}.{slugify(name)}"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.async_discovered_service_info"
|
||||
|
@ -442,7 +452,9 @@ async def test_tracking_battery_successful(hass: HomeAssistant) -> None:
|
|||
CONF_TRACK_BATTERY_INTERVAL: timedelta(minutes=2),
|
||||
CONF_TRACK_NEW: True,
|
||||
}
|
||||
result = await async_setup_component(hass, DOMAIN, {DOMAIN: config})
|
||||
result = await async_setup_component(
|
||||
hass, DEVICE_TRACKER_DOMAIN, {DEVICE_TRACKER_DOMAIN: config}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import MagicMock, patch
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.sensor import DOMAIN
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
@ -14,7 +14,7 @@ from tests.common import assert_setup_component
|
|||
COMPONENT = "comfoconnect"
|
||||
VALID_CONFIG = {
|
||||
COMPONENT: {"host": "1.2.3.4"},
|
||||
DOMAIN: {
|
||||
SENSOR_DOMAIN: {
|
||||
"platform": COMPONENT,
|
||||
"resources": [
|
||||
"current_humidity",
|
||||
|
@ -51,8 +51,8 @@ async def setup_sensor(
|
|||
mock_comfoconnect_command: MagicMock,
|
||||
) -> None:
|
||||
"""Set up demo sensor component."""
|
||||
with assert_setup_component(1, DOMAIN):
|
||||
await async_setup_component(hass, DOMAIN, VALID_CONFIG)
|
||||
with assert_setup_component(1, SENSOR_DOMAIN):
|
||||
await async_setup_component(hass, SENSOR_DOMAIN, VALID_CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
|||
from freezegun.api import FrozenDateTimeFactory
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.button import DOMAIN, SERVICE_PRESS
|
||||
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -27,7 +27,9 @@ async def button_only() -> None:
|
|||
@pytest.fixture(autouse=True)
|
||||
async def setup_demo_button(hass: HomeAssistant, button_only) -> None:
|
||||
"""Initialize setup demo button entity."""
|
||||
assert await async_setup_component(hass, DOMAIN, {"button": {"platform": "demo"}})
|
||||
assert await async_setup_component(
|
||||
hass, BUTTON_DOMAIN, {"button": {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
|
@ -47,7 +49,7 @@ async def test_press(hass: HomeAssistant, freezer: FrozenDateTimeFactory) -> Non
|
|||
now = dt_util.parse_datetime("2021-01-09 12:00:00+00:00")
|
||||
freezer.move_to(now)
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
BUTTON_DOMAIN,
|
||||
SERVICE_PRESS,
|
||||
{ATTR_ENTITY_ID: ENTITY_PUSH},
|
||||
blocking=True,
|
||||
|
|
|
@ -22,7 +22,7 @@ from homeassistant.components.climate import (
|
|||
ATTR_SWING_MODE,
|
||||
ATTR_TARGET_TEMP_HIGH,
|
||||
ATTR_TARGET_TEMP_LOW,
|
||||
DOMAIN,
|
||||
DOMAIN as CLIMATE_DOMAIN,
|
||||
PRESET_AWAY,
|
||||
PRESET_ECO,
|
||||
SERVICE_SET_FAN_MODE,
|
||||
|
@ -64,7 +64,9 @@ def climate_only() -> Generator[None]:
|
|||
async def setup_demo_climate(hass: HomeAssistant, climate_only: None) -> None:
|
||||
"""Initialize setup demo climate."""
|
||||
hass.config.units = METRIC_SYSTEM
|
||||
assert await async_setup_component(hass, DOMAIN, {"climate": {"platform": "demo"}})
|
||||
assert await async_setup_component(
|
||||
hass, CLIMATE_DOMAIN, {"climate": {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
|
@ -104,7 +106,7 @@ async def test_set_only_target_temp_bad_attr(hass: HomeAssistant) -> None:
|
|||
|
||||
with pytest.raises(vol.Invalid):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_TEMPERATURE: None},
|
||||
blocking=True,
|
||||
|
@ -120,7 +122,7 @@ async def test_set_only_target_temp(hass: HomeAssistant) -> None:
|
|||
assert state.attributes.get(ATTR_TEMPERATURE) == 21
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_TEMPERATURE: 30},
|
||||
blocking=True,
|
||||
|
@ -136,7 +138,7 @@ async def test_set_only_target_temp_with_convert(hass: HomeAssistant) -> None:
|
|||
assert state.attributes.get(ATTR_TEMPERATURE) == 20
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: ENTITY_HEATPUMP, ATTR_TEMPERATURE: 21},
|
||||
blocking=True,
|
||||
|
@ -154,7 +156,7 @@ async def test_set_target_temp_range(hass: HomeAssistant) -> None:
|
|||
assert state.attributes.get(ATTR_TARGET_TEMP_HIGH) == 24.0
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: ENTITY_ECOBEE,
|
||||
|
@ -179,7 +181,7 @@ async def test_set_target_temp_range_bad_attr(hass: HomeAssistant) -> None:
|
|||
|
||||
with pytest.raises(vol.Invalid):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: ENTITY_ECOBEE,
|
||||
|
@ -202,7 +204,7 @@ async def test_set_temp_with_hvac_mode(hass: HomeAssistant) -> None:
|
|||
assert state.state == HVACMode.COOL
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: ENTITY_CLIMATE,
|
||||
|
@ -224,7 +226,7 @@ async def test_set_target_humidity_bad_attr(hass: HomeAssistant) -> None:
|
|||
|
||||
with pytest.raises(vol.Invalid):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_HUMIDITY: None},
|
||||
blocking=True,
|
||||
|
@ -240,7 +242,7 @@ async def test_set_target_humidity(hass: HomeAssistant) -> None:
|
|||
assert state.attributes.get(ATTR_HUMIDITY) == 67.4
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_HUMIDITY: 64},
|
||||
blocking=True,
|
||||
|
@ -257,7 +259,7 @@ async def test_set_fan_mode_bad_attr(hass: HomeAssistant) -> None:
|
|||
|
||||
with pytest.raises(vol.Invalid):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_FAN_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_FAN_MODE: None},
|
||||
blocking=True,
|
||||
|
@ -273,7 +275,7 @@ async def test_set_fan_mode(hass: HomeAssistant) -> None:
|
|||
assert state.attributes.get(ATTR_FAN_MODE) == "on_high"
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_FAN_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_FAN_MODE: "on_low"},
|
||||
blocking=True,
|
||||
|
@ -290,7 +292,7 @@ async def test_set_swing_mode_bad_attr(hass: HomeAssistant) -> None:
|
|||
|
||||
with pytest.raises(vol.Invalid):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_SWING_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_SWING_MODE: None},
|
||||
blocking=True,
|
||||
|
@ -306,7 +308,7 @@ async def test_set_swing(hass: HomeAssistant) -> None:
|
|||
assert state.attributes.get(ATTR_SWING_MODE) == "off"
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_SWING_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_SWING_MODE: "auto"},
|
||||
blocking=True,
|
||||
|
@ -327,7 +329,7 @@ async def test_set_hvac_bad_attr_and_state(hass: HomeAssistant) -> None:
|
|||
|
||||
with pytest.raises(vol.Invalid):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_HVAC_MODE: None},
|
||||
blocking=True,
|
||||
|
@ -344,7 +346,7 @@ async def test_set_hvac(hass: HomeAssistant) -> None:
|
|||
assert state.state == HVACMode.COOL
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_HVAC_MODE: HVACMode.HEAT},
|
||||
blocking=True,
|
||||
|
@ -357,7 +359,7 @@ async def test_set_hvac(hass: HomeAssistant) -> None:
|
|||
async def test_set_hold_mode_away(hass: HomeAssistant) -> None:
|
||||
"""Test setting the hold mode away."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ECOBEE, ATTR_PRESET_MODE: PRESET_AWAY},
|
||||
blocking=True,
|
||||
|
@ -370,7 +372,7 @@ async def test_set_hold_mode_away(hass: HomeAssistant) -> None:
|
|||
async def test_set_hold_mode_eco(hass: HomeAssistant) -> None:
|
||||
"""Test setting the hold mode eco."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ECOBEE, ATTR_PRESET_MODE: PRESET_ECO},
|
||||
blocking=True,
|
||||
|
@ -383,7 +385,7 @@ async def test_set_hold_mode_eco(hass: HomeAssistant) -> None:
|
|||
async def test_turn_on(hass: HomeAssistant) -> None:
|
||||
"""Test turn on device."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_HVAC_MODE: HVACMode.OFF},
|
||||
blocking=True,
|
||||
|
@ -393,7 +395,7 @@ async def test_turn_on(hass: HomeAssistant) -> None:
|
|||
assert state.state == HVACMode.OFF
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_CLIMATE}, blocking=True
|
||||
CLIMATE_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_CLIMATE}, blocking=True
|
||||
)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.state == HVACMode.HEAT
|
||||
|
@ -402,7 +404,7 @@ async def test_turn_on(hass: HomeAssistant) -> None:
|
|||
async def test_turn_off(hass: HomeAssistant) -> None:
|
||||
"""Test turn on device."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_CLIMATE, ATTR_HVAC_MODE: HVACMode.HEAT},
|
||||
blocking=True,
|
||||
|
@ -412,7 +414,10 @@ async def test_turn_off(hass: HomeAssistant) -> None:
|
|||
assert state.state == HVACMode.HEAT
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_CLIMATE}, blocking=True
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY_CLIMATE},
|
||||
blocking=True,
|
||||
)
|
||||
state = hass.states.get(ENTITY_CLIMATE)
|
||||
assert state.state == HVACMode.OFF
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.cover import (
|
|||
ATTR_CURRENT_TILT_POSITION,
|
||||
ATTR_POSITION,
|
||||
ATTR_TILT_POSITION,
|
||||
DOMAIN,
|
||||
DOMAIN as COVER_DOMAIN,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
|
@ -55,8 +55,8 @@ def cover_only() -> Generator[None]:
|
|||
@pytest.fixture(autouse=True)
|
||||
async def setup_comp(hass: HomeAssistant, cover_only: None) -> None:
|
||||
"""Set up demo cover component."""
|
||||
with assert_setup_component(1, DOMAIN):
|
||||
await async_setup_component(hass, DOMAIN, CONFIG)
|
||||
with assert_setup_component(1, COVER_DOMAIN):
|
||||
await async_setup_component(hass, COVER_DOMAIN, CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
|
@ -79,7 +79,7 @@ async def test_close_cover(hass: HomeAssistant) -> None:
|
|||
assert state.attributes[ATTR_CURRENT_POSITION] == 70
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
)
|
||||
state = hass.states.get(ENTITY_COVER)
|
||||
assert state.state == STATE_CLOSING
|
||||
|
@ -99,7 +99,7 @@ async def test_open_cover(hass: HomeAssistant) -> None:
|
|||
assert state.state == STATE_OPEN
|
||||
assert state.attributes[ATTR_CURRENT_POSITION] == 70
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
)
|
||||
state = hass.states.get(ENTITY_COVER)
|
||||
assert state.state == STATE_OPENING
|
||||
|
@ -117,7 +117,7 @@ async def test_toggle_cover(hass: HomeAssistant) -> None:
|
|||
"""Test toggling the cover."""
|
||||
# Start open
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
)
|
||||
for _ in range(7):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -129,7 +129,7 @@ async def test_toggle_cover(hass: HomeAssistant) -> None:
|
|||
assert state.attributes["current_position"] == 100
|
||||
# Toggle closed
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
)
|
||||
for _ in range(10):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -141,7 +141,7 @@ async def test_toggle_cover(hass: HomeAssistant) -> None:
|
|||
assert state.attributes[ATTR_CURRENT_POSITION] == 0
|
||||
# Toggle open
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
)
|
||||
for _ in range(10):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -158,7 +158,7 @@ async def test_set_cover_position(hass: HomeAssistant) -> None:
|
|||
state = hass.states.get(ENTITY_COVER)
|
||||
assert state.attributes[ATTR_CURRENT_POSITION] == 70
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
COVER_DOMAIN,
|
||||
SERVICE_SET_COVER_POSITION,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER, ATTR_POSITION: 10},
|
||||
blocking=True,
|
||||
|
@ -177,13 +177,13 @@ async def test_stop_cover(hass: HomeAssistant) -> None:
|
|||
state = hass.states.get(ENTITY_COVER)
|
||||
assert state.attributes[ATTR_CURRENT_POSITION] == 70
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
)
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
async_fire_time_changed(hass, future)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_STOP_COVER, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_STOP_COVER, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
)
|
||||
async_fire_time_changed(hass, future)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -196,7 +196,10 @@ async def test_close_cover_tilt(hass: HomeAssistant) -> None:
|
|||
state = hass.states.get(ENTITY_COVER)
|
||||
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 50
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_CLOSE_COVER_TILT, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
COVER_DOMAIN,
|
||||
SERVICE_CLOSE_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER},
|
||||
blocking=True,
|
||||
)
|
||||
for _ in range(7):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -212,7 +215,10 @@ async def test_open_cover_tilt(hass: HomeAssistant) -> None:
|
|||
state = hass.states.get(ENTITY_COVER)
|
||||
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 50
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER_TILT, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
COVER_DOMAIN,
|
||||
SERVICE_OPEN_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER},
|
||||
blocking=True,
|
||||
)
|
||||
for _ in range(7):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -227,7 +233,10 @@ async def test_toggle_cover_tilt(hass: HomeAssistant) -> None:
|
|||
"""Test toggling the cover tilt."""
|
||||
# Start open
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER_TILT, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
COVER_DOMAIN,
|
||||
SERVICE_OPEN_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER},
|
||||
blocking=True,
|
||||
)
|
||||
for _ in range(7):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -238,7 +247,10 @@ async def test_toggle_cover_tilt(hass: HomeAssistant) -> None:
|
|||
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 100
|
||||
# Toggle closed
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE_COVER_TILT, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
COVER_DOMAIN,
|
||||
SERVICE_TOGGLE_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER},
|
||||
blocking=True,
|
||||
)
|
||||
for _ in range(10):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -249,7 +261,10 @@ async def test_toggle_cover_tilt(hass: HomeAssistant) -> None:
|
|||
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 0
|
||||
# Toggle Open
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE_COVER_TILT, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
COVER_DOMAIN,
|
||||
SERVICE_TOGGLE_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER},
|
||||
blocking=True,
|
||||
)
|
||||
for _ in range(10):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -265,7 +280,7 @@ async def test_set_cover_tilt_position(hass: HomeAssistant) -> None:
|
|||
state = hass.states.get(ENTITY_COVER)
|
||||
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 50
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
COVER_DOMAIN,
|
||||
SERVICE_SET_COVER_TILT_POSITION,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER, ATTR_TILT_POSITION: 90},
|
||||
blocking=True,
|
||||
|
@ -284,13 +299,19 @@ async def test_stop_cover_tilt(hass: HomeAssistant) -> None:
|
|||
state = hass.states.get(ENTITY_COVER)
|
||||
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 50
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_CLOSE_COVER_TILT, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
COVER_DOMAIN,
|
||||
SERVICE_CLOSE_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER},
|
||||
blocking=True,
|
||||
)
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
async_fire_time_changed(hass, future)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_STOP_COVER_TILT, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
|
||||
COVER_DOMAIN,
|
||||
SERVICE_STOP_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, future)
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -4,7 +4,11 @@ from unittest.mock import patch
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.date import ATTR_DATE, DOMAIN, SERVICE_SET_VALUE
|
||||
from homeassistant.components.date import (
|
||||
ATTR_DATE,
|
||||
DOMAIN as DATE_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -25,7 +29,9 @@ async def date_only() -> None:
|
|||
@pytest.fixture(autouse=True)
|
||||
async def setup_demo_date(hass: HomeAssistant, date_only) -> None:
|
||||
"""Initialize setup demo date."""
|
||||
assert await async_setup_component(hass, DOMAIN, {"date": {"platform": "demo"}})
|
||||
assert await async_setup_component(
|
||||
hass, DATE_DOMAIN, {"date": {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
|
@ -38,7 +44,7 @@ def test_setup_params(hass: HomeAssistant) -> None:
|
|||
async def test_set_datetime(hass: HomeAssistant) -> None:
|
||||
"""Test set datetime service."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
DATE_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
{ATTR_ENTITY_ID: ENTITY_DATE, ATTR_DATE: "2021-02-03"},
|
||||
blocking=True,
|
||||
|
|
|
@ -4,7 +4,11 @@ from unittest.mock import patch
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.datetime import ATTR_DATETIME, DOMAIN, SERVICE_SET_VALUE
|
||||
from homeassistant.components.datetime import (
|
||||
ATTR_DATETIME,
|
||||
DOMAIN as DATETIME_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -25,7 +29,9 @@ async def datetime_only() -> None:
|
|||
@pytest.fixture(autouse=True)
|
||||
async def setup_demo_datetime(hass: HomeAssistant, datetime_only) -> None:
|
||||
"""Initialize setup demo datetime."""
|
||||
assert await async_setup_component(hass, DOMAIN, {"datetime": {"platform": "demo"}})
|
||||
assert await async_setup_component(
|
||||
hass, DATETIME_DOMAIN, {"datetime": {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
|
@ -39,7 +45,7 @@ async def test_set_datetime(hass: HomeAssistant) -> None:
|
|||
"""Test set datetime service."""
|
||||
await hass.config.async_set_time_zone("UTC")
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
DATETIME_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
{ATTR_ENTITY_ID: ENTITY_DATETIME, ATTR_DATETIME: "2021-02-03 01:02:03"},
|
||||
blocking=True,
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.humidifier import (
|
|||
ATTR_HUMIDITY,
|
||||
ATTR_MAX_HUMIDITY,
|
||||
ATTR_MIN_HUMIDITY,
|
||||
DOMAIN,
|
||||
DOMAIN as HUMIDITY_DOMAIN,
|
||||
MODE_AWAY,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
SERVICE_SET_MODE,
|
||||
|
@ -48,7 +48,7 @@ async def humidifier_only() -> None:
|
|||
async def setup_demo_humidifier(hass: HomeAssistant, humidifier_only: None):
|
||||
"""Initialize setup demo humidifier."""
|
||||
assert await async_setup_component(
|
||||
hass, DOMAIN, {"humidifier": {"platform": "demo"}}
|
||||
hass, HUMIDITY_DOMAIN, {"humidifier": {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -76,7 +76,7 @@ async def test_set_target_humidity_bad_attr(hass: HomeAssistant) -> None:
|
|||
|
||||
with pytest.raises(vol.Invalid):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDITY_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_HUMIDITY: None, ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER},
|
||||
blocking=True,
|
||||
|
@ -93,7 +93,7 @@ async def test_set_target_humidity(hass: HomeAssistant) -> None:
|
|||
assert state.attributes.get(ATTR_HUMIDITY) == 54.2
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDITY_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_HUMIDITY: 64, ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER},
|
||||
blocking=True,
|
||||
|
@ -107,7 +107,7 @@ async def test_set_target_humidity(hass: HomeAssistant) -> None:
|
|||
async def test_set_hold_mode_away(hass: HomeAssistant) -> None:
|
||||
"""Test setting the hold mode away."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDITY_DOMAIN,
|
||||
SERVICE_SET_MODE,
|
||||
{ATTR_MODE: MODE_AWAY, ATTR_ENTITY_ID: ENTITY_HYGROSTAT},
|
||||
blocking=True,
|
||||
|
@ -121,7 +121,7 @@ async def test_set_hold_mode_away(hass: HomeAssistant) -> None:
|
|||
async def test_set_hold_mode_eco(hass: HomeAssistant) -> None:
|
||||
"""Test setting the hold mode eco."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDITY_DOMAIN,
|
||||
SERVICE_SET_MODE,
|
||||
{ATTR_MODE: "eco", ATTR_ENTITY_ID: ENTITY_HYGROSTAT},
|
||||
blocking=True,
|
||||
|
@ -135,14 +135,20 @@ async def test_set_hold_mode_eco(hass: HomeAssistant) -> None:
|
|||
async def test_turn_on(hass: HomeAssistant) -> None:
|
||||
"""Test turn on device."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER}, blocking=True
|
||||
HUMIDITY_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER},
|
||||
blocking=True,
|
||||
)
|
||||
state = hass.states.get(ENTITY_DEHUMIDIFIER)
|
||||
assert state.state == STATE_OFF
|
||||
assert state.attributes.get(ATTR_ACTION) == "off"
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER}, blocking=True
|
||||
HUMIDITY_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER},
|
||||
blocking=True,
|
||||
)
|
||||
state = hass.states.get(ENTITY_DEHUMIDIFIER)
|
||||
assert state.state == STATE_ON
|
||||
|
@ -152,14 +158,20 @@ async def test_turn_on(hass: HomeAssistant) -> None:
|
|||
async def test_turn_off(hass: HomeAssistant) -> None:
|
||||
"""Test turn off device."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER}, blocking=True
|
||||
HUMIDITY_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER},
|
||||
blocking=True,
|
||||
)
|
||||
state = hass.states.get(ENTITY_DEHUMIDIFIER)
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get(ATTR_ACTION) == "drying"
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER}, blocking=True
|
||||
HUMIDITY_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER},
|
||||
blocking=True,
|
||||
)
|
||||
state = hass.states.get(ENTITY_DEHUMIDIFIER)
|
||||
assert state.state == STATE_OFF
|
||||
|
@ -169,19 +181,28 @@ async def test_turn_off(hass: HomeAssistant) -> None:
|
|||
async def test_toggle(hass: HomeAssistant) -> None:
|
||||
"""Test toggle device."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER}, blocking=True
|
||||
HUMIDITY_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER},
|
||||
blocking=True,
|
||||
)
|
||||
state = hass.states.get(ENTITY_DEHUMIDIFIER)
|
||||
assert state.state == STATE_ON
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER}, blocking=True
|
||||
HUMIDITY_DOMAIN,
|
||||
SERVICE_TOGGLE,
|
||||
{ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER},
|
||||
blocking=True,
|
||||
)
|
||||
state = hass.states.get(ENTITY_DEHUMIDIFIER)
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER}, blocking=True
|
||||
HUMIDITY_DOMAIN,
|
||||
SERVICE_TOGGLE,
|
||||
{ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER},
|
||||
blocking=True,
|
||||
)
|
||||
state = hass.states.get(ENTITY_DEHUMIDIFIER)
|
||||
assert state.state == STATE_ON
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.number import (
|
|||
ATTR_MIN,
|
||||
ATTR_STEP,
|
||||
ATTR_VALUE,
|
||||
DOMAIN,
|
||||
DOMAIN as NUMBER_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
NumberMode,
|
||||
)
|
||||
|
@ -39,7 +39,9 @@ def number_only() -> Generator[None]:
|
|||
@pytest.fixture(autouse=True)
|
||||
async def setup_demo_number(hass: HomeAssistant, number_only: None) -> None:
|
||||
"""Initialize setup demo Number entity."""
|
||||
assert await async_setup_component(hass, DOMAIN, {"number": {"platform": "demo"}})
|
||||
assert await async_setup_component(
|
||||
hass, NUMBER_DOMAIN, {"number": {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
|
@ -83,7 +85,7 @@ async def test_set_value_bad_attr(hass: HomeAssistant) -> None:
|
|||
|
||||
with pytest.raises(vol.Invalid):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
NUMBER_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
{ATTR_VALUE: None, ATTR_ENTITY_ID: ENTITY_VOLUME},
|
||||
blocking=True,
|
||||
|
@ -101,7 +103,7 @@ async def test_set_value_bad_range(hass: HomeAssistant) -> None:
|
|||
|
||||
with pytest.raises(ServiceValidationError):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
NUMBER_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
{ATTR_VALUE: 1024, ATTR_ENTITY_ID: ENTITY_VOLUME},
|
||||
blocking=True,
|
||||
|
@ -118,7 +120,7 @@ async def test_set_set_value(hass: HomeAssistant) -> None:
|
|||
assert state.state == "42.0"
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
NUMBER_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
{ATTR_VALUE: 23, ATTR_ENTITY_ID: ENTITY_VOLUME},
|
||||
blocking=True,
|
||||
|
|
|
@ -7,7 +7,7 @@ import pytest
|
|||
from homeassistant.components.select import (
|
||||
ATTR_OPTION,
|
||||
ATTR_OPTIONS,
|
||||
DOMAIN,
|
||||
DOMAIN as SELECT_DOMAIN,
|
||||
SERVICE_SELECT_OPTION,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
|
@ -31,7 +31,9 @@ async def select_only() -> None:
|
|||
@pytest.fixture(autouse=True)
|
||||
async def setup_demo_select(hass: HomeAssistant, select_only) -> None:
|
||||
"""Initialize setup demo select entity."""
|
||||
assert await async_setup_component(hass, DOMAIN, {"select": {"platform": "demo"}})
|
||||
assert await async_setup_component(
|
||||
hass, SELECT_DOMAIN, {"select": {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
|
@ -55,7 +57,7 @@ async def test_select_option_bad_attr(hass: HomeAssistant) -> None:
|
|||
|
||||
with pytest.raises(ServiceValidationError):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SELECT_DOMAIN,
|
||||
SERVICE_SELECT_OPTION,
|
||||
{ATTR_OPTION: "slow_speed", ATTR_ENTITY_ID: ENTITY_SPEED},
|
||||
blocking=True,
|
||||
|
@ -74,7 +76,7 @@ async def test_select_option(hass: HomeAssistant) -> None:
|
|||
assert state.state == "ridiculous_speed"
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SELECT_DOMAIN,
|
||||
SERVICE_SELECT_OPTION,
|
||||
{ATTR_OPTION: "light_speed", ATTR_ENTITY_ID: ENTITY_SPEED},
|
||||
blocking=True,
|
||||
|
|
|
@ -8,7 +8,7 @@ from homeassistant.components.siren import (
|
|||
ATTR_AVAILABLE_TONES,
|
||||
ATTR_TONE,
|
||||
ATTR_VOLUME_LEVEL,
|
||||
DOMAIN,
|
||||
DOMAIN as SIREN_DOMAIN,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
|
@ -39,7 +39,9 @@ async def siren_only() -> None:
|
|||
@pytest.fixture(autouse=True)
|
||||
async def setup_demo_siren(hass: HomeAssistant, siren_only: None):
|
||||
"""Initialize setup demo siren."""
|
||||
assert await async_setup_component(hass, DOMAIN, {"siren": {"platform": "demo"}})
|
||||
assert await async_setup_component(
|
||||
hass, SIREN_DOMAIN, {"siren": {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
|
@ -59,13 +61,13 @@ def test_all_setup_params(hass: HomeAssistant) -> None:
|
|||
async def test_turn_on(hass: HomeAssistant) -> None:
|
||||
"""Test turn on device."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_SIREN}, blocking=True
|
||||
SIREN_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_SIREN}, blocking=True
|
||||
)
|
||||
state = hass.states.get(ENTITY_SIREN)
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_SIREN}, blocking=True
|
||||
SIREN_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_SIREN}, blocking=True
|
||||
)
|
||||
state = hass.states.get(ENTITY_SIREN)
|
||||
assert state.state == STATE_ON
|
||||
|
@ -73,7 +75,7 @@ async def test_turn_on(hass: HomeAssistant) -> None:
|
|||
# Test that an invalid tone will raise a ValueError
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SIREN_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY_SIREN_WITH_ALL_FEATURES, ATTR_TONE: "invalid_tone"},
|
||||
blocking=True,
|
||||
|
@ -83,13 +85,13 @@ async def test_turn_on(hass: HomeAssistant) -> None:
|
|||
async def test_turn_off(hass: HomeAssistant) -> None:
|
||||
"""Test turn off device."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_SIREN}, blocking=True
|
||||
SIREN_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_SIREN}, blocking=True
|
||||
)
|
||||
state = hass.states.get(ENTITY_SIREN)
|
||||
assert state.state == STATE_ON
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_SIREN}, blocking=True
|
||||
SIREN_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_SIREN}, blocking=True
|
||||
)
|
||||
state = hass.states.get(ENTITY_SIREN)
|
||||
assert state.state == STATE_OFF
|
||||
|
@ -98,19 +100,19 @@ async def test_turn_off(hass: HomeAssistant) -> None:
|
|||
async def test_toggle(hass: HomeAssistant) -> None:
|
||||
"""Test toggle device."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_SIREN}, blocking=True
|
||||
SIREN_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_SIREN}, blocking=True
|
||||
)
|
||||
state = hass.states.get(ENTITY_SIREN)
|
||||
assert state.state == STATE_ON
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: ENTITY_SIREN}, blocking=True
|
||||
SIREN_DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: ENTITY_SIREN}, blocking=True
|
||||
)
|
||||
state = hass.states.get(ENTITY_SIREN)
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: ENTITY_SIREN}, blocking=True
|
||||
SIREN_DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: ENTITY_SIREN}, blocking=True
|
||||
)
|
||||
state = hass.states.get(ENTITY_SIREN)
|
||||
assert state.state == STATE_ON
|
||||
|
@ -122,7 +124,7 @@ async def test_turn_on_strip_attributes(hass: HomeAssistant) -> None:
|
|||
"homeassistant.components.demo.siren.DemoSiren.async_turn_on"
|
||||
) as svc_call:
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SIREN_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY_SIREN, ATTR_VOLUME_LEVEL: 1},
|
||||
blocking=True,
|
||||
|
|
|
@ -10,7 +10,7 @@ from homeassistant.components.text import (
|
|||
ATTR_MIN,
|
||||
ATTR_PATTERN,
|
||||
ATTR_VALUE,
|
||||
DOMAIN,
|
||||
DOMAIN as TEXT_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
|
@ -38,7 +38,9 @@ def text_only() -> Generator[None]:
|
|||
@pytest.fixture(autouse=True)
|
||||
async def setup_demo_text(hass: HomeAssistant, text_only: None) -> None:
|
||||
"""Initialize setup demo text."""
|
||||
assert await async_setup_component(hass, DOMAIN, {"text": {"platform": "demo"}})
|
||||
assert await async_setup_component(
|
||||
hass, TEXT_DOMAIN, {"text": {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
|
@ -55,7 +57,7 @@ def test_setup_params(hass: HomeAssistant) -> None:
|
|||
async def test_set_value(hass: HomeAssistant) -> None:
|
||||
"""Test set value service."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
TEXT_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
{ATTR_ENTITY_ID: ENTITY_TEXT, ATTR_VALUE: "new"},
|
||||
blocking=True,
|
||||
|
|
|
@ -4,7 +4,11 @@ from unittest.mock import patch
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.time import ATTR_TIME, DOMAIN, SERVICE_SET_VALUE
|
||||
from homeassistant.components.time import (
|
||||
ATTR_TIME,
|
||||
DOMAIN as TIME_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -25,7 +29,9 @@ async def time_only() -> None:
|
|||
@pytest.fixture(autouse=True)
|
||||
async def setup_demo_datetime(hass: HomeAssistant, time_only) -> None:
|
||||
"""Initialize setup demo time."""
|
||||
assert await async_setup_component(hass, DOMAIN, {"time": {"platform": "demo"}})
|
||||
assert await async_setup_component(
|
||||
hass, TIME_DOMAIN, {"time": {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
|
@ -38,7 +44,7 @@ def test_setup_params(hass: HomeAssistant) -> None:
|
|||
async def test_set_value(hass: HomeAssistant) -> None:
|
||||
"""Test set value service."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
TIME_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
{ATTR_ENTITY_ID: ENTITY_TIME, ATTR_TIME: "01:02:03"},
|
||||
blocking=True,
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.update import (
|
|||
ATTR_RELEASE_SUMMARY,
|
||||
ATTR_RELEASE_URL,
|
||||
ATTR_TITLE,
|
||||
DOMAIN,
|
||||
DOMAIN as UPDATE_DOMAIN,
|
||||
SERVICE_INSTALL,
|
||||
UpdateDeviceClass,
|
||||
)
|
||||
|
@ -41,7 +41,9 @@ async def update_only() -> None:
|
|||
@pytest.fixture(autouse=True)
|
||||
async def setup_demo_update(hass: HomeAssistant, update_only) -> None:
|
||||
"""Initialize setup demo update entity."""
|
||||
assert await async_setup_component(hass, DOMAIN, {"update": {"platform": "demo"}})
|
||||
assert await async_setup_component(
|
||||
hass, UPDATE_DOMAIN, {"update": {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
|
@ -140,7 +142,7 @@ async def test_update_with_progress(hass: HomeAssistant) -> None:
|
|||
|
||||
with patch("homeassistant.components.demo.update.FAKE_INSTALL_SLEEP_TIME", new=0):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
UPDATE_DOMAIN,
|
||||
SERVICE_INSTALL,
|
||||
{ATTR_ENTITY_ID: "update.demo_update_with_progress"},
|
||||
blocking=True,
|
||||
|
@ -184,7 +186,7 @@ async def test_update_with_progress_raising(hass: HomeAssistant) -> None:
|
|||
pytest.raises(RuntimeError),
|
||||
):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
UPDATE_DOMAIN,
|
||||
SERVICE_INSTALL,
|
||||
{ATTR_ENTITY_ID: "update.demo_update_with_progress"},
|
||||
blocking=True,
|
||||
|
|
|
@ -19,7 +19,7 @@ from homeassistant.components.vacuum import (
|
|||
ATTR_FAN_SPEED,
|
||||
ATTR_FAN_SPEED_LIST,
|
||||
ATTR_PARAMS,
|
||||
DOMAIN,
|
||||
DOMAIN as VACUUM_DOMAIN,
|
||||
SERVICE_SEND_COMMAND,
|
||||
SERVICE_SET_FAN_SPEED,
|
||||
STATE_CLEANING,
|
||||
|
@ -42,11 +42,11 @@ from homeassistant.util import dt as dt_util
|
|||
from tests.common import async_fire_time_changed, async_mock_service
|
||||
from tests.components.vacuum import common
|
||||
|
||||
ENTITY_VACUUM_BASIC = f"{DOMAIN}.{DEMO_VACUUM_BASIC}".lower()
|
||||
ENTITY_VACUUM_COMPLETE = f"{DOMAIN}.{DEMO_VACUUM_COMPLETE}".lower()
|
||||
ENTITY_VACUUM_MINIMAL = f"{DOMAIN}.{DEMO_VACUUM_MINIMAL}".lower()
|
||||
ENTITY_VACUUM_MOST = f"{DOMAIN}.{DEMO_VACUUM_MOST}".lower()
|
||||
ENTITY_VACUUM_NONE = f"{DOMAIN}.{DEMO_VACUUM_NONE}".lower()
|
||||
ENTITY_VACUUM_BASIC = f"{VACUUM_DOMAIN}.{DEMO_VACUUM_BASIC}".lower()
|
||||
ENTITY_VACUUM_COMPLETE = f"{VACUUM_DOMAIN}.{DEMO_VACUUM_COMPLETE}".lower()
|
||||
ENTITY_VACUUM_MINIMAL = f"{VACUUM_DOMAIN}.{DEMO_VACUUM_MINIMAL}".lower()
|
||||
ENTITY_VACUUM_MOST = f"{VACUUM_DOMAIN}.{DEMO_VACUUM_MOST}".lower()
|
||||
ENTITY_VACUUM_NONE = f"{VACUUM_DOMAIN}.{DEMO_VACUUM_NONE}".lower()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -62,7 +62,9 @@ async def vacuum_only() -> None:
|
|||
@pytest.fixture(autouse=True)
|
||||
async def setup_demo_vacuum(hass: HomeAssistant, vacuum_only: None):
|
||||
"""Initialize setup demo vacuum."""
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "demo"}})
|
||||
assert await async_setup_component(
|
||||
hass, VACUUM_DOMAIN, {VACUUM_DOMAIN: {CONF_PLATFORM: "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
|
@ -189,7 +191,7 @@ async def test_unsupported_methods(hass: HomeAssistant) -> None:
|
|||
async def test_services(hass: HomeAssistant) -> None:
|
||||
"""Test vacuum services."""
|
||||
# Test send_command
|
||||
send_command_calls = async_mock_service(hass, DOMAIN, SERVICE_SEND_COMMAND)
|
||||
send_command_calls = async_mock_service(hass, VACUUM_DOMAIN, SERVICE_SEND_COMMAND)
|
||||
|
||||
params = {"rotate": 150, "speed": 20}
|
||||
await common.async_send_command(
|
||||
|
@ -198,20 +200,20 @@ async def test_services(hass: HomeAssistant) -> None:
|
|||
assert len(send_command_calls) == 1
|
||||
call = send_command_calls[-1]
|
||||
|
||||
assert call.domain == DOMAIN
|
||||
assert call.domain == VACUUM_DOMAIN
|
||||
assert call.service == SERVICE_SEND_COMMAND
|
||||
assert call.data[ATTR_ENTITY_ID] == ENTITY_VACUUM_BASIC
|
||||
assert call.data[ATTR_COMMAND] == "test_command"
|
||||
assert call.data[ATTR_PARAMS] == params
|
||||
|
||||
# Test set fan speed
|
||||
set_fan_speed_calls = async_mock_service(hass, DOMAIN, SERVICE_SET_FAN_SPEED)
|
||||
set_fan_speed_calls = async_mock_service(hass, VACUUM_DOMAIN, SERVICE_SET_FAN_SPEED)
|
||||
|
||||
await common.async_set_fan_speed(hass, FAN_SPEEDS[0], ENTITY_VACUUM_COMPLETE)
|
||||
assert len(set_fan_speed_calls) == 1
|
||||
call = set_fan_speed_calls[-1]
|
||||
|
||||
assert call.domain == DOMAIN
|
||||
assert call.domain == VACUUM_DOMAIN
|
||||
assert call.service == SERVICE_SET_FAN_SPEED
|
||||
assert call.data[ATTR_ENTITY_ID] == ENTITY_VACUUM_COMPLETE
|
||||
assert call.data[ATTR_FAN_SPEED] == FAN_SPEEDS[0]
|
||||
|
|
|
@ -13,7 +13,7 @@ from homeassistant.components import (
|
|||
group,
|
||||
light,
|
||||
)
|
||||
from homeassistant.components.device_tracker import DOMAIN
|
||||
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
CONF_PLATFORM,
|
||||
|
@ -150,21 +150,21 @@ async def test_lights_turn_on_when_coming_home_after_sun_set(
|
|||
hass, device_sun_light_trigger.DOMAIN, {device_sun_light_trigger.DOMAIN: {}}
|
||||
)
|
||||
|
||||
hass.states.async_set(f"{DOMAIN}.device_2", STATE_UNKNOWN)
|
||||
hass.states.async_set(f"{DEVICE_TRACKER_DOMAIN}.device_2", STATE_UNKNOWN)
|
||||
await hass.async_block_till_done()
|
||||
assert all(
|
||||
hass.states.get(ent_id).state == STATE_OFF
|
||||
for ent_id in hass.states.async_entity_ids("light")
|
||||
)
|
||||
|
||||
hass.states.async_set(f"{DOMAIN}.device_2", STATE_NOT_HOME)
|
||||
hass.states.async_set(f"{DEVICE_TRACKER_DOMAIN}.device_2", STATE_NOT_HOME)
|
||||
await hass.async_block_till_done()
|
||||
assert all(
|
||||
hass.states.get(ent_id).state == STATE_OFF
|
||||
for ent_id in hass.states.async_entity_ids("light")
|
||||
)
|
||||
|
||||
hass.states.async_set(f"{DOMAIN}.device_2", STATE_HOME)
|
||||
hass.states.async_set(f"{DEVICE_TRACKER_DOMAIN}.device_2", STATE_HOME)
|
||||
await hass.async_block_till_done()
|
||||
assert all(
|
||||
hass.states.get(ent_id).state == light.STATE_ON
|
||||
|
@ -177,8 +177,8 @@ async def test_lights_turn_on_when_coming_home_after_sun_set_person(
|
|||
hass: HomeAssistant, freezer: FrozenDateTimeFactory
|
||||
) -> None:
|
||||
"""Test lights turn on when coming home after sun set."""
|
||||
device_1 = f"{DOMAIN}.device_1"
|
||||
device_2 = f"{DOMAIN}.device_2"
|
||||
device_1 = f"{DEVICE_TRACKER_DOMAIN}.device_1"
|
||||
device_2 = f"{DEVICE_TRACKER_DOMAIN}.device_2"
|
||||
|
||||
test_time = datetime(2017, 4, 5, 3, 2, 3, tzinfo=dt_util.UTC)
|
||||
freezer.move_to(test_time)
|
||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
|||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.binary_sensor import DOMAIN
|
||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
@ -34,24 +34,28 @@ async def test_binary_sensor(
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test_door")
|
||||
state = hass.states.get(f"{BINARY_SENSOR_DOMAIN}.test_door")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test_door") == snapshot
|
||||
assert entity_registry.async_get(f"{BINARY_SENSOR_DOMAIN}.test_door") == snapshot
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test_overload")
|
||||
state = hass.states.get(f"{BINARY_SENSOR_DOMAIN}.test_overload")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test_overload") == snapshot
|
||||
assert (
|
||||
entity_registry.async_get(f"{BINARY_SENSOR_DOMAIN}.test_overload") == snapshot
|
||||
)
|
||||
|
||||
# Emulate websocket message: sensor turned on
|
||||
test_gateway.publisher.dispatch("Test", ("Test", True))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test_door").state == STATE_ON
|
||||
assert hass.states.get(f"{BINARY_SENSOR_DOMAIN}.test_door").state == STATE_ON
|
||||
|
||||
# Emulate websocket message: device went offline
|
||||
test_gateway.devices["Test"].status = 1
|
||||
test_gateway.publisher.dispatch("Test", ("Status", False, "status"))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test_door").state == STATE_UNAVAILABLE
|
||||
assert (
|
||||
hass.states.get(f"{BINARY_SENSOR_DOMAIN}.test_door").state == STATE_UNAVAILABLE
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_zeroconf")
|
||||
|
@ -69,25 +73,30 @@ async def test_remote_control(
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test_button_1")
|
||||
state = hass.states.get(f"{BINARY_SENSOR_DOMAIN}.test_button_1")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test_button_1") == snapshot
|
||||
assert (
|
||||
entity_registry.async_get(f"{BINARY_SENSOR_DOMAIN}.test_button_1") == snapshot
|
||||
)
|
||||
|
||||
# Emulate websocket message: button pressed
|
||||
test_gateway.publisher.dispatch("Test", ("Test", 1))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test_button_1").state == STATE_ON
|
||||
assert hass.states.get(f"{BINARY_SENSOR_DOMAIN}.test_button_1").state == STATE_ON
|
||||
|
||||
# Emulate websocket message: button released
|
||||
test_gateway.publisher.dispatch("Test", ("Test", 0))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test_button_1").state == STATE_OFF
|
||||
assert hass.states.get(f"{BINARY_SENSOR_DOMAIN}.test_button_1").state == STATE_OFF
|
||||
|
||||
# Emulate websocket message: device went offline
|
||||
test_gateway.devices["Test"].status = 1
|
||||
test_gateway.publisher.dispatch("Test", ("Status", False, "status"))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test_button_1").state == STATE_UNAVAILABLE
|
||||
assert (
|
||||
hass.states.get(f"{BINARY_SENSOR_DOMAIN}.test_button_1").state
|
||||
== STATE_UNAVAILABLE
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_zeroconf")
|
||||
|
@ -101,7 +110,7 @@ async def test_disabled(hass: HomeAssistant) -> None:
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(f"{DOMAIN}.test_door") is None
|
||||
assert hass.states.get(f"{BINARY_SENSOR_DOMAIN}.test_door") is None
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_zeroconf")
|
||||
|
@ -116,7 +125,7 @@ async def test_remove_from_hass(hass: HomeAssistant) -> None:
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test_door")
|
||||
state = hass.states.get(f"{BINARY_SENSOR_DOMAIN}.test_door")
|
||||
assert state is not None
|
||||
await hass.config_entries.async_remove(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -6,7 +6,7 @@ from syrupy.assertion import SnapshotAssertion
|
|||
|
||||
from homeassistant.components.climate import (
|
||||
ATTR_HVAC_MODE,
|
||||
DOMAIN,
|
||||
DOMAIN as CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
HVACMode,
|
||||
)
|
||||
|
@ -32,14 +32,14 @@ async def test_climate(
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{CLIMATE_DOMAIN}.test")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test") == snapshot
|
||||
assert entity_registry.async_get(f"{CLIMATE_DOMAIN}.test") == snapshot
|
||||
|
||||
# Emulate websocket message: temperature changed
|
||||
test_gateway.publisher.dispatch("Test", ("Test", 21.0))
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{CLIMATE_DOMAIN}.test")
|
||||
assert state.state == HVACMode.HEAT
|
||||
assert state.attributes[ATTR_TEMPERATURE] == 21.0
|
||||
|
||||
|
@ -48,10 +48,10 @@ async def test_climate(
|
|||
"devolo_home_control_api.properties.multi_level_switch_property.MultiLevelSwitchProperty.set"
|
||||
) as set_value:
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: f"{DOMAIN}.test",
|
||||
ATTR_ENTITY_ID: f"{CLIMATE_DOMAIN}.test",
|
||||
ATTR_HVAC_MODE: HVACMode.HEAT,
|
||||
ATTR_TEMPERATURE: 20.0,
|
||||
},
|
||||
|
@ -63,7 +63,7 @@ async def test_climate(
|
|||
test_gateway.devices["Test"].status = 1
|
||||
test_gateway.publisher.dispatch("Test", ("Status", False, "status"))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_UNAVAILABLE
|
||||
assert hass.states.get(f"{CLIMATE_DOMAIN}.test").state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_remove_from_hass(hass: HomeAssistant) -> None:
|
||||
|
@ -77,7 +77,7 @@ async def test_remove_from_hass(hass: HomeAssistant) -> None:
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{CLIMATE_DOMAIN}.test")
|
||||
assert state is not None
|
||||
await hass.config_entries.async_remove(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -4,7 +4,11 @@ from unittest.mock import patch
|
|||
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.cover import ATTR_CURRENT_POSITION, ATTR_POSITION, DOMAIN
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_CURRENT_POSITION,
|
||||
ATTR_POSITION,
|
||||
DOMAIN as COVER_DOMAIN,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
SERVICE_CLOSE_COVER,
|
||||
|
@ -34,14 +38,14 @@ async def test_cover(
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{COVER_DOMAIN}.test")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test") == snapshot
|
||||
assert entity_registry.async_get(f"{COVER_DOMAIN}.test") == snapshot
|
||||
|
||||
# Emulate websocket message: position changed
|
||||
test_gateway.publisher.dispatch("Test", ("devolo.Blinds", 0.0))
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{COVER_DOMAIN}.test")
|
||||
assert state.state == STATE_CLOSED
|
||||
assert state.attributes[ATTR_CURRENT_POSITION] == 0.0
|
||||
|
||||
|
@ -50,27 +54,27 @@ async def test_cover(
|
|||
"devolo_home_control_api.properties.multi_level_switch_property.MultiLevelSwitchProperty.set"
|
||||
) as set_value:
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
COVER_DOMAIN,
|
||||
SERVICE_OPEN_COVER,
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.test"},
|
||||
{ATTR_ENTITY_ID: f"{COVER_DOMAIN}.test"},
|
||||
blocking=True,
|
||||
) # In reality, this leads to a websocket message like already tested above
|
||||
set_value.assert_called_once_with(100)
|
||||
|
||||
set_value.reset_mock()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
COVER_DOMAIN,
|
||||
SERVICE_CLOSE_COVER,
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.test"},
|
||||
{ATTR_ENTITY_ID: f"{COVER_DOMAIN}.test"},
|
||||
blocking=True,
|
||||
) # In reality, this leads to a websocket message like already tested above
|
||||
set_value.assert_called_once_with(0)
|
||||
|
||||
set_value.reset_mock()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
COVER_DOMAIN,
|
||||
SERVICE_SET_COVER_POSITION,
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.test", ATTR_POSITION: 50},
|
||||
{ATTR_ENTITY_ID: f"{COVER_DOMAIN}.test", ATTR_POSITION: 50},
|
||||
blocking=True,
|
||||
) # In reality, this leads to a websocket message like already tested above
|
||||
set_value.assert_called_once_with(50)
|
||||
|
@ -79,7 +83,7 @@ async def test_cover(
|
|||
test_gateway.devices["Test"].status = 1
|
||||
test_gateway.publisher.dispatch("Test", ("Status", False, "status"))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_UNAVAILABLE
|
||||
assert hass.states.get(f"{COVER_DOMAIN}.test").state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_remove_from_hass(hass: HomeAssistant) -> None:
|
||||
|
@ -93,7 +97,7 @@ async def test_remove_from_hass(hass: HomeAssistant) -> None:
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{COVER_DOMAIN}.test")
|
||||
assert state is not None
|
||||
await hass.config_entries.async_remove(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
|||
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.light import ATTR_BRIGHTNESS, DOMAIN
|
||||
from homeassistant.components.light import ATTR_BRIGHTNESS, DOMAIN as LIGHT_DOMAIN
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
SERVICE_TURN_OFF,
|
||||
|
@ -33,18 +33,18 @@ async def test_light_without_binary_sensor(
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{LIGHT_DOMAIN}.test")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test") == snapshot
|
||||
assert entity_registry.async_get(f"{LIGHT_DOMAIN}.test") == snapshot
|
||||
|
||||
# Emulate websocket message: brightness changed
|
||||
test_gateway.publisher.dispatch("Test", ("devolo.Dimmer:Test", 0.0))
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{LIGHT_DOMAIN}.test")
|
||||
assert state.state == STATE_OFF
|
||||
test_gateway.publisher.dispatch("Test", ("devolo.Dimmer:Test", 100.0))
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{LIGHT_DOMAIN}.test")
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes[ATTR_BRIGHTNESS] == 255
|
||||
|
||||
|
@ -53,27 +53,27 @@ async def test_light_without_binary_sensor(
|
|||
"devolo_home_control_api.properties.multi_level_switch_property.MultiLevelSwitchProperty.set"
|
||||
) as set_value:
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
LIGHT_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.test"},
|
||||
{ATTR_ENTITY_ID: f"{LIGHT_DOMAIN}.test"},
|
||||
blocking=True,
|
||||
) # In reality, this leads to a websocket message like already tested above
|
||||
set_value.assert_called_once_with(100)
|
||||
|
||||
set_value.reset_mock()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
LIGHT_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.test"},
|
||||
{ATTR_ENTITY_ID: f"{LIGHT_DOMAIN}.test"},
|
||||
blocking=True,
|
||||
) # In reality, this leads to a websocket message like already tested above
|
||||
set_value.assert_called_once_with(0)
|
||||
|
||||
set_value.reset_mock()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
LIGHT_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.test", ATTR_BRIGHTNESS: 50},
|
||||
{ATTR_ENTITY_ID: f"{LIGHT_DOMAIN}.test", ATTR_BRIGHTNESS: 50},
|
||||
blocking=True,
|
||||
) # In reality, this leads to a websocket message like already tested above
|
||||
set_value.assert_called_once_with(round(50 / 255 * 100))
|
||||
|
@ -82,7 +82,7 @@ async def test_light_without_binary_sensor(
|
|||
test_gateway.devices["Test"].status = 1
|
||||
test_gateway.publisher.dispatch("Test", ("Status", False, "status"))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_UNAVAILABLE
|
||||
assert hass.states.get(f"{LIGHT_DOMAIN}.test").state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_light_with_binary_sensor(
|
||||
|
@ -101,18 +101,18 @@ async def test_light_with_binary_sensor(
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{LIGHT_DOMAIN}.test")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test") == snapshot
|
||||
assert entity_registry.async_get(f"{LIGHT_DOMAIN}.test") == snapshot
|
||||
|
||||
# Emulate websocket message: brightness changed
|
||||
test_gateway.publisher.dispatch("Test", ("devolo.Dimmer:Test", 0.0))
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{LIGHT_DOMAIN}.test")
|
||||
assert state.state == STATE_OFF
|
||||
test_gateway.publisher.dispatch("Test", ("devolo.Dimmer:Test", 100.0))
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{LIGHT_DOMAIN}.test")
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes[ATTR_BRIGHTNESS] == 255
|
||||
|
||||
|
@ -121,18 +121,18 @@ async def test_light_with_binary_sensor(
|
|||
"devolo_home_control_api.properties.binary_switch_property.BinarySwitchProperty.set"
|
||||
) as set_value:
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
LIGHT_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.test"},
|
||||
{ATTR_ENTITY_ID: f"{LIGHT_DOMAIN}.test"},
|
||||
blocking=True,
|
||||
) # In reality, this leads to a websocket message like already tested above
|
||||
set_value.assert_called_once_with(True)
|
||||
|
||||
set_value.reset_mock()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
LIGHT_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.test"},
|
||||
{ATTR_ENTITY_ID: f"{LIGHT_DOMAIN}.test"},
|
||||
blocking=True,
|
||||
) # In reality, this leads to a websocket message like already tested above
|
||||
set_value.assert_called_once_with(False)
|
||||
|
@ -149,7 +149,7 @@ async def test_remove_from_hass(hass: HomeAssistant) -> None:
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{LIGHT_DOMAIN}.test")
|
||||
assert state is not None
|
||||
await hass.config_entries.async_remove(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
|||
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.sensor import DOMAIN
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
@ -26,9 +26,9 @@ async def test_temperature_sensor(
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test_temperature")
|
||||
state = hass.states.get(f"{SENSOR_DOMAIN}.test_temperature")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test_temperature") == snapshot
|
||||
assert entity_registry.async_get(f"{SENSOR_DOMAIN}.test_temperature") == snapshot
|
||||
|
||||
|
||||
async def test_battery_sensor(
|
||||
|
@ -45,14 +45,14 @@ async def test_battery_sensor(
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test_battery_level")
|
||||
state = hass.states.get(f"{SENSOR_DOMAIN}.test_battery_level")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test_battery_level") == snapshot
|
||||
assert entity_registry.async_get(f"{SENSOR_DOMAIN}.test_battery_level") == snapshot
|
||||
|
||||
# Emulate websocket message: value changed
|
||||
test_gateway.publisher.dispatch("Test", ("Test", 10, "battery_level"))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test_battery_level").state == "10"
|
||||
assert hass.states.get(f"{SENSOR_DOMAIN}.test_battery_level").state == "10"
|
||||
|
||||
|
||||
async def test_consumption_sensor(
|
||||
|
@ -68,29 +68,36 @@ async def test_consumption_sensor(
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test_current_consumption")
|
||||
state = hass.states.get(f"{SENSOR_DOMAIN}.test_current_consumption")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test_current_consumption") == snapshot
|
||||
assert (
|
||||
entity_registry.async_get(f"{SENSOR_DOMAIN}.test_current_consumption")
|
||||
== snapshot
|
||||
)
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test_total_consumption")
|
||||
state = hass.states.get(f"{SENSOR_DOMAIN}.test_total_consumption")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test_total_consumption") == snapshot
|
||||
assert (
|
||||
entity_registry.async_get(f"{SENSOR_DOMAIN}.test_total_consumption") == snapshot
|
||||
)
|
||||
|
||||
# Emulate websocket message: value changed
|
||||
test_gateway.devices["Test"].consumption_property["devolo.Meter:Test"].total = 50.0
|
||||
test_gateway.publisher.dispatch("Test", ("devolo.Meter:Test", 50.0))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test_total_consumption").state == "50.0"
|
||||
assert hass.states.get(f"{SENSOR_DOMAIN}.test_total_consumption").state == "50.0"
|
||||
|
||||
# Emulate websocket message: device went offline
|
||||
test_gateway.devices["Test"].status = 1
|
||||
test_gateway.publisher.dispatch("Test", ("Status", False, "status"))
|
||||
await hass.async_block_till_done()
|
||||
assert (
|
||||
hass.states.get(f"{DOMAIN}.test_current_consumption").state == STATE_UNAVAILABLE
|
||||
hass.states.get(f"{SENSOR_DOMAIN}.test_current_consumption").state
|
||||
== STATE_UNAVAILABLE
|
||||
)
|
||||
assert (
|
||||
hass.states.get(f"{DOMAIN}.test_total_consumption").state == STATE_UNAVAILABLE
|
||||
hass.states.get(f"{SENSOR_DOMAIN}.test_total_consumption").state
|
||||
== STATE_UNAVAILABLE
|
||||
)
|
||||
|
||||
|
||||
|
@ -105,7 +112,7 @@ async def test_voltage_sensor(hass: HomeAssistant) -> None:
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test_voltage")
|
||||
state = hass.states.get(f"{SENSOR_DOMAIN}.test_voltage")
|
||||
assert state is None
|
||||
|
||||
|
||||
|
@ -123,14 +130,16 @@ async def test_sensor_change(hass: HomeAssistant) -> None:
|
|||
# Emulate websocket message: value changed
|
||||
test_gateway.publisher.dispatch("Test", ("devolo.MultiLevelSensor:Test", 50.0))
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{DOMAIN}.test_temperature")
|
||||
state = hass.states.get(f"{SENSOR_DOMAIN}.test_temperature")
|
||||
assert state.state == "50.0"
|
||||
|
||||
# Emulate websocket message: device went offline
|
||||
test_gateway.devices["Test"].status = 1
|
||||
test_gateway.publisher.dispatch("Test", ("Status", False, "status"))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test_temperature").state == STATE_UNAVAILABLE
|
||||
assert (
|
||||
hass.states.get(f"{SENSOR_DOMAIN}.test_temperature").state == STATE_UNAVAILABLE
|
||||
)
|
||||
|
||||
|
||||
async def test_remove_from_hass(hass: HomeAssistant) -> None:
|
||||
|
@ -144,7 +153,7 @@ async def test_remove_from_hass(hass: HomeAssistant) -> None:
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test_temperature")
|
||||
state = hass.states.get(f"{SENSOR_DOMAIN}.test_temperature")
|
||||
assert state is not None
|
||||
await hass.config_entries.async_remove(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
|||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.siren import DOMAIN
|
||||
from homeassistant.components.siren import DOMAIN as SIREN_DOMAIN
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
@ -29,20 +29,20 @@ async def test_siren(
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{SIREN_DOMAIN}.test")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test") == snapshot
|
||||
assert entity_registry.async_get(f"{SIREN_DOMAIN}.test") == snapshot
|
||||
|
||||
# Emulate websocket message: sensor turned on
|
||||
test_gateway.publisher.dispatch("Test", ("devolo.SirenMultiLevelSwitch:Test", 1))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_ON
|
||||
assert hass.states.get(f"{SIREN_DOMAIN}.test").state == STATE_ON
|
||||
|
||||
# Emulate websocket message: device went offline
|
||||
test_gateway.devices["Test"].status = 1
|
||||
test_gateway.publisher.dispatch("Test", ("Status", False, "status"))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_UNAVAILABLE
|
||||
assert hass.states.get(f"{SIREN_DOMAIN}.test").state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_zeroconf")
|
||||
|
@ -60,9 +60,9 @@ async def test_siren_switching(
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{SIREN_DOMAIN}.test")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test") == snapshot
|
||||
assert entity_registry.async_get(f"{SIREN_DOMAIN}.test") == snapshot
|
||||
|
||||
with patch(
|
||||
"devolo_home_control_api.properties.multi_level_switch_property.MultiLevelSwitchProperty.set"
|
||||
|
@ -70,7 +70,7 @@ async def test_siren_switching(
|
|||
await hass.services.async_call(
|
||||
"siren",
|
||||
"turn_on",
|
||||
{"entity_id": f"{DOMAIN}.test"},
|
||||
{"entity_id": f"{SIREN_DOMAIN}.test"},
|
||||
blocking=True,
|
||||
)
|
||||
# The real device state is changed by a websocket message
|
||||
|
@ -86,7 +86,7 @@ async def test_siren_switching(
|
|||
await hass.services.async_call(
|
||||
"siren",
|
||||
"turn_off",
|
||||
{"entity_id": f"{DOMAIN}.test"},
|
||||
{"entity_id": f"{SIREN_DOMAIN}.test"},
|
||||
blocking=True,
|
||||
)
|
||||
# The real device state is changed by a websocket message
|
||||
|
@ -94,7 +94,7 @@ async def test_siren_switching(
|
|||
"Test", ("devolo.SirenMultiLevelSwitch:Test", 0)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_OFF
|
||||
assert hass.states.get(f"{SIREN_DOMAIN}.test").state == STATE_OFF
|
||||
property_set.assert_called_once_with(0)
|
||||
|
||||
|
||||
|
@ -113,9 +113,9 @@ async def test_siren_change_default_tone(
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{SIREN_DOMAIN}.test")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test") == snapshot
|
||||
assert entity_registry.async_get(f"{SIREN_DOMAIN}.test") == snapshot
|
||||
|
||||
with patch(
|
||||
"devolo_home_control_api.properties.multi_level_switch_property.MultiLevelSwitchProperty.set"
|
||||
|
@ -124,7 +124,7 @@ async def test_siren_change_default_tone(
|
|||
await hass.services.async_call(
|
||||
"siren",
|
||||
"turn_on",
|
||||
{"entity_id": f"{DOMAIN}.test"},
|
||||
{"entity_id": f"{SIREN_DOMAIN}.test"},
|
||||
blocking=True,
|
||||
)
|
||||
property_set.assert_called_once_with(2)
|
||||
|
@ -142,7 +142,7 @@ async def test_remove_from_hass(hass: HomeAssistant) -> None:
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{SIREN_DOMAIN}.test")
|
||||
assert state is not None
|
||||
await hass.config_entries.async_remove(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
|||
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.switch import DOMAIN
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
SERVICE_TURN_OFF,
|
||||
|
@ -32,9 +32,9 @@ async def test_switch(
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{SWITCH_DOMAIN}.test")
|
||||
assert state == snapshot
|
||||
assert entity_registry.async_get(f"{DOMAIN}.test") == snapshot
|
||||
assert entity_registry.async_get(f"{SWITCH_DOMAIN}.test") == snapshot
|
||||
|
||||
# Emulate websocket message: switched on
|
||||
test_gateway.devices["Test"].binary_switch_property[
|
||||
|
@ -42,24 +42,24 @@ async def test_switch(
|
|||
].state = True
|
||||
test_gateway.publisher.dispatch("Test", ("devolo.BinarySwitch:Test", True))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_ON
|
||||
assert hass.states.get(f"{SWITCH_DOMAIN}.test").state == STATE_ON
|
||||
|
||||
with patch(
|
||||
"devolo_home_control_api.properties.binary_switch_property.BinarySwitchProperty.set"
|
||||
) as set_value:
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.test"},
|
||||
{ATTR_ENTITY_ID: f"{SWITCH_DOMAIN}.test"},
|
||||
blocking=True,
|
||||
) # In reality, this leads to a websocket message like already tested above
|
||||
set_value.assert_called_once_with(state=True)
|
||||
|
||||
set_value.reset_mock()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.test"},
|
||||
{ATTR_ENTITY_ID: f"{SWITCH_DOMAIN}.test"},
|
||||
blocking=True,
|
||||
) # In reality, this leads to a websocket message like already tested above
|
||||
set_value.assert_called_once_with(state=False)
|
||||
|
@ -68,7 +68,7 @@ async def test_switch(
|
|||
test_gateway.devices["Test"].status = 1
|
||||
test_gateway.publisher.dispatch("Test", ("Status", False, "status"))
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_UNAVAILABLE
|
||||
assert hass.states.get(f"{SWITCH_DOMAIN}.test").state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_remove_from_hass(hass: HomeAssistant) -> None:
|
||||
|
@ -82,7 +82,7 @@ async def test_remove_from_hass(hass: HomeAssistant) -> None:
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.test")
|
||||
state = hass.states.get(f"{SWITCH_DOMAIN}.test")
|
||||
assert state is not None
|
||||
await hass.config_entries.async_remove(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -7,7 +7,7 @@ from freezegun.api import FrozenDateTimeFactory
|
|||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.binary_sensor import DOMAIN
|
||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
||||
from homeassistant.components.devolo_home_network.const import (
|
||||
CONNECTED_TO_ROUTER,
|
||||
LONG_UPDATE_INTERVAL,
|
||||
|
@ -31,7 +31,10 @@ async def test_binary_sensor_setup(hass: HomeAssistant) -> None:
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(f"{DOMAIN}.{device_name}_{CONNECTED_TO_ROUTER}") is None
|
||||
assert (
|
||||
hass.states.get(f"{BINARY_SENSOR_DOMAIN}.{device_name}_{CONNECTED_TO_ROUTER}")
|
||||
is None
|
||||
)
|
||||
|
||||
await hass.config_entries.async_unload(entry.entry_id)
|
||||
|
||||
|
@ -47,7 +50,7 @@ async def test_update_attached_to_router(
|
|||
"""Test state change of a attached_to_router binary sensor device."""
|
||||
entry = configure_integration(hass)
|
||||
device_name = entry.title.replace(" ", "_").lower()
|
||||
state_key = f"{DOMAIN}.{device_name}_{CONNECTED_TO_ROUTER}"
|
||||
state_key = f"{BINARY_SENSOR_DOMAIN}.{device_name}_{CONNECTED_TO_ROUTER}"
|
||||
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -9,7 +9,7 @@ import pytest
|
|||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.devolo_home_network.const import SHORT_UPDATE_INTERVAL
|
||||
from homeassistant.components.image import DOMAIN
|
||||
from homeassistant.components.image import DOMAIN as IMAGE_DOMAIN
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
@ -32,7 +32,9 @@ async def test_image_setup(hass: HomeAssistant) -> None:
|
|||
await hass.async_block_till_done()
|
||||
|
||||
assert (
|
||||
hass.states.get(f"{DOMAIN}.{device_name}_guest_wi_fi_credentials_as_qr_code")
|
||||
hass.states.get(
|
||||
f"{IMAGE_DOMAIN}.{device_name}_guest_wi_fi_credentials_as_qr_code"
|
||||
)
|
||||
is not None
|
||||
)
|
||||
|
||||
|
@ -51,7 +53,7 @@ async def test_guest_wifi_qr(
|
|||
"""Test showing a QR code of the guest wifi credentials."""
|
||||
entry = configure_integration(hass)
|
||||
device_name = entry.title.replace(" ", "_").lower()
|
||||
state_key = f"{DOMAIN}.{device_name}_guest_wi_fi_credentials_as_qr_code"
|
||||
state_key = f"{IMAGE_DOMAIN}.{device_name}_guest_wi_fi_credentials_as_qr_code"
|
||||
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Test DoorBird buttons."""
|
||||
|
||||
from homeassistant.components.button import DOMAIN, SERVICE_PRESS
|
||||
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
@ -16,7 +16,7 @@ async def test_relay_button(
|
|||
relay_1_entity_id = "button.mydoorbird_relay_1"
|
||||
assert hass.states.get(relay_1_entity_id).state == STATE_UNKNOWN
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_PRESS, {ATTR_ENTITY_ID: relay_1_entity_id}, blocking=True
|
||||
BUTTON_DOMAIN, SERVICE_PRESS, {ATTR_ENTITY_ID: relay_1_entity_id}, blocking=True
|
||||
)
|
||||
assert hass.states.get(relay_1_entity_id).state != STATE_UNKNOWN
|
||||
assert doorbird_entry.api.energize_relay.call_count == 1
|
||||
|
@ -31,7 +31,7 @@ async def test_ir_button(
|
|||
ir_entity_id = "button.mydoorbird_ir"
|
||||
assert hass.states.get(ir_entity_id).state == STATE_UNKNOWN
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_PRESS, {ATTR_ENTITY_ID: ir_entity_id}, blocking=True
|
||||
BUTTON_DOMAIN, SERVICE_PRESS, {ATTR_ENTITY_ID: ir_entity_id}, blocking=True
|
||||
)
|
||||
assert hass.states.get(ir_entity_id).state != STATE_UNKNOWN
|
||||
assert doorbird_entry.api.turn_light_on.call_count == 1
|
||||
|
@ -46,7 +46,7 @@ async def test_reset_favorites_button(
|
|||
reset_entity_id = "button.mydoorbird_reset_favorites"
|
||||
assert hass.states.get(reset_entity_id).state == STATE_UNKNOWN
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_PRESS, {ATTR_ENTITY_ID: reset_entity_id}, blocking=True
|
||||
BUTTON_DOMAIN, SERVICE_PRESS, {ATTR_ENTITY_ID: reset_entity_id}, blocking=True
|
||||
)
|
||||
assert hass.states.get(reset_entity_id).state != STATE_UNKNOWN
|
||||
assert doorbird_entry.api.delete_favorite.call_count == 3
|
||||
|
|
Loading…
Reference in New Issue