Add alias to DOMAIN import in tests [e-g] (#125575)
parent
029dbe7d94
commit
fe2402b611
|
@ -2,7 +2,11 @@
|
|||
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.number import ATTR_VALUE, DOMAIN, SERVICE_SET_VALUE
|
||||
from homeassistant.components.number import (
|
||||
ATTR_VALUE,
|
||||
DOMAIN as NUMBER_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, UnitOfTime
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
@ -15,7 +19,7 @@ THERMOSTAT_ID = 0
|
|||
|
||||
async def test_ventilator_min_on_home_attributes(hass: HomeAssistant) -> None:
|
||||
"""Test the ventilator number on home attributes are correct."""
|
||||
await setup_platform(hass, DOMAIN)
|
||||
await setup_platform(hass, NUMBER_DOMAIN)
|
||||
|
||||
state = hass.states.get(VENTILATOR_MIN_HOME_ID)
|
||||
assert state.state == "20"
|
||||
|
@ -28,7 +32,7 @@ async def test_ventilator_min_on_home_attributes(hass: HomeAssistant) -> None:
|
|||
|
||||
async def test_ventilator_min_on_away_attributes(hass: HomeAssistant) -> None:
|
||||
"""Test the ventilator number on away attributes are correct."""
|
||||
await setup_platform(hass, DOMAIN)
|
||||
await setup_platform(hass, NUMBER_DOMAIN)
|
||||
|
||||
state = hass.states.get(VENTILATOR_MIN_AWAY_ID)
|
||||
assert state.state == "10"
|
||||
|
@ -45,10 +49,10 @@ async def test_set_min_time_home(hass: HomeAssistant) -> None:
|
|||
with patch(
|
||||
"homeassistant.components.ecobee.Ecobee.set_ventilator_min_on_time_home"
|
||||
) as mock_set_min_home_time:
|
||||
await setup_platform(hass, DOMAIN)
|
||||
await setup_platform(hass, NUMBER_DOMAIN)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
NUMBER_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
{ATTR_ENTITY_ID: VENTILATOR_MIN_HOME_ID, ATTR_VALUE: target_value},
|
||||
blocking=True,
|
||||
|
@ -63,10 +67,10 @@ async def test_set_min_time_away(hass: HomeAssistant) -> None:
|
|||
with patch(
|
||||
"homeassistant.components.ecobee.Ecobee.set_ventilator_min_on_time_away"
|
||||
) as mock_set_min_away_time:
|
||||
await setup_platform(hass, DOMAIN)
|
||||
await setup_platform(hass, NUMBER_DOMAIN)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
NUMBER_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
{ATTR_ENTITY_ID: VENTILATOR_MIN_AWAY_ID, ATTR_VALUE: target_value},
|
||||
blocking=True,
|
||||
|
|
|
@ -8,7 +8,11 @@ from unittest.mock import patch
|
|||
import pytest
|
||||
|
||||
from homeassistant.components.ecobee.switch import DATE_FORMAT
|
||||
from homeassistant.components.switch import DOMAIN, SERVICE_TURN_OFF, SERVICE_TURN_ON
|
||||
from homeassistant.components.switch import (
|
||||
DOMAIN as SWITCH_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
SERVICE_TURN_ON,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
@ -29,7 +33,7 @@ def data_fixture():
|
|||
|
||||
async def test_ventilator_20min_attributes(hass: HomeAssistant) -> None:
|
||||
"""Test the ventilator switch on home attributes are correct."""
|
||||
await setup_platform(hass, DOMAIN)
|
||||
await setup_platform(hass, SWITCH_DOMAIN)
|
||||
|
||||
state = hass.states.get(VENTILATOR_20MIN_ID)
|
||||
assert state.state == "off"
|
||||
|
@ -42,7 +46,7 @@ async def test_ventilator_20min_when_on(hass: HomeAssistant, data) -> None:
|
|||
datetime.now() + timedelta(days=1)
|
||||
).strftime(DATE_FORMAT)
|
||||
with mock.patch("pyecobee.Ecobee.get_thermostat", data):
|
||||
await setup_platform(hass, DOMAIN)
|
||||
await setup_platform(hass, SWITCH_DOMAIN)
|
||||
|
||||
state = hass.states.get(VENTILATOR_20MIN_ID)
|
||||
assert state.state == "on"
|
||||
|
@ -57,7 +61,7 @@ async def test_ventilator_20min_when_off(hass: HomeAssistant, data) -> None:
|
|||
datetime.now() - timedelta(days=1)
|
||||
).strftime(DATE_FORMAT)
|
||||
with mock.patch("pyecobee.Ecobee.get_thermostat", data):
|
||||
await setup_platform(hass, DOMAIN)
|
||||
await setup_platform(hass, SWITCH_DOMAIN)
|
||||
|
||||
state = hass.states.get(VENTILATOR_20MIN_ID)
|
||||
assert state.state == "off"
|
||||
|
@ -70,7 +74,7 @@ async def test_ventilator_20min_when_empty(hass: HomeAssistant, data) -> None:
|
|||
|
||||
data.return_value["settings"]["ventilatorOffDateTime"] = ""
|
||||
with mock.patch("pyecobee.Ecobee.get_thermostat", data):
|
||||
await setup_platform(hass, DOMAIN)
|
||||
await setup_platform(hass, SWITCH_DOMAIN)
|
||||
|
||||
state = hass.states.get(VENTILATOR_20MIN_ID)
|
||||
assert state.state == "off"
|
||||
|
@ -84,10 +88,10 @@ async def test_turn_on_20min_ventilator(hass: HomeAssistant) -> None:
|
|||
with patch(
|
||||
"homeassistant.components.ecobee.Ecobee.set_ventilator_timer"
|
||||
) as mock_set_20min_ventilator:
|
||||
await setup_platform(hass, DOMAIN)
|
||||
await setup_platform(hass, SWITCH_DOMAIN)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: VENTILATOR_20MIN_ID},
|
||||
blocking=True,
|
||||
|
@ -102,10 +106,10 @@ async def test_turn_off_20min_ventilator(hass: HomeAssistant) -> None:
|
|||
with patch(
|
||||
"homeassistant.components.ecobee.Ecobee.set_ventilator_timer"
|
||||
) as mock_set_20min_ventilator:
|
||||
await setup_platform(hass, DOMAIN)
|
||||
await setup_platform(hass, SWITCH_DOMAIN)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: VENTILATOR_20MIN_ID},
|
||||
blocking=True,
|
||||
|
@ -120,10 +124,10 @@ DEVICE_ID = "switch.ecobee2_aux_heat_only"
|
|||
async def test_aux_heat_only_turn_on(hass: HomeAssistant) -> None:
|
||||
"""Test the switch can be turned on."""
|
||||
with patch("pyecobee.Ecobee.set_hvac_mode") as mock_turn_on:
|
||||
await setup_platform(hass, DOMAIN)
|
||||
await setup_platform(hass, SWITCH_DOMAIN)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: DEVICE_ID},
|
||||
blocking=True,
|
||||
|
@ -134,10 +138,10 @@ async def test_aux_heat_only_turn_on(hass: HomeAssistant) -> None:
|
|||
async def test_aux_heat_only_turn_off(hass: HomeAssistant) -> None:
|
||||
"""Test the switch can be turned off."""
|
||||
with patch("pyecobee.Ecobee.set_hvac_mode") as mock_turn_off:
|
||||
await setup_platform(hass, DOMAIN)
|
||||
await setup_platform(hass, SWITCH_DOMAIN)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: DEVICE_ID},
|
||||
blocking=True,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import pytest
|
||||
|
||||
from homeassistant.components.flo.const import DOMAIN as FLO_DOMAIN
|
||||
from homeassistant.components.switch import DOMAIN
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, STATE_OFF, STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -30,11 +30,11 @@ async def test_valve_switches(
|
|||
assert hass.states.get(entity_id).state == STATE_ON
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, "turn_off", {"entity_id": entity_id}, blocking=True
|
||||
SWITCH_DOMAIN, "turn_off", {"entity_id": entity_id}, blocking=True
|
||||
)
|
||||
assert hass.states.get(entity_id).state == STATE_OFF
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, "turn_on", {"entity_id": entity_id}, blocking=True
|
||||
SWITCH_DOMAIN, "turn_on", {"entity_id": entity_id}, blocking=True
|
||||
)
|
||||
assert hass.states.get(entity_id).state == STATE_ON
|
||||
|
|
|
@ -6,7 +6,10 @@ from unittest.mock import Mock
|
|||
|
||||
from requests.exceptions import HTTPError
|
||||
|
||||
from homeassistant.components.binary_sensor import DOMAIN, BinarySensorDeviceClass
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DOMAIN as BINARY_SENSOR_DOMAIN,
|
||||
BinarySensorDeviceClass,
|
||||
)
|
||||
from homeassistant.components.fritzbox.const import DOMAIN as FB_DOMAIN
|
||||
from homeassistant.components.sensor import ATTR_STATE_CLASS, DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.const import (
|
||||
|
@ -27,7 +30,7 @@ from .const import CONF_FAKE_NAME, MOCK_CONFIG
|
|||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
ENTITY_ID = f"{DOMAIN}.{CONF_FAKE_NAME}"
|
||||
ENTITY_ID = f"{BINARY_SENSOR_DOMAIN}.{CONF_FAKE_NAME}"
|
||||
|
||||
|
||||
async def test_setup(hass: HomeAssistant, fritz: Mock) -> None:
|
||||
|
@ -148,5 +151,5 @@ async def test_discover_new_device(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
async_fire_time_changed(hass, next_update)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.new_device_alarm")
|
||||
state = hass.states.get(f"{BINARY_SENSOR_DOMAIN}.new_device_alarm")
|
||||
assert state
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
from datetime import timedelta
|
||||
from unittest.mock import Mock
|
||||
|
||||
from homeassistant.components.button import DOMAIN, SERVICE_PRESS
|
||||
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
|
||||
from homeassistant.components.fritzbox.const import DOMAIN as FB_DOMAIN
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
|
@ -19,7 +19,7 @@ from .const import CONF_FAKE_NAME, MOCK_CONFIG
|
|||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
ENTITY_ID = f"{DOMAIN}.{CONF_FAKE_NAME}"
|
||||
ENTITY_ID = f"{BUTTON_DOMAIN}.{CONF_FAKE_NAME}"
|
||||
|
||||
|
||||
async def test_setup(hass: HomeAssistant, fritz: Mock) -> None:
|
||||
|
@ -43,7 +43,7 @@ async def test_apply_template(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_PRESS, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
BUTTON_DOMAIN, SERVICE_PRESS, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
)
|
||||
assert fritz().apply_template.call_count == 1
|
||||
|
||||
|
@ -67,5 +67,5 @@ async def test_discover_new_device(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
async_fire_time_changed(hass, next_update)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.new_template")
|
||||
state = hass.states.get(f"{BUTTON_DOMAIN}.new_template")
|
||||
assert state
|
||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.components.climate import (
|
|||
ATTR_MIN_TEMP,
|
||||
ATTR_PRESET_MODE,
|
||||
ATTR_PRESET_MODES,
|
||||
DOMAIN,
|
||||
DOMAIN as CLIMATE_DOMAIN,
|
||||
PRESET_COMFORT,
|
||||
PRESET_ECO,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
|
@ -56,7 +56,7 @@ from .const import CONF_FAKE_NAME, MOCK_CONFIG
|
|||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
ENTITY_ID = f"{DOMAIN}.{CONF_FAKE_NAME}"
|
||||
ENTITY_ID = f"{CLIMATE_DOMAIN}.{CONF_FAKE_NAME}"
|
||||
|
||||
|
||||
async def test_setup(hass: HomeAssistant, fritz: Mock) -> None:
|
||||
|
@ -278,7 +278,7 @@ async def test_set_temperature_temperature(hass: HomeAssistant, fritz: Mock) ->
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_TEMPERATURE: 23},
|
||||
True,
|
||||
|
@ -294,7 +294,7 @@ async def test_set_temperature_mode_off(hass: HomeAssistant, fritz: Mock) -> Non
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: ENTITY_ID,
|
||||
|
@ -315,7 +315,7 @@ async def test_set_temperature_mode_heat(hass: HomeAssistant, fritz: Mock) -> No
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: ENTITY_ID,
|
||||
|
@ -335,7 +335,7 @@ async def test_set_hvac_mode_off(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_HVAC_MODE: HVACMode.OFF},
|
||||
True,
|
||||
|
@ -351,7 +351,7 @@ async def test_no_reset_hvac_mode_heat(hass: HomeAssistant, fritz: Mock) -> None
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_HVAC_MODE: HVACMode.HEAT},
|
||||
True,
|
||||
|
@ -368,7 +368,7 @@ async def test_set_hvac_mode_heat(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_HVAC_MODE: HVACMode.HEAT},
|
||||
True,
|
||||
|
@ -384,7 +384,7 @@ async def test_set_preset_mode_comfort(hass: HomeAssistant, fritz: Mock) -> None
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_PRESET_MODE: PRESET_COMFORT},
|
||||
True,
|
||||
|
@ -400,7 +400,7 @@ async def test_set_preset_mode_eco(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_PRESET_MODE: PRESET_ECO},
|
||||
True,
|
||||
|
@ -463,7 +463,7 @@ async def test_discover_new_device(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
async_fire_time_changed(hass, next_update)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.new_climate")
|
||||
state = hass.states.get(f"{CLIMATE_DOMAIN}.new_climate")
|
||||
assert state
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from unittest.mock import Mock, call
|
|||
from homeassistant.components.cover import (
|
||||
ATTR_CURRENT_POSITION,
|
||||
ATTR_POSITION,
|
||||
DOMAIN,
|
||||
DOMAIN as COVER_DOMAIN,
|
||||
STATE_OPEN,
|
||||
)
|
||||
from homeassistant.components.fritzbox.const import DOMAIN as FB_DOMAIN
|
||||
|
@ -32,7 +32,7 @@ from .const import CONF_FAKE_NAME, MOCK_CONFIG
|
|||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
ENTITY_ID = f"{DOMAIN}.{CONF_FAKE_NAME}"
|
||||
ENTITY_ID = f"{COVER_DOMAIN}.{CONF_FAKE_NAME}"
|
||||
|
||||
|
||||
async def test_setup(hass: HomeAssistant, fritz: Mock) -> None:
|
||||
|
@ -68,7 +68,7 @@ async def test_open_cover(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
COVER_DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
)
|
||||
assert device.set_blind_open.call_count == 1
|
||||
|
||||
|
@ -81,7 +81,7 @@ async def test_close_cover(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
COVER_DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
)
|
||||
assert device.set_blind_close.call_count == 1
|
||||
|
||||
|
@ -94,7 +94,7 @@ async def test_set_position_cover(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
COVER_DOMAIN,
|
||||
SERVICE_SET_COVER_POSITION,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_POSITION: 50},
|
||||
True,
|
||||
|
@ -110,7 +110,7 @@ async def test_stop_cover(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_STOP_COVER, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
COVER_DOMAIN, SERVICE_STOP_COVER, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
)
|
||||
assert device.set_blind_stop.call_count == 1
|
||||
|
||||
|
@ -134,5 +134,5 @@ async def test_discover_new_device(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
async_fire_time_changed(hass, next_update)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.new_climate")
|
||||
state = hass.states.get(f"{COVER_DOMAIN}.new_climate")
|
||||
assert state
|
||||
|
|
|
@ -19,7 +19,7 @@ from homeassistant.components.light import (
|
|||
ATTR_MAX_COLOR_TEMP_KELVIN,
|
||||
ATTR_MIN_COLOR_TEMP_KELVIN,
|
||||
ATTR_SUPPORTED_COLOR_MODES,
|
||||
DOMAIN,
|
||||
DOMAIN as LIGHT_DOMAIN,
|
||||
ColorMode,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
|
@ -38,7 +38,7 @@ from .const import CONF_FAKE_NAME, MOCK_CONFIG
|
|||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
ENTITY_ID = f"{DOMAIN}.{CONF_FAKE_NAME}"
|
||||
ENTITY_ID = f"{LIGHT_DOMAIN}.{CONF_FAKE_NAME}"
|
||||
|
||||
|
||||
async def test_setup(hass: HomeAssistant, fritz: Mock) -> None:
|
||||
|
@ -147,7 +147,7 @@ async def test_turn_on(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
LIGHT_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_BRIGHTNESS: 100, ATTR_COLOR_TEMP_KELVIN: 3000},
|
||||
True,
|
||||
|
@ -170,7 +170,7 @@ async def test_turn_on_color(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
hass, MOCK_CONFIG[FB_DOMAIN][CONF_DEVICES][0], ENTITY_ID, device, fritz
|
||||
)
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
LIGHT_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_BRIGHTNESS: 100, ATTR_HS_COLOR: (100, 70)},
|
||||
True,
|
||||
|
@ -204,7 +204,7 @@ async def test_turn_on_color_unsupported_api_method(
|
|||
device.set_unmapped_color.side_effect = error
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
LIGHT_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_BRIGHTNESS: 100, ATTR_HS_COLOR: (100, 70)},
|
||||
True,
|
||||
|
@ -219,7 +219,7 @@ async def test_turn_on_color_unsupported_api_method(
|
|||
error.response.status_code = 500
|
||||
with pytest.raises(HTTPError, match="Bad Request"):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
LIGHT_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_BRIGHTNESS: 100, ATTR_HS_COLOR: (100, 70)},
|
||||
True,
|
||||
|
@ -237,7 +237,7 @@ async def test_turn_off(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
hass, MOCK_CONFIG[FB_DOMAIN][CONF_DEVICES][0], ENTITY_ID, device, fritz
|
||||
)
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
LIGHT_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
)
|
||||
assert device.set_state_off.call_count == 1
|
||||
|
||||
|
@ -316,5 +316,5 @@ async def test_discover_new_device(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
async_fire_time_changed(hass, next_update)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.new_light")
|
||||
state = hass.states.get(f"{LIGHT_DOMAIN}.new_light")
|
||||
assert state
|
||||
|
|
|
@ -6,7 +6,11 @@ from unittest.mock import Mock
|
|||
from requests.exceptions import HTTPError
|
||||
|
||||
from homeassistant.components.fritzbox.const import DOMAIN as FB_DOMAIN
|
||||
from homeassistant.components.sensor import ATTR_STATE_CLASS, DOMAIN, SensorStateClass
|
||||
from homeassistant.components.sensor import (
|
||||
ATTR_STATE_CLASS,
|
||||
DOMAIN as SENSOR_DOMAIN,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_FRIENDLY_NAME,
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
|
@ -24,7 +28,7 @@ from .const import CONF_FAKE_NAME, MOCK_CONFIG
|
|||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
ENTITY_ID = f"{DOMAIN}.{CONF_FAKE_NAME}"
|
||||
ENTITY_ID = f"{SENSOR_DOMAIN}.{CONF_FAKE_NAME}"
|
||||
|
||||
|
||||
async def test_setup(
|
||||
|
@ -130,5 +134,5 @@ async def test_discover_new_device(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
async_fire_time_changed(hass, next_update)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.new_device_temperature")
|
||||
state = hass.states.get(f"{SENSOR_DOMAIN}.new_device_temperature")
|
||||
assert state
|
||||
|
|
|
@ -12,7 +12,7 @@ from homeassistant.components.sensor import (
|
|||
DOMAIN as SENSOR_DOMAIN,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.components.switch import DOMAIN
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_FRIENDLY_NAME,
|
||||
|
@ -39,7 +39,7 @@ from .const import CONF_FAKE_NAME, MOCK_CONFIG
|
|||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
ENTITY_ID = f"{DOMAIN}.{CONF_FAKE_NAME}"
|
||||
ENTITY_ID = f"{SWITCH_DOMAIN}.{CONF_FAKE_NAME}"
|
||||
|
||||
|
||||
async def test_setup(
|
||||
|
@ -124,7 +124,7 @@ async def test_turn_on(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
SWITCH_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
)
|
||||
assert device.set_switch_state_on.call_count == 1
|
||||
|
||||
|
@ -138,7 +138,7 @@ async def test_turn_off(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
SWITCH_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
)
|
||||
|
||||
assert device.set_switch_state_off.call_count == 1
|
||||
|
@ -158,7 +158,7 @@ async def test_toggle_while_locked(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
match="Can't toggle switch while manual switching is disabled for the device",
|
||||
):
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
SWITCH_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
)
|
||||
|
||||
with pytest.raises(
|
||||
|
@ -166,7 +166,7 @@ async def test_toggle_while_locked(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
match="Can't toggle switch while manual switching is disabled for the device",
|
||||
):
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
SWITCH_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||
)
|
||||
|
||||
|
||||
|
@ -239,5 +239,5 @@ async def test_discover_new_device(hass: HomeAssistant, fritz: Mock) -> None:
|
|||
async_fire_time_changed(hass, next_update)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
state = hass.states.get(f"{DOMAIN}.new_switch")
|
||||
state = hass.states.get(f"{SWITCH_DOMAIN}.new_switch")
|
||||
assert state
|
||||
|
|
|
@ -13,7 +13,7 @@ from homeassistant.components.generic_hygrostat import (
|
|||
)
|
||||
from homeassistant.components.humidifier import (
|
||||
ATTR_HUMIDITY,
|
||||
DOMAIN,
|
||||
DOMAIN as HUMIDIFIER_DOMAIN,
|
||||
MODE_AWAY,
|
||||
MODE_NORMAL,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
|
@ -107,7 +107,7 @@ async def test_humidifier_input_boolean(hass: HomeAssistant) -> None:
|
|||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -125,7 +125,7 @@ async def test_humidifier_input_boolean(hass: HomeAssistant) -> None:
|
|||
_setup_sensor(hass, 23)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 32},
|
||||
blocking=True,
|
||||
|
@ -151,7 +151,7 @@ async def test_humidifier_switch(
|
|||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -170,7 +170,7 @@ async def test_humidifier_switch(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 32},
|
||||
blocking=True,
|
||||
|
@ -191,7 +191,7 @@ async def test_unique_id(
|
|||
await _setup_switch(hass, True)
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -222,7 +222,7 @@ async def setup_comp_0(hass: HomeAssistant) -> None:
|
|||
await hass.async_block_till_done()
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -248,7 +248,7 @@ async def setup_comp_2(hass: HomeAssistant) -> None:
|
|||
await hass.async_block_till_done()
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -269,7 +269,7 @@ async def test_unavailable_state(hass: HomeAssistant) -> None:
|
|||
"""Test the setting of defaults to unknown."""
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -296,7 +296,7 @@ async def test_setup_defaults_to_unknown(hass: HomeAssistant) -> None:
|
|||
"""Test the setting of defaults to unknown."""
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -345,7 +345,7 @@ async def test_get_modes(hass: HomeAssistant) -> None:
|
|||
async def test_set_target_humidity(hass: HomeAssistant) -> None:
|
||||
"""Test the setting of the target humidity."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 40},
|
||||
blocking=True,
|
||||
|
@ -355,7 +355,7 @@ async def test_set_target_humidity(hass: HomeAssistant) -> None:
|
|||
assert state.attributes.get("humidity") == 40
|
||||
with pytest.raises(vol.Invalid):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: None},
|
||||
blocking=True,
|
||||
|
@ -369,14 +369,14 @@ async def test_set_target_humidity(hass: HomeAssistant) -> None:
|
|||
async def test_set_away_mode(hass: HomeAssistant) -> None:
|
||||
"""Test the setting away mode."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 44},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_MODE: MODE_AWAY},
|
||||
blocking=True,
|
||||
|
@ -393,14 +393,14 @@ async def test_set_away_mode_and_restore_prev_humidity(hass: HomeAssistant) -> N
|
|||
Verify original humidity is restored.
|
||||
"""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 44},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_MODE: MODE_AWAY},
|
||||
blocking=True,
|
||||
|
@ -409,7 +409,7 @@ async def test_set_away_mode_and_restore_prev_humidity(hass: HomeAssistant) -> N
|
|||
state = hass.states.get(ENTITY)
|
||||
assert state.attributes.get("humidity") == 35
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_MODE: MODE_NORMAL},
|
||||
blocking=True,
|
||||
|
@ -428,21 +428,21 @@ async def test_set_away_mode_twice_and_restore_prev_humidity(
|
|||
Verify original humidity is restored.
|
||||
"""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 44},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_MODE: MODE_AWAY},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_MODE: MODE_AWAY},
|
||||
blocking=True,
|
||||
|
@ -451,7 +451,7 @@ async def test_set_away_mode_twice_and_restore_prev_humidity(
|
|||
state = hass.states.get(ENTITY)
|
||||
assert state.attributes.get("humidity") == 35
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_MODE: MODE_NORMAL},
|
||||
blocking=True,
|
||||
|
@ -523,7 +523,7 @@ async def test_set_target_humidity_humidifier_on(hass: HomeAssistant) -> None:
|
|||
await hass.async_block_till_done()
|
||||
calls.clear()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 45},
|
||||
blocking=True,
|
||||
|
@ -544,7 +544,7 @@ async def test_set_target_humidity_humidifier_off(hass: HomeAssistant) -> None:
|
|||
await hass.async_block_till_done()
|
||||
calls.clear()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 36},
|
||||
blocking=True,
|
||||
|
@ -564,7 +564,7 @@ async def test_humidity_change_humidifier_on_within_tolerance(
|
|||
"""Test if humidity change doesn't turn on within tolerance."""
|
||||
calls = await _setup_switch(hass, False)
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 44},
|
||||
blocking=True,
|
||||
|
@ -582,7 +582,7 @@ async def test_humidity_change_humidifier_on_outside_tolerance(
|
|||
"""Test if humidity change turn humidifier on outside dry tolerance."""
|
||||
calls = await _setup_switch(hass, False)
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 44},
|
||||
blocking=True,
|
||||
|
@ -604,7 +604,7 @@ async def test_humidity_change_humidifier_off_within_tolerance(
|
|||
"""Test if humidity change doesn't turn off within tolerance."""
|
||||
calls = await _setup_switch(hass, True)
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 46},
|
||||
blocking=True,
|
||||
|
@ -622,7 +622,7 @@ async def test_humidity_change_humidifier_off_outside_tolerance(
|
|||
"""Test if humidity change turn humidifier off outside wet tolerance."""
|
||||
calls = await _setup_switch(hass, True)
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 46},
|
||||
blocking=True,
|
||||
|
@ -644,14 +644,14 @@ async def test_operation_mode_humidify(hass: HomeAssistant) -> None:
|
|||
Switch turns on when humidity below setpoint and mode changes.
|
||||
"""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 45},
|
||||
blocking=True,
|
||||
|
@ -661,7 +661,7 @@ async def test_operation_mode_humidify(hass: HomeAssistant) -> None:
|
|||
await hass.async_block_till_done()
|
||||
calls = await _setup_switch(hass, False)
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY},
|
||||
blocking=True,
|
||||
|
@ -696,7 +696,7 @@ async def setup_comp_3(hass: HomeAssistant) -> None:
|
|||
"""Initialize components."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -722,7 +722,7 @@ async def test_set_target_humidity_dry_off(hass: HomeAssistant) -> None:
|
|||
_setup_sensor(hass, 50)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 55},
|
||||
blocking=True,
|
||||
|
@ -743,14 +743,14 @@ async def test_turn_away_mode_on_drying(hass: HomeAssistant) -> None:
|
|||
_setup_sensor(hass, 50)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 34},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_MODE: MODE_AWAY},
|
||||
blocking=True,
|
||||
|
@ -771,7 +771,7 @@ async def test_operation_mode_dry(hass: HomeAssistant) -> None:
|
|||
await hass.async_block_till_done()
|
||||
assert len(calls) == 0
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY},
|
||||
blocking=True,
|
||||
|
@ -781,7 +781,7 @@ async def test_operation_mode_dry(hass: HomeAssistant) -> None:
|
|||
await hass.async_block_till_done()
|
||||
assert len(calls) == 0
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY},
|
||||
blocking=True,
|
||||
|
@ -875,7 +875,7 @@ async def test_running_when_operating_mode_is_off_2(hass: HomeAssistant) -> None
|
|||
_setup_sensor(hass, 45)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY},
|
||||
blocking=True,
|
||||
|
@ -896,7 +896,7 @@ async def test_no_state_change_when_operation_mode_off_2(hass: HomeAssistant) ->
|
|||
_setup_sensor(hass, 30)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY},
|
||||
blocking=True,
|
||||
|
@ -913,7 +913,7 @@ async def setup_comp_4(hass: HomeAssistant) -> None:
|
|||
"""Initialize components."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -1008,7 +1008,7 @@ async def test_mode_change_dry_trigger_off_not_long_enough(hass: HomeAssistant)
|
|||
await hass.async_block_till_done()
|
||||
assert len(calls) == 0
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY},
|
||||
blocking=True,
|
||||
|
@ -1028,7 +1028,7 @@ async def test_mode_change_dry_trigger_on_not_long_enough(hass: HomeAssistant) -
|
|||
_setup_sensor(hass, 35)
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY},
|
||||
blocking=True,
|
||||
|
@ -1038,7 +1038,7 @@ async def test_mode_change_dry_trigger_on_not_long_enough(hass: HomeAssistant) -
|
|||
await hass.async_block_till_done()
|
||||
assert len(calls) == 0
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY},
|
||||
blocking=True,
|
||||
|
@ -1056,7 +1056,7 @@ async def setup_comp_6(hass: HomeAssistant) -> None:
|
|||
"""Initialize components."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -1157,7 +1157,7 @@ async def test_mode_change_humidifier_trigger_off_not_long_enough(
|
|||
assert len(calls) == 0
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY},
|
||||
blocking=True,
|
||||
|
@ -1181,7 +1181,7 @@ async def test_mode_change_humidifier_trigger_on_not_long_enough(
|
|||
assert len(calls) == 0
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY},
|
||||
blocking=True,
|
||||
|
@ -1194,7 +1194,7 @@ async def test_mode_change_humidifier_trigger_on_not_long_enough(
|
|||
assert len(calls) == 0
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY},
|
||||
blocking=True,
|
||||
|
@ -1212,7 +1212,7 @@ async def setup_comp_7(hass: HomeAssistant) -> None:
|
|||
"""Initialize components."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -1279,7 +1279,7 @@ async def setup_comp_8(hass: HomeAssistant) -> None:
|
|||
"""Initialize components."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -1344,7 +1344,7 @@ async def test_float_tolerance_values(hass: HomeAssistant) -> None:
|
|||
"""Test if dehumidifier does not turn on within floating point tolerance."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -1370,7 +1370,7 @@ async def test_float_tolerance_values_2(hass: HomeAssistant) -> None:
|
|||
"""Test if dehumidifier turns off when oudside of floating point tolerance values."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -1401,7 +1401,7 @@ async def test_custom_setup_params(hass: HomeAssistant) -> None:
|
|||
await hass.async_block_till_done()
|
||||
result = await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -1441,7 +1441,7 @@ async def test_restore_state(hass: HomeAssistant) -> None:
|
|||
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -1479,7 +1479,7 @@ async def test_restore_state_target_humidity(hass: HomeAssistant) -> None:
|
|||
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -1522,7 +1522,7 @@ async def test_restore_state_and_return_to_normal(hass: HomeAssistant) -> None:
|
|||
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -1542,7 +1542,7 @@ async def test_restore_state_and_return_to_normal(hass: HomeAssistant) -> None:
|
|||
assert state.state == STATE_OFF
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_MODE,
|
||||
{ATTR_ENTITY_ID: "humidifier.test_hygrostat", ATTR_MODE: MODE_NORMAL},
|
||||
blocking=True,
|
||||
|
@ -1577,7 +1577,7 @@ async def test_no_restore_state(hass: HomeAssistant) -> None:
|
|||
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -1623,7 +1623,7 @@ async def test_restore_state_uncoherence_case(hass: HomeAssistant) -> None:
|
|||
async def _setup_humidifier(hass: HomeAssistant) -> None:
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -1665,7 +1665,7 @@ async def test_away_fixed_humidity_mode(hass: HomeAssistant) -> None:
|
|||
await hass.async_block_till_done()
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -1687,7 +1687,7 @@ async def test_away_fixed_humidity_mode(hass: HomeAssistant) -> None:
|
|||
|
||||
# Switch to Away mode
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_MODE,
|
||||
{ATTR_ENTITY_ID: "humidifier.test_hygrostat", ATTR_MODE: MODE_AWAY},
|
||||
blocking=True,
|
||||
|
@ -1703,7 +1703,7 @@ async def test_away_fixed_humidity_mode(hass: HomeAssistant) -> None:
|
|||
|
||||
# Change target humidity
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: "humidifier.test_hygrostat", ATTR_HUMIDITY: 42},
|
||||
blocking=True,
|
||||
|
@ -1719,7 +1719,7 @@ async def test_away_fixed_humidity_mode(hass: HomeAssistant) -> None:
|
|||
|
||||
# Return to Normal mode
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_MODE,
|
||||
{ATTR_ENTITY_ID: "humidifier.test_hygrostat", ATTR_MODE: MODE_NORMAL},
|
||||
blocking=True,
|
||||
|
@ -1750,7 +1750,7 @@ async def test_sensor_stale_duration(
|
|||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
{
|
||||
"humidifier": {
|
||||
"platform": "generic_hygrostat",
|
||||
|
@ -1770,7 +1770,7 @@ async def test_sensor_stale_duration(
|
|||
assert hass.states.get(humidifier_switch).state == STATE_OFF
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_SET_HUMIDITY,
|
||||
{ATTR_ENTITY_ID: ENTITY, ATTR_HUMIDITY: 32},
|
||||
blocking=True,
|
||||
|
@ -1813,7 +1813,7 @@ async def test_sensor_stale_duration(
|
|||
|
||||
# Manual turn off
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
HUMIDIFIER_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY},
|
||||
blocking=True,
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant import config as hass_config
|
|||
from homeassistant.components import input_boolean, switch
|
||||
from homeassistant.components.climate import (
|
||||
ATTR_PRESET_MODE,
|
||||
DOMAIN,
|
||||
DOMAIN as CLIMATE_DOMAIN,
|
||||
PRESET_ACTIVITY,
|
||||
PRESET_AWAY,
|
||||
PRESET_COMFORT,
|
||||
|
@ -122,7 +122,7 @@ async def test_heater_input_boolean(hass: HomeAssistant) -> None:
|
|||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -160,7 +160,7 @@ async def test_heater_switch(
|
|||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -192,7 +192,7 @@ async def test_unique_id(
|
|||
_setup_switch(hass, True)
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -221,7 +221,7 @@ async def setup_comp_2(hass: HomeAssistant) -> None:
|
|||
hass.config.units = METRIC_SYSTEM
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -248,7 +248,7 @@ async def test_setup_defaults_to_unknown(hass: HomeAssistant) -> None:
|
|||
hass.config.units = METRIC_SYSTEM
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -272,7 +272,7 @@ async def test_setup_gets_current_temp_from_sensor(hass: HomeAssistant) -> None:
|
|||
await hass.async_block_till_done()
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -618,7 +618,7 @@ async def setup_comp_3(hass: HomeAssistant) -> None:
|
|||
hass.config.temperature_unit = UnitOfTemperature.CELSIUS
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -774,7 +774,7 @@ async def _setup_thermostat_with_min_cycle_duration(
|
|||
hass.config.temperature_unit = UnitOfTemperature.CELSIUS
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -927,7 +927,7 @@ async def setup_comp_7(hass: HomeAssistant) -> None:
|
|||
hass.config.temperature_unit = UnitOfTemperature.CELSIUS
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -1002,7 +1002,7 @@ async def setup_comp_8(hass: HomeAssistant) -> None:
|
|||
hass.config.temperature_unit = UnitOfTemperature.CELSIUS
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -1076,7 +1076,7 @@ async def setup_comp_9(hass: HomeAssistant) -> None:
|
|||
"""Initialize components."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -1110,7 +1110,7 @@ async def test_custom_setup_params(hass: HomeAssistant) -> None:
|
|||
"""Test the setup with custom parameters."""
|
||||
result = await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -1151,7 +1151,7 @@ async def test_restore_state(hass: HomeAssistant, hvac_mode) -> None:
|
|||
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -1189,7 +1189,7 @@ async def test_no_restore_state(hass: HomeAssistant) -> None:
|
|||
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -1220,7 +1220,7 @@ async def test_initial_hvac_off_force_heater_off(hass: HomeAssistant) -> None:
|
|||
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -1274,7 +1274,7 @@ async def test_restore_will_turn_off_(hass: HomeAssistant) -> None:
|
|||
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -1319,7 +1319,7 @@ async def test_restore_will_turn_off_when_loaded_second(hass: HomeAssistant) ->
|
|||
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -1379,7 +1379,7 @@ async def test_restore_state_uncoherence_case(hass: HomeAssistant) -> None:
|
|||
async def _setup_climate(hass: HomeAssistant) -> None:
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
@ -1415,7 +1415,7 @@ async def test_reload(hass: HomeAssistant) -> None:
|
|||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Switch tests for the Goalzero integration."""
|
||||
|
||||
from homeassistant.components.goalzero.const import DEFAULT_NAME
|
||||
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,7 +32,7 @@ async def test_switches_states(
|
|||
text=load_fixture("goalzero/state_change.json"),
|
||||
)
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: [entity_id]},
|
||||
blocking=True,
|
||||
|
@ -44,7 +44,7 @@ async def test_switches_states(
|
|||
text=load_fixture("goalzero/state_data.json"),
|
||||
)
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: [entity_id]},
|
||||
blocking=True,
|
||||
|
|
|
@ -5,7 +5,7 @@ from datetime import timedelta
|
|||
from freezegun.api import FrozenDateTimeFactory
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.climate import DOMAIN, HVACMode
|
||||
from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN, HVACMode
|
||||
from homeassistant.components.gree.const import (
|
||||
COORDINATORS,
|
||||
DOMAIN as GREE,
|
||||
|
@ -18,8 +18,8 @@ from .common import async_setup_gree, build_device_mock
|
|||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
ENTITY_ID_1 = f"{DOMAIN}.fake_device_1"
|
||||
ENTITY_ID_2 = f"{DOMAIN}.fake_device_2"
|
||||
ENTITY_ID_1 = f"{CLIMATE_DOMAIN}.fake_device_1"
|
||||
ENTITY_ID_2 = f"{CLIMATE_DOMAIN}.fake_device_2"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -46,7 +46,7 @@ async def test_discovery_after_setup(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
assert discovery.return_value.scan_count == 1
|
||||
assert len(hass.states.async_all(DOMAIN)) == 2
|
||||
assert len(hass.states.async_all(CLIMATE_DOMAIN)) == 2
|
||||
|
||||
device_infos = [x.device.device_info for x in hass.data[GREE][COORDINATORS]]
|
||||
assert device_infos[0].ip == "1.1.1.1"
|
||||
|
@ -68,7 +68,7 @@ async def test_discovery_after_setup(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
assert discovery.return_value.scan_count == 2
|
||||
assert len(hass.states.async_all(DOMAIN)) == 2
|
||||
assert len(hass.states.async_all(CLIMATE_DOMAIN)) == 2
|
||||
|
||||
device_infos = [x.device.device_info for x in hass.data[GREE][COORDINATORS]]
|
||||
assert device_infos[0].ip == "1.1.1.2"
|
||||
|
@ -82,7 +82,7 @@ async def test_coordinator_updates(
|
|||
await async_setup_gree(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(hass.states.async_all(DOMAIN)) == 1
|
||||
assert len(hass.states.async_all(CLIMATE_DOMAIN)) == 1
|
||||
|
||||
callback = device().add_handler.call_args_list[0][0][1]
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ from homeassistant.components.climate import (
|
|||
ATTR_HVAC_MODE,
|
||||
ATTR_PRESET_MODE,
|
||||
ATTR_SWING_MODE,
|
||||
DOMAIN,
|
||||
DOMAIN as CLIMATE_DOMAIN,
|
||||
FAN_AUTO,
|
||||
FAN_HIGH,
|
||||
FAN_LOW,
|
||||
|
@ -71,7 +71,7 @@ from .common import async_setup_gree, build_device_mock
|
|||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
ENTITY_ID = f"{DOMAIN}.fake_device_1"
|
||||
ENTITY_ID = f"{CLIMATE_DOMAIN}.fake_device_1"
|
||||
|
||||
|
||||
async def test_discovery_called_once(hass: HomeAssistant, discovery, device) -> None:
|
||||
|
@ -98,7 +98,7 @@ async def test_discovery_setup(hass: HomeAssistant, discovery, device) -> None:
|
|||
await async_setup_gree(hass)
|
||||
await hass.async_block_till_done()
|
||||
assert discovery.call_count == 1
|
||||
assert len(hass.states.async_all(DOMAIN)) == 2
|
||||
assert len(hass.states.async_all(CLIMATE_DOMAIN)) == 2
|
||||
|
||||
|
||||
async def test_discovery_setup_connection_error(
|
||||
|
@ -117,7 +117,7 @@ async def test_discovery_setup_connection_error(
|
|||
await async_setup_gree(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(hass.states.async_all(DOMAIN)) == 1
|
||||
assert len(hass.states.async_all(CLIMATE_DOMAIN)) == 1
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state.name == "fake-device-1"
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
@ -143,7 +143,7 @@ async def test_discovery_after_setup(
|
|||
await async_setup_gree(hass) # Update 1
|
||||
|
||||
assert discovery.return_value.scan_count == 1
|
||||
assert len(hass.states.async_all(DOMAIN)) == 2
|
||||
assert len(hass.states.async_all(CLIMATE_DOMAIN)) == 2
|
||||
|
||||
# rediscover the same devices shouldn't change anything
|
||||
discovery.return_value.mock_devices = [MockDevice1, MockDevice2]
|
||||
|
@ -154,7 +154,7 @@ async def test_discovery_after_setup(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
assert discovery.return_value.scan_count == 2
|
||||
assert len(hass.states.async_all(DOMAIN)) == 2
|
||||
assert len(hass.states.async_all(CLIMATE_DOMAIN)) == 2
|
||||
|
||||
|
||||
async def test_discovery_add_device_after_setup(
|
||||
|
@ -180,7 +180,7 @@ async def test_discovery_add_device_after_setup(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
assert discovery.return_value.scan_count == 1
|
||||
assert len(hass.states.async_all(DOMAIN)) == 1
|
||||
assert len(hass.states.async_all(CLIMATE_DOMAIN)) == 1
|
||||
|
||||
# rediscover the same devices shouldn't change anything
|
||||
discovery.return_value.mock_devices = [MockDevice2]
|
||||
|
@ -191,7 +191,7 @@ async def test_discovery_add_device_after_setup(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
assert discovery.return_value.scan_count == 2
|
||||
assert len(hass.states.async_all(DOMAIN)) == 2
|
||||
assert len(hass.states.async_all(CLIMATE_DOMAIN)) == 2
|
||||
|
||||
|
||||
async def test_discovery_device_bind_after_setup(
|
||||
|
@ -209,7 +209,7 @@ async def test_discovery_device_bind_after_setup(
|
|||
|
||||
await async_setup_gree(hass) # Update 1
|
||||
|
||||
assert len(hass.states.async_all(DOMAIN)) == 1
|
||||
assert len(hass.states.async_all(CLIMATE_DOMAIN)) == 1
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state.name == "fake-device-1"
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
@ -328,7 +328,7 @@ async def test_send_command_device_timeout(
|
|||
|
||||
# Send failure should not raise exceptions or change device state
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID},
|
||||
blocking=True,
|
||||
|
@ -377,7 +377,7 @@ async def test_send_power_on(hass: HomeAssistant, discovery, device) -> None:
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID},
|
||||
blocking=True,
|
||||
|
@ -397,7 +397,7 @@ async def test_send_power_off_device_timeout(
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID},
|
||||
blocking=True,
|
||||
|
@ -439,7 +439,7 @@ async def test_send_target_temperature(
|
|||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_TEMPERATURE: temperature},
|
||||
blocking=True,
|
||||
|
@ -473,7 +473,7 @@ async def test_send_target_temperature_with_hvac_mode(
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: ENTITY_ID,
|
||||
|
@ -509,7 +509,7 @@ async def test_send_target_temperature_device_timeout(
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_TEMPERATURE: temperature},
|
||||
blocking=True,
|
||||
|
@ -543,7 +543,7 @@ async def test_update_target_temperature(
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_TEMPERATURE: temperature},
|
||||
blocking=True,
|
||||
|
@ -565,7 +565,7 @@ async def test_send_preset_mode(hass: HomeAssistant, discovery, device, preset)
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_PRESET_MODE: preset},
|
||||
blocking=True,
|
||||
|
@ -582,7 +582,7 @@ async def test_send_invalid_preset_mode(hass: HomeAssistant, discovery, device)
|
|||
|
||||
with pytest.raises(ServiceValidationError):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_PRESET_MODE: "invalid"},
|
||||
blocking=True,
|
||||
|
@ -605,7 +605,7 @@ async def test_send_preset_mode_device_timeout(
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_PRESET_MODE: preset},
|
||||
blocking=True,
|
||||
|
@ -653,7 +653,7 @@ async def test_send_hvac_mode(
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_HVAC_MODE: hvac_mode},
|
||||
blocking=True,
|
||||
|
@ -677,7 +677,7 @@ async def test_send_hvac_mode_device_timeout(
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_HVAC_MODE: hvac_mode},
|
||||
blocking=True,
|
||||
|
@ -722,7 +722,7 @@ async def test_send_fan_mode(hass: HomeAssistant, discovery, device, fan_mode) -
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_FAN_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_FAN_MODE: fan_mode},
|
||||
blocking=True,
|
||||
|
@ -739,7 +739,7 @@ async def test_send_invalid_fan_mode(hass: HomeAssistant, discovery, device) ->
|
|||
|
||||
with pytest.raises(ServiceValidationError):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_FAN_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_FAN_MODE: "invalid"},
|
||||
blocking=True,
|
||||
|
@ -763,7 +763,7 @@ async def test_send_fan_mode_device_timeout(
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_FAN_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_FAN_MODE: fan_mode},
|
||||
blocking=True,
|
||||
|
@ -801,7 +801,7 @@ async def test_send_swing_mode(
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_SWING_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_SWING_MODE: swing_mode},
|
||||
blocking=True,
|
||||
|
@ -818,7 +818,7 @@ async def test_send_invalid_swing_mode(hass: HomeAssistant, discovery, device) -
|
|||
|
||||
with pytest.raises(ServiceValidationError):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_SWING_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_SWING_MODE: "invalid"},
|
||||
blocking=True,
|
||||
|
@ -841,7 +841,7 @@ async def test_send_swing_mode_device_timeout(
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_SWING_MODE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_SWING_MODE: swing_mode},
|
||||
blocking=True,
|
||||
|
@ -884,7 +884,7 @@ async def test_coordinator_update_handler(
|
|||
await async_setup_gree(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entity: GreeClimateEntity = hass.data[DOMAIN].get_entity(ENTITY_ID)
|
||||
entity: GreeClimateEntity = hass.data[CLIMATE_DOMAIN].get_entity(ENTITY_ID)
|
||||
assert entity is not None
|
||||
|
||||
# Initial state
|
||||
|
@ -911,7 +911,7 @@ async def test_coordinator_update_handler(
|
|||
assert entity.max_temp == TEMP_MAX
|
||||
|
||||
|
||||
@patch("homeassistant.components.gree.PLATFORMS", [DOMAIN])
|
||||
@patch("homeassistant.components.gree.PLATFORMS", [CLIMATE_DOMAIN])
|
||||
async def test_registry_settings(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, snapshot: SnapshotAssertion
|
||||
) -> None:
|
||||
|
@ -922,7 +922,7 @@ async def test_registry_settings(
|
|||
assert entries == snapshot
|
||||
|
||||
|
||||
@patch("homeassistant.components.gree.PLATFORMS", [DOMAIN])
|
||||
@patch("homeassistant.components.gree.PLATFORMS", [CLIMATE_DOMAIN])
|
||||
async def test_entity_states(hass: HomeAssistant, snapshot: SnapshotAssertion) -> None:
|
||||
"""Test for entity registry settings (unique_id)."""
|
||||
await async_setup_gree(hass)
|
||||
|
|
|
@ -7,7 +7,7 @@ import pytest
|
|||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.gree.const import DOMAIN as GREE_DOMAIN
|
||||
from homeassistant.components.switch import DOMAIN
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
SERVICE_TOGGLE,
|
||||
|
@ -22,23 +22,23 @@ from homeassistant.setup import async_setup_component
|
|||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
ENTITY_ID_LIGHT_PANEL = f"{DOMAIN}.fake_device_1_panel_light"
|
||||
ENTITY_ID_HEALTH_MODE = f"{DOMAIN}.fake_device_1_health_mode"
|
||||
ENTITY_ID_QUIET = f"{DOMAIN}.fake_device_1_quiet"
|
||||
ENTITY_ID_FRESH_AIR = f"{DOMAIN}.fake_device_1_fresh_air"
|
||||
ENTITY_ID_XFAN = f"{DOMAIN}.fake_device_1_xfan"
|
||||
ENTITY_ID_LIGHT_PANEL = f"{SWITCH_DOMAIN}.fake_device_1_panel_light"
|
||||
ENTITY_ID_HEALTH_MODE = f"{SWITCH_DOMAIN}.fake_device_1_health_mode"
|
||||
ENTITY_ID_QUIET = f"{SWITCH_DOMAIN}.fake_device_1_quiet"
|
||||
ENTITY_ID_FRESH_AIR = f"{SWITCH_DOMAIN}.fake_device_1_fresh_air"
|
||||
ENTITY_ID_XFAN = f"{SWITCH_DOMAIN}.fake_device_1_xfan"
|
||||
|
||||
|
||||
async def async_setup_gree(hass: HomeAssistant) -> MockConfigEntry:
|
||||
"""Set up the gree switch platform."""
|
||||
entry = MockConfigEntry(domain=GREE_DOMAIN)
|
||||
entry.add_to_hass(hass)
|
||||
await async_setup_component(hass, GREE_DOMAIN, {GREE_DOMAIN: {DOMAIN: {}}})
|
||||
await async_setup_component(hass, GREE_DOMAIN, {GREE_DOMAIN: {SWITCH_DOMAIN: {}}})
|
||||
await hass.async_block_till_done()
|
||||
return entry
|
||||
|
||||
|
||||
@patch("homeassistant.components.gree.PLATFORMS", [DOMAIN])
|
||||
@patch("homeassistant.components.gree.PLATFORMS", [SWITCH_DOMAIN])
|
||||
async def test_registry_settings(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
|
@ -67,7 +67,7 @@ async def test_send_switch_on(hass: HomeAssistant, entity: str) -> None:
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: entity},
|
||||
blocking=True,
|
||||
|
@ -98,7 +98,7 @@ async def test_send_switch_on_device_timeout(
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: entity},
|
||||
blocking=True,
|
||||
|
@ -125,7 +125,7 @@ async def test_send_switch_off(hass: HomeAssistant, entity: str) -> None:
|
|||
await async_setup_gree(hass)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{ATTR_ENTITY_ID: entity},
|
||||
blocking=True,
|
||||
|
@ -153,7 +153,7 @@ async def test_send_switch_toggle(hass: HomeAssistant, entity: str) -> None:
|
|||
|
||||
# Turn the service on first
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: entity},
|
||||
blocking=True,
|
||||
|
@ -165,7 +165,7 @@ async def test_send_switch_toggle(hass: HomeAssistant, entity: str) -> None:
|
|||
|
||||
# Toggle it off
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TOGGLE,
|
||||
{ATTR_ENTITY_ID: entity},
|
||||
blocking=True,
|
||||
|
@ -177,7 +177,7 @@ async def test_send_switch_toggle(hass: HomeAssistant, entity: str) -> None:
|
|||
|
||||
# Toggle is back on
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TOGGLE,
|
||||
{ATTR_ENTITY_ID: entity},
|
||||
blocking=True,
|
||||
|
@ -197,5 +197,5 @@ async def test_entity_state(
|
|||
"""Test for entity registry settings (disabled_by, unique_id)."""
|
||||
await async_setup_gree(hass)
|
||||
|
||||
state = hass.states.async_all(DOMAIN)
|
||||
state = hass.states.async_all(SWITCH_DOMAIN)
|
||||
assert state == snapshot
|
||||
|
|
|
@ -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.components.group.cover import DEFAULT_NAME
|
||||
from homeassistant.const import (
|
||||
|
@ -52,7 +52,7 @@ DEMO_COVER_TILT = "cover.living_room_window"
|
|||
DEMO_TILT = "cover.tilt_demo"
|
||||
|
||||
CONFIG_ALL = {
|
||||
DOMAIN: [
|
||||
COVER_DOMAIN: [
|
||||
{"platform": "demo"},
|
||||
{
|
||||
"platform": "group",
|
||||
|
@ -62,7 +62,7 @@ CONFIG_ALL = {
|
|||
}
|
||||
|
||||
CONFIG_POS = {
|
||||
DOMAIN: [
|
||||
COVER_DOMAIN: [
|
||||
{"platform": "demo"},
|
||||
{
|
||||
"platform": "group",
|
||||
|
@ -72,7 +72,7 @@ CONFIG_POS = {
|
|||
}
|
||||
|
||||
CONFIG_TILT_ONLY = {
|
||||
DOMAIN: [
|
||||
COVER_DOMAIN: [
|
||||
{"platform": "demo"},
|
||||
{
|
||||
"platform": "group",
|
||||
|
@ -82,7 +82,7 @@ CONFIG_TILT_ONLY = {
|
|||
}
|
||||
|
||||
CONFIG_ATTRIBUTES = {
|
||||
DOMAIN: {
|
||||
COVER_DOMAIN: {
|
||||
"platform": "group",
|
||||
CONF_ENTITIES: [DEMO_COVER, DEMO_COVER_POS, DEMO_COVER_TILT, DEMO_TILT],
|
||||
CONF_UNIQUE_ID: "unique_identifier",
|
||||
|
@ -96,8 +96,8 @@ async def setup_comp(
|
|||
) -> None:
|
||||
"""Set up group cover component."""
|
||||
config, count = config_count
|
||||
with assert_setup_component(count, DOMAIN):
|
||||
await async_setup_component(hass, DOMAIN, config)
|
||||
with assert_setup_component(count, COVER_DOMAIN):
|
||||
await async_setup_component(hass, COVER_DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_start()
|
||||
await hass.async_block_till_done()
|
||||
|
@ -454,7 +454,7 @@ async def test_cover_that_only_supports_tilt_removed(hass: HomeAssistant) -> Non
|
|||
async def test_open_covers(hass: HomeAssistant) -> None:
|
||||
"""Test open cover function."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
)
|
||||
|
||||
for _ in range(10):
|
||||
|
@ -476,7 +476,7 @@ async def test_open_covers(hass: HomeAssistant) -> None:
|
|||
async def test_close_covers(hass: HomeAssistant) -> None:
|
||||
"""Test close cover function."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
)
|
||||
|
||||
for _ in range(10):
|
||||
|
@ -499,7 +499,7 @@ async def test_toggle_covers(hass: HomeAssistant) -> None:
|
|||
"""Test toggle cover function."""
|
||||
# Start covers in open state
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
)
|
||||
for _ in range(10):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -511,7 +511,7 @@ async def test_toggle_covers(hass: HomeAssistant) -> None:
|
|||
|
||||
# Toggle will close covers
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
)
|
||||
for _ in range(10):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -528,7 +528,7 @@ async def test_toggle_covers(hass: HomeAssistant) -> None:
|
|||
|
||||
# Toggle again will open covers
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
)
|
||||
for _ in range(10):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -549,14 +549,14 @@ async def test_toggle_covers(hass: HomeAssistant) -> None:
|
|||
async def test_stop_covers(hass: HomeAssistant) -> None:
|
||||
"""Test stop cover function."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, 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: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_STOP_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
)
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
async_fire_time_changed(hass, future)
|
||||
|
@ -576,7 +576,7 @@ async def test_stop_covers(hass: HomeAssistant) -> None:
|
|||
async def test_set_cover_position(hass: HomeAssistant) -> None:
|
||||
"""Test set cover position function."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
COVER_DOMAIN,
|
||||
SERVICE_SET_COVER_POSITION,
|
||||
{ATTR_ENTITY_ID: COVER_GROUP, ATTR_POSITION: 50},
|
||||
blocking=True,
|
||||
|
@ -600,7 +600,10 @@ async def test_set_cover_position(hass: HomeAssistant) -> None:
|
|||
async def test_open_tilts(hass: HomeAssistant) -> None:
|
||||
"""Test open tilt function."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER_TILT, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN,
|
||||
SERVICE_OPEN_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: COVER_GROUP},
|
||||
blocking=True,
|
||||
)
|
||||
for _ in range(5):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -621,7 +624,10 @@ async def test_open_tilts(hass: HomeAssistant) -> None:
|
|||
async def test_close_tilts(hass: HomeAssistant) -> None:
|
||||
"""Test close tilt function."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_CLOSE_COVER_TILT, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN,
|
||||
SERVICE_CLOSE_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: COVER_GROUP},
|
||||
blocking=True,
|
||||
)
|
||||
for _ in range(5):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -641,7 +647,10 @@ async def test_toggle_tilts(hass: HomeAssistant) -> None:
|
|||
"""Test toggle tilt function."""
|
||||
# Start tilted open
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER_TILT, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN,
|
||||
SERVICE_OPEN_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: COVER_GROUP},
|
||||
blocking=True,
|
||||
)
|
||||
for _ in range(10):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -658,7 +667,10 @@ async def test_toggle_tilts(hass: HomeAssistant) -> None:
|
|||
|
||||
# Toggle will tilt closed
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE_COVER_TILT, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN,
|
||||
SERVICE_TOGGLE_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: COVER_GROUP},
|
||||
blocking=True,
|
||||
)
|
||||
for _ in range(10):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -673,7 +685,10 @@ async def test_toggle_tilts(hass: HomeAssistant) -> None:
|
|||
|
||||
# Toggle again will tilt open
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE_COVER_TILT, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN,
|
||||
SERVICE_TOGGLE_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: COVER_GROUP},
|
||||
blocking=True,
|
||||
)
|
||||
for _ in range(10):
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
|
@ -694,14 +709,20 @@ async def test_toggle_tilts(hass: HomeAssistant) -> None:
|
|||
async def test_stop_tilts(hass: HomeAssistant) -> None:
|
||||
"""Test stop tilts function."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER_TILT, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN,
|
||||
SERVICE_OPEN_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: COVER_GROUP},
|
||||
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: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN,
|
||||
SERVICE_STOP_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: COVER_GROUP},
|
||||
blocking=True,
|
||||
)
|
||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||
async_fire_time_changed(hass, future)
|
||||
|
@ -719,7 +740,7 @@ async def test_stop_tilts(hass: HomeAssistant) -> None:
|
|||
async def test_set_tilt_positions(hass: HomeAssistant) -> None:
|
||||
"""Test set tilt position function."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
COVER_DOMAIN,
|
||||
SERVICE_SET_COVER_TILT_POSITION,
|
||||
{ATTR_ENTITY_ID: COVER_GROUP, ATTR_TILT_POSITION: 80},
|
||||
blocking=True,
|
||||
|
@ -741,7 +762,7 @@ async def test_set_tilt_positions(hass: HomeAssistant) -> None:
|
|||
async def test_is_opening_closing(hass: HomeAssistant) -> None:
|
||||
"""Test is_opening property."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -756,7 +777,7 @@ async def test_is_opening_closing(hass: HomeAssistant) -> None:
|
|||
await hass.async_block_till_done()
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
COVER_DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
|
||||
)
|
||||
|
||||
# Both covers closing -> closing
|
||||
|
@ -814,9 +835,9 @@ async def test_nested_group(hass: HomeAssistant) -> None:
|
|||
"""Test nested cover group."""
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
COVER_DOMAIN,
|
||||
{
|
||||
DOMAIN: [
|
||||
COVER_DOMAIN: [
|
||||
{"platform": "demo"},
|
||||
{
|
||||
"platform": "group",
|
||||
|
@ -848,7 +869,7 @@ async def test_nested_group(hass: HomeAssistant) -> None:
|
|||
# Test controlling the nested group
|
||||
async with asyncio.timeout(0.5):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
COVER_DOMAIN,
|
||||
SERVICE_CLOSE_COVER,
|
||||
{ATTR_ENTITY_ID: "cover.nested_group"},
|
||||
blocking=True,
|
||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.components.fan import (
|
|||
ATTR_PERCENTAGE_STEP,
|
||||
DIRECTION_FORWARD,
|
||||
DIRECTION_REVERSE,
|
||||
DOMAIN,
|
||||
DOMAIN as FAN_DOMAIN,
|
||||
SERVICE_OSCILLATE,
|
||||
SERVICE_SET_DIRECTION,
|
||||
SERVICE_SET_PERCENTAGE,
|
||||
|
@ -60,7 +60,7 @@ FULL_SUPPORT_FEATURES = (
|
|||
|
||||
|
||||
CONFIG_MISSING_FAN = {
|
||||
DOMAIN: [
|
||||
FAN_DOMAIN: [
|
||||
{"platform": "demo"},
|
||||
{
|
||||
"platform": "group",
|
||||
|
@ -74,7 +74,7 @@ CONFIG_MISSING_FAN = {
|
|||
}
|
||||
|
||||
CONFIG_FULL_SUPPORT = {
|
||||
DOMAIN: [
|
||||
FAN_DOMAIN: [
|
||||
{"platform": "demo"},
|
||||
{
|
||||
"platform": "group",
|
||||
|
@ -84,7 +84,7 @@ CONFIG_FULL_SUPPORT = {
|
|||
}
|
||||
|
||||
CONFIG_LIMITED_SUPPORT = {
|
||||
DOMAIN: [
|
||||
FAN_DOMAIN: [
|
||||
{
|
||||
"platform": "group",
|
||||
CONF_ENTITIES: [*LIMITED_FAN_ENTITY_IDS],
|
||||
|
@ -94,7 +94,7 @@ CONFIG_LIMITED_SUPPORT = {
|
|||
|
||||
|
||||
CONFIG_ATTRIBUTES = {
|
||||
DOMAIN: {
|
||||
FAN_DOMAIN: {
|
||||
"platform": "group",
|
||||
CONF_ENTITIES: [*FULL_FAN_ENTITY_IDS, *LIMITED_FAN_ENTITY_IDS],
|
||||
CONF_UNIQUE_ID: "unique_identifier",
|
||||
|
@ -108,8 +108,8 @@ async def setup_comp(
|
|||
) -> None:
|
||||
"""Set up group fan component."""
|
||||
config, count = config_count
|
||||
with assert_setup_component(count, DOMAIN):
|
||||
await async_setup_component(hass, DOMAIN, config)
|
||||
with assert_setup_component(count, FAN_DOMAIN):
|
||||
await async_setup_component(hass, FAN_DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_start()
|
||||
await hass.async_block_till_done()
|
||||
|
@ -393,7 +393,7 @@ async def test_state_missing_entity_id(hass: HomeAssistant) -> None:
|
|||
async def test_setup_before_started(hass: HomeAssistant) -> None:
|
||||
"""Test we can setup before starting."""
|
||||
hass.set_state(CoreState.stopped)
|
||||
assert await async_setup_component(hass, DOMAIN, CONFIG_MISSING_FAN)
|
||||
assert await async_setup_component(hass, FAN_DOMAIN, CONFIG_MISSING_FAN)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_start()
|
||||
|
@ -431,14 +431,14 @@ async def test_reload(hass: HomeAssistant) -> None:
|
|||
async def test_service_calls(hass: HomeAssistant) -> None:
|
||||
"""Test calling services."""
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: FAN_GROUP}, blocking=True
|
||||
FAN_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: FAN_GROUP}, blocking=True
|
||||
)
|
||||
assert hass.states.get(LIVING_ROOM_FAN_ENTITY_ID).state == STATE_ON
|
||||
assert hass.states.get(PERCENTAGE_FULL_FAN_ENTITY_ID).state == STATE_ON
|
||||
assert hass.states.get(FAN_GROUP).state == STATE_ON
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
FAN_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: FAN_GROUP, ATTR_PERCENTAGE: 66},
|
||||
blocking=True,
|
||||
|
@ -452,14 +452,14 @@ async def test_service_calls(hass: HomeAssistant) -> None:
|
|||
assert fan_group_state.attributes[ATTR_PERCENTAGE_STEP] == 100 / 3
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: FAN_GROUP}, blocking=True
|
||||
FAN_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: FAN_GROUP}, blocking=True
|
||||
)
|
||||
assert hass.states.get(LIVING_ROOM_FAN_ENTITY_ID).state == STATE_OFF
|
||||
assert hass.states.get(PERCENTAGE_FULL_FAN_ENTITY_ID).state == STATE_OFF
|
||||
assert hass.states.get(FAN_GROUP).state == STATE_OFF
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
FAN_DOMAIN,
|
||||
SERVICE_SET_PERCENTAGE,
|
||||
{ATTR_ENTITY_ID: FAN_GROUP, ATTR_PERCENTAGE: 100},
|
||||
blocking=True,
|
||||
|
@ -472,7 +472,7 @@ async def test_service_calls(hass: HomeAssistant) -> None:
|
|||
assert fan_group_state.attributes[ATTR_PERCENTAGE] == 100
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
FAN_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: FAN_GROUP, ATTR_PERCENTAGE: 0},
|
||||
blocking=True,
|
||||
|
@ -482,7 +482,7 @@ async def test_service_calls(hass: HomeAssistant) -> None:
|
|||
assert hass.states.get(FAN_GROUP).state == STATE_OFF
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
FAN_DOMAIN,
|
||||
SERVICE_OSCILLATE,
|
||||
{ATTR_ENTITY_ID: FAN_GROUP, ATTR_OSCILLATING: True},
|
||||
blocking=True,
|
||||
|
@ -495,7 +495,7 @@ async def test_service_calls(hass: HomeAssistant) -> None:
|
|||
assert fan_group_state.attributes[ATTR_OSCILLATING] is True
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
FAN_DOMAIN,
|
||||
SERVICE_OSCILLATE,
|
||||
{ATTR_ENTITY_ID: FAN_GROUP, ATTR_OSCILLATING: False},
|
||||
blocking=True,
|
||||
|
@ -508,7 +508,7 @@ async def test_service_calls(hass: HomeAssistant) -> None:
|
|||
assert fan_group_state.attributes[ATTR_OSCILLATING] is False
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
FAN_DOMAIN,
|
||||
SERVICE_SET_DIRECTION,
|
||||
{ATTR_ENTITY_ID: FAN_GROUP, ATTR_DIRECTION: DIRECTION_FORWARD},
|
||||
blocking=True,
|
||||
|
@ -521,7 +521,7 @@ async def test_service_calls(hass: HomeAssistant) -> None:
|
|||
assert fan_group_state.attributes[ATTR_DIRECTION] == DIRECTION_FORWARD
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
FAN_DOMAIN,
|
||||
SERVICE_SET_DIRECTION,
|
||||
{ATTR_ENTITY_ID: FAN_GROUP, ATTR_DIRECTION: DIRECTION_REVERSE},
|
||||
blocking=True,
|
||||
|
@ -538,9 +538,9 @@ async def test_nested_group(hass: HomeAssistant) -> None:
|
|||
"""Test nested fan group."""
|
||||
await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
FAN_DOMAIN,
|
||||
{
|
||||
DOMAIN: [
|
||||
FAN_DOMAIN: [
|
||||
{"platform": "demo"},
|
||||
{
|
||||
"platform": "group",
|
||||
|
@ -578,7 +578,7 @@ async def test_nested_group(hass: HomeAssistant) -> None:
|
|||
# Test controlling the nested group
|
||||
async with asyncio.timeout(0.5):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
FAN_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "fan.nested_group"},
|
||||
blocking=True,
|
||||
|
|
Loading…
Reference in New Issue