response
stringlengths 1
33.1k
| instruction
stringlengths 22
582k
|
---|---|
Define a lock characteristics as per page 219 of HAP spec. | def create_lock_service(accessory):
"""Define a lock characteristics as per page 219 of HAP spec."""
service = accessory.add_service(ServicesTypes.LOCK_MECHANISM)
cur_state = service.add_char(CharacteristicsTypes.LOCK_MECHANISM_CURRENT_STATE)
cur_state.value = 0
targ_state = service.add_char(CharacteristicsTypes.LOCK_MECHANISM_TARGET_STATE)
targ_state.value = 0
# According to the spec, a battery-level characteristic is normally
# part of a separate service. However as the code was written (which
# predates this test) the battery level would have to be part of the lock
# service as it is here.
targ_state = service.add_char(CharacteristicsTypes.BATTERY_LEVEL)
targ_state.value = 50
return service |
Define tv characteristics.
The TV is not currently documented publicly - this is based on observing really TV's that have HomeKit support. | def create_tv_service(accessory):
"""Define tv characteristics.
The TV is not currently documented publicly - this is based on observing really TV's that have HomeKit support.
"""
tv_service = accessory.add_service(ServicesTypes.TELEVISION)
tv_service.add_char(CharacteristicsTypes.ACTIVE, value=True)
cur_state = tv_service.add_char(CharacteristicsTypes.CURRENT_MEDIA_STATE)
cur_state.value = 0
cur_state.perms.append(CharacteristicPermissions.events)
remote = tv_service.add_char(CharacteristicsTypes.REMOTE_KEY)
remote.value = None
remote.perms.append(CharacteristicPermissions.paired_write)
remote.perms.append(CharacteristicPermissions.events)
# Add a HDMI 1 channel
input_source_1 = accessory.add_service(ServicesTypes.INPUT_SOURCE)
input_source_1.add_char(CharacteristicsTypes.IDENTIFIER, value=1)
input_source_1.add_char(CharacteristicsTypes.CONFIGURED_NAME, value="HDMI 1")
tv_service.add_linked_service(input_source_1)
# Add a HDMI 2 channel
input_source_2 = accessory.add_service(ServicesTypes.INPUT_SOURCE)
input_source_2.add_char(CharacteristicsTypes.IDENTIFIER, value=2)
input_source_2.add_char(CharacteristicsTypes.CONFIGURED_NAME, value="HDMI 2")
tv_service.add_linked_service(input_source_2)
# Support switching channels
active_identifier = tv_service.add_char(CharacteristicsTypes.ACTIVE_IDENTIFIER)
active_identifier.value = 1
active_identifier.perms.append(CharacteristicPermissions.paired_write)
return tv_service |
Define a TV service that can play/pause/stop without generate remote events. | def create_tv_service_with_target_media_state(accessory):
"""Define a TV service that can play/pause/stop without generate remote events."""
service = create_tv_service(accessory)
tms = service.add_char(CharacteristicsTypes.TARGET_MEDIA_STATE)
tms.value = None
tms.perms.append(CharacteristicPermissions.paired_write)
return service |
Define battery level characteristics. | def create_switch_with_spray_level(accessory):
"""Define battery level characteristics."""
service = accessory.add_service(ServicesTypes.OUTLET)
spray_level = service.add_char(
CharacteristicsTypes.VENDOR_VOCOLINC_HUMIDIFIER_SPRAY_LEVEL
)
spray_level.perms.append("ev")
spray_level.value = 1
spray_level.minStep = 1
spray_level.minValue = 1
spray_level.maxValue = 5
spray_level.format = "float"
cur_state = service.add_char(CharacteristicsTypes.ON)
cur_state.value = True
return service |
Define a thermostat with ecobee mode characteristics. | def create_service_with_ecobee_mode(accessory: Accessory):
"""Define a thermostat with ecobee mode characteristics."""
service = accessory.add_service(ServicesTypes.THERMOSTAT, add_required=True)
current_mode = service.add_char(CharacteristicsTypes.VENDOR_ECOBEE_CURRENT_MODE)
current_mode.value = 0
current_mode.perms.append("ev")
service.add_char(CharacteristicsTypes.VENDOR_ECOBEE_SET_HOLD_SCHEDULE)
return service |
Define a thermostat with ecobee mode characteristics. | def create_service_with_temperature_units(accessory: Accessory):
"""Define a thermostat with ecobee mode characteristics."""
service = accessory.add_service(ServicesTypes.TEMPERATURE_SENSOR, add_required=True)
units = service.add_char(CharacteristicsTypes.TEMPERATURE_UNITS)
units.value = 0
return service |
Define temperature characteristics. | def create_temperature_sensor_service(accessory):
"""Define temperature characteristics."""
service = accessory.add_service(ServicesTypes.TEMPERATURE_SENSOR)
cur_state = service.add_char(CharacteristicsTypes.TEMPERATURE_CURRENT)
cur_state.value = 0 |
Define humidity characteristics. | def create_humidity_sensor_service(accessory):
"""Define humidity characteristics."""
service = accessory.add_service(ServicesTypes.HUMIDITY_SENSOR)
cur_state = service.add_char(CharacteristicsTypes.RELATIVE_HUMIDITY_CURRENT)
cur_state.value = 0 |
Define light level characteristics. | def create_light_level_sensor_service(accessory):
"""Define light level characteristics."""
service = accessory.add_service(ServicesTypes.LIGHT_SENSOR)
cur_state = service.add_char(CharacteristicsTypes.LIGHT_LEVEL_CURRENT)
cur_state.value = 0 |
Define carbon dioxide level characteristics. | def create_carbon_dioxide_level_sensor_service(accessory):
"""Define carbon dioxide level characteristics."""
service = accessory.add_service(ServicesTypes.CARBON_DIOXIDE_SENSOR)
cur_state = service.add_char(CharacteristicsTypes.CARBON_DIOXIDE_LEVEL)
cur_state.value = 0 |
Define battery level characteristics. | def create_battery_level_sensor(accessory):
"""Define battery level characteristics."""
service = accessory.add_service(ServicesTypes.BATTERY_SERVICE)
cur_state = service.add_char(CharacteristicsTypes.BATTERY_LEVEL)
cur_state.value = 100
low_battery = service.add_char(CharacteristicsTypes.STATUS_LO_BATT)
low_battery.value = 0
charging_state = service.add_char(CharacteristicsTypes.CHARGING_STATE)
charging_state.value = 0
return service |
Define battery level characteristics. | def create_switch_with_sensor(accessory):
"""Define battery level characteristics."""
service = accessory.add_service(ServicesTypes.OUTLET)
realtime_energy = service.add_char(
CharacteristicsTypes.VENDOR_KOOGEEK_REALTIME_ENERGY
)
realtime_energy.value = 0
realtime_energy.format = "float"
realtime_energy.perms.append("ev")
cur_state = service.add_char(CharacteristicsTypes.ON)
cur_state.value = True
return service |
Test all values of this enum get a translatable string. | def test_thread_node_caps_to_str() -> None:
"""Test all values of this enum get a translatable string."""
assert (
thread_node_capability_to_str(ThreadNodeCapabilities.BORDER_ROUTER_CAPABLE)
== "border_router_capable"
)
assert (
thread_node_capability_to_str(ThreadNodeCapabilities.ROUTER_ELIGIBLE)
== "router_eligible"
)
assert thread_node_capability_to_str(ThreadNodeCapabilities.FULL) == "full"
assert thread_node_capability_to_str(ThreadNodeCapabilities.MINIMAL) == "minimal"
assert thread_node_capability_to_str(ThreadNodeCapabilities.SLEEPY) == "sleepy"
assert thread_node_capability_to_str(ThreadNodeCapabilities(128)) == "none" |
Test all values of this enum get a translatable string. | def test_thread_status_to_str() -> None:
"""Test all values of this enum get a translatable string."""
assert thread_status_to_str(ThreadStatus.BORDER_ROUTER) == "border_router"
assert thread_status_to_str(ThreadStatus.LEADER) == "leader"
assert thread_status_to_str(ThreadStatus.ROUTER) == "router"
assert thread_status_to_str(ThreadStatus.CHILD) == "child"
assert thread_status_to_str(ThreadStatus.JOINING) == "joining"
assert thread_status_to_str(ThreadStatus.DETACHED) == "detached"
assert thread_status_to_str(ThreadStatus.DISABLED) == "disabled" |
Define lightbulb characteristics. | def create_lightbulb_service(accessory):
"""Define lightbulb characteristics."""
service = accessory.add_service(ServicesTypes.LIGHTBULB)
on_char = service.add_char(CharacteristicsTypes.ON)
on_char.value = 0 |
Define outlet characteristics. | def create_switch_service(accessory):
"""Define outlet characteristics."""
service = accessory.add_service(ServicesTypes.OUTLET)
on_char = service.add_char(CharacteristicsTypes.ON)
on_char.value = False
outlet_in_use = service.add_char(CharacteristicsTypes.OUTLET_IN_USE)
outlet_in_use.value = False |
Define valve characteristics. | def create_valve_service(accessory):
"""Define valve characteristics."""
service = accessory.add_service(ServicesTypes.VALVE)
on_char = service.add_char(CharacteristicsTypes.ACTIVE)
on_char.value = False
in_use = service.add_char(CharacteristicsTypes.IN_USE)
in_use.value = InUseValues.IN_USE
configured = service.add_char(CharacteristicsTypes.IS_CONFIGURED)
configured.value = IsConfiguredValues.CONFIGURED
remaining = service.add_char(CharacteristicsTypes.REMAINING_DURATION)
remaining.value = 99 |
Define swtch characteristics. | def create_char_switch_service(accessory):
"""Define swtch characteristics."""
service = accessory.add_service(ServicesTypes.OUTLET)
on_char = service.add_char(CharacteristicsTypes.VENDOR_AQARA_PAIRING_MODE)
on_char.perms.append("ev")
on_char.value = False |
Check that unique_id_to_iids is safe against different invalid ids. | def test_unique_id_to_iids():
"""Check that unique_id_to_iids is safe against different invalid ids."""
assert unique_id_to_iids("pairingid_1_2_3") == (1, 2, 3)
assert unique_id_to_iids("pairingid_1_2") == (1, 2, None)
assert unique_id_to_iids("pairingid_1") == (1, None, None)
assert unique_id_to_iids("pairingid") is None
assert unique_id_to_iids("pairingid_1_2_3_4") is None
assert unique_id_to_iids("pairingid_a") is None
assert unique_id_to_iids("pairingid_1_a") is None
assert unique_id_to_iids("pairingid_1_2_a") is None |
Return a mocked connection. | def mock_connection_fixture() -> AsyncConnection:
"""Return a mocked connection."""
connection = MagicMock(spec=AsyncConnection)
def _rest_call_side_effect(path, body=None):
return path, body
connection._restCall.side_effect = _rest_call_side_effect
connection.api_call = AsyncMock(return_value=True)
connection.init = AsyncMock(side_effect=True)
return connection |
Create a mock config entry for homematic ip cloud. | def hmip_config_entry_fixture() -> config_entries.ConfigEntry:
"""Create a mock config entry for homematic ip cloud."""
entry_data = {
HMIPC_HAPID: HAPID,
HMIPC_AUTHTOKEN: AUTH_TOKEN,
HMIPC_NAME: "",
HMIPC_PIN: HAPPIN,
}
return MockConfigEntry(
version=1,
domain=HMIPC_DOMAIN,
title="Home Test SN",
unique_id=HAPID,
data=entry_data,
source=SOURCE_IMPORT,
) |
Create a config for homematic ip cloud. | def hmip_config_fixture() -> ConfigType:
"""Create a config for homematic ip cloud."""
entry_data = {
HMIPC_HAPID: HAPID,
HMIPC_AUTHTOKEN: AUTH_TOKEN,
HMIPC_NAME: "",
HMIPC_PIN: HAPPIN,
}
return {HMIPC_DOMAIN: [entry_data]} |
Create a dummy config. | def dummy_config_fixture() -> ConfigType:
"""Create a dummy config."""
return {"blabla": None} |
Return a simple mocked connection. | def simple_mock_home_fixture():
"""Return a simple mocked connection."""
mock_home = Mock(
spec=AsyncHome,
name="Demo",
devices=[],
groups=[],
location=Mock(),
weather=Mock(
temperature=0.0,
weatherCondition=WeatherCondition.UNKNOWN,
weatherDayTime=WeatherDayTime.DAY,
minTemperature=0.0,
maxTemperature=0.0,
humidity=0,
windSpeed=0.0,
windDirection=0,
vaporAmount=0.0,
),
id=42,
dutyCycle=88,
connected=True,
currentAPVersion="2.0.36",
)
with patch(
"homeassistant.components.homematicip_cloud.hap.AsyncHome",
autospec=True,
return_value=mock_home,
):
yield |
Return a simple mocked connection. | def mock_connection_init_fixture():
"""Return a simple mocked connection."""
with (
patch(
"homeassistant.components.homematicip_cloud.hap.AsyncHome.init",
return_value=None,
),
patch(
"homeassistant.components.homematicip_cloud.hap.AsyncAuth.init",
return_value=None,
),
):
yield |
Return a simple AsyncAuth Mock. | def simple_mock_auth_fixture() -> AsyncAuth:
"""Return a simple AsyncAuth Mock."""
return Mock(spec=AsyncAuth, pin=HAPPIN, create=True) |
Get and test basic device. | def get_and_check_entity_basics(hass, mock_hap, entity_id, entity_name, device_model):
"""Get and test basic device."""
ha_state = hass.states.get(entity_id)
assert ha_state is not None
if device_model:
assert ha_state.attributes[ATTR_MODEL_TYPE] == device_model
assert ha_state.name == entity_name
hmip_device = mock_hap.hmip_device_by_entity_id.get(entity_id)
if hmip_device:
if isinstance(hmip_device, AsyncDevice):
assert ha_state.attributes[ATTR_IS_GROUP] is False
elif isinstance(hmip_device, AsyncGroup):
assert ha_state.attributes[ATTR_IS_GROUP]
return ha_state, hmip_device |
Create a mock and copy instance attributes over mock. | def _get_mock(instance):
"""Create a mock and copy instance attributes over mock."""
if isinstance(instance, Mock):
instance.__dict__.update(instance._mock_wraps.__dict__)
return instance
mock = Mock(spec=instance, wraps=instance)
mock.__dict__.update(instance.__dict__)
return mock |
Return the device fixtures for a specific device. | def device_fixture() -> str:
"""Return the device fixtures for a specific device."""
return "HWE-P1" |
Return a mock bridge. | def mock_homewizardenergy(
device_fixture: str,
) -> MagicMock:
"""Return a mock bridge."""
with (
patch(
"homeassistant.components.homewizard.coordinator.HomeWizardEnergy",
autospec=True,
) as homewizard,
patch(
"homeassistant.components.homewizard.config_flow.HomeWizardEnergy",
new=homewizard,
),
):
client = homewizard.return_value
client.device.return_value = Device.from_dict(
load_json_object_fixture(f"{device_fixture}/device.json", DOMAIN)
)
client.data.return_value = Data.from_dict(
load_json_object_fixture(f"{device_fixture}/data.json", DOMAIN)
)
if get_fixture_path(f"{device_fixture}/state.json", DOMAIN).exists():
client.state.return_value = State.from_dict(
load_json_object_fixture(f"{device_fixture}/state.json", DOMAIN)
)
else:
client.state.side_effect = NotFoundError
if get_fixture_path(f"{device_fixture}/system.json", DOMAIN).exists():
client.system.return_value = System.from_dict(
load_json_object_fixture(f"{device_fixture}/system.json", DOMAIN)
)
else:
client.system.side_effect = NotFoundError
yield client |
Mock setting up a config entry. | def mock_setup_entry() -> Generator[AsyncMock, None, None]:
"""Mock setting up a config entry."""
with patch(
"homeassistant.components.homewizard.async_setup_entry", return_value=True
) as mock_setup:
yield mock_setup |
Return the default mocked config entry. | def mock_config_entry() -> MockConfigEntry:
"""Return the default mocked config entry."""
return MockConfigEntry(
title="Device",
domain=DOMAIN,
data={
"product_name": "Product name",
"product_type": "product_type",
"serial": "aabbccddeeff",
CONF_IP_ADDRESS: "127.0.0.1",
},
unique_id="aabbccddeeff",
) |
Mock that Home Assistant is currently onboarding. | def mock_onboarding() -> Generator[MagicMock, None, None]:
"""Mock that Home Assistant is currently onboarding."""
with patch(
"homeassistant.components.onboarding.async_is_onboarded",
return_value=False,
) as mock_onboarding:
yield mock_onboarding |
Return the default mocked config entry. | def mock_config_entry() -> MockConfigEntry:
"""Return the default mocked config entry."""
return MockConfigEntry(
title="Lutron Homeworks",
domain=DOMAIN,
data={},
options={
CONF_CONTROLLER_ID: "main_controller",
CONF_HOST: "192.168.0.1",
CONF_PORT: 1234,
CONF_DIMMERS: [
{
CONF_ADDR: "[02:08:01:01]",
CONF_NAME: "Foyer Sconces",
CONF_RATE: 1.0,
}
],
CONF_KEYPADS: [
{
CONF_ADDR: "[02:08:02:01]",
CONF_NAME: "Foyer Keypad",
CONF_BUTTONS: [
{
CONF_NAME: "Morning",
CONF_NUMBER: 1,
CONF_LED: True,
CONF_RELEASE_DELAY: None,
},
{
CONF_NAME: "Relax",
CONF_NUMBER: 2,
CONF_LED: True,
CONF_RELEASE_DELAY: None,
},
{
CONF_NAME: "Dim up",
CONF_NUMBER: 3,
CONF_LED: False,
CONF_RELEASE_DELAY: 0.2,
},
],
}
],
},
) |
Return a mocked config entry with no keypads or dimmers. | def mock_empty_config_entry() -> MockConfigEntry:
"""Return a mocked config entry with no keypads or dimmers."""
return MockConfigEntry(
title="Lutron Homeworks",
domain=DOMAIN,
data={},
options={
CONF_CONTROLLER_ID: "main_controller",
CONF_HOST: "192.168.0.1",
CONF_PORT: 1234,
CONF_DIMMERS: [],
CONF_KEYPADS: [],
},
) |
Return a mocked Homeworks client. | def mock_homeworks() -> Generator[None, MagicMock, None]:
"""Return a mocked Homeworks client."""
with (
patch(
"homeassistant.components.homeworks.Homeworks", autospec=True
) as homeworks_mock,
patch(
"homeassistant.components.homeworks.config_flow.Homeworks",
new=homeworks_mock,
),
):
yield homeworks_mock |
Override async_setup_entry. | def mock_setup_entry() -> Generator[AsyncMock, None, None]:
"""Override async_setup_entry."""
with patch(
"homeassistant.components.homeworks.async_setup_entry", return_value=True
) as mock_setup_entry:
yield mock_setup_entry |
Fixture for expiration time of the config entry auth token. | def mock_token_expiration_time() -> float:
"""Fixture for expiration time of the config entry auth token."""
return time.time() + 86400 |
Fixture for OAuth 'token' data for a ConfigEntry. | def mock_token_entry(token_expiration_time: float) -> dict[str, Any]:
"""Fixture for OAuth 'token' data for a ConfigEntry."""
return {
"refresh_token": FAKE_REFRESH_TOKEN,
"access_token": FAKE_ACCESS_TOKEN,
"type": "Bearer",
"expires_at": token_expiration_time,
} |
Fixture for a config entry. | def mock_config_entry(token_entry: dict[str, Any]) -> MockConfigEntry:
"""Fixture for a config entry."""
return MockConfigEntry(
domain=DOMAIN,
data={
"auth_implementation": FAKE_AUTH_IMPL,
"token": token_entry,
},
) |
Fixture to specify platforms to test. | def platforms() -> list[Platform]:
"""Fixture to specify platforms to test."""
return [] |
Fixture to bypass the throttle decorator in __init__. | def mock_bypass_throttle():
"""Fixture to bypass the throttle decorator in __init__."""
with patch(
"homeassistant.components.home_connect.update_all_devices",
side_effect=lambda x, y: bypass_throttle(x, y),
):
yield |
Mock ConfigEntryAuth parent (HomeAssistantAPI) method. | def mock_get_appliances() -> Generator[None, Any, None]:
"""Mock ConfigEntryAuth parent (HomeAssistantAPI) method."""
with patch(
"homeassistant.components.home_connect.api.ConfigEntryAuth.get_appliances",
) as mock:
yield mock |
Fixture to mock Appliance. | def mock_appliance(request) -> Mock:
"""Fixture to mock Appliance."""
app = "Washer"
if hasattr(request, "param") and request.param:
app = request.param
mock = MagicMock(
autospec=HomeConnectAppliance,
**MOCK_APPLIANCES_PROPERTIES.get(app),
)
mock.name = app
type(mock).status = PropertyMock(return_value={})
mock.get.return_value = {}
mock.get_programs_available.return_value = []
mock.get_status.return_value = {}
mock.get_settings.return_value = {}
return mock |
Fixture to mock a problematic Appliance. | def mock_problematic_appliance() -> Mock:
"""Fixture to mock a problematic Appliance."""
app = "Washer"
mock = Mock(
spec=HomeConnectAppliance,
**MOCK_APPLIANCES_PROPERTIES.get(app),
)
mock.name = app
setattr(mock, "status", {})
mock.get_programs_active.side_effect = HomeConnectError
mock.get_programs_available.side_effect = HomeConnectError
mock.start_program.side_effect = HomeConnectError
mock.stop_program.side_effect = HomeConnectError
mock.get_status.side_effect = HomeConnectError
mock.get_settings.side_effect = HomeConnectError
mock.set_setting.side_effect = HomeConnectError
return mock |
Return a list of `HomeConnectAppliance` instances for all appliances. | def get_all_appliances():
"""Return a list of `HomeConnectAppliance` instances for all appliances."""
appliances = {}
data = load_json_object_fixture("home_connect/appliances.json").get("data")
programs_active = load_json_object_fixture("home_connect/programs-active.json")
programs_available = load_json_object_fixture(
"home_connect/programs-available.json"
)
def listen_callback(mock, callback):
callback["callback"](mock)
for home_appliance in data["homeappliances"]:
api_status = load_json_object_fixture("home_connect/status.json")
api_settings = load_json_object_fixture("home_connect/settings.json")
ha_id = home_appliance["haId"]
ha_type = home_appliance["type"]
appliance = MagicMock(spec=HomeConnectAppliance, **home_appliance)
appliance.name = home_appliance["name"]
appliance.listen_events.side_effect = (
lambda app=appliance, **x: listen_callback(app, x)
)
appliance.get_programs_active.return_value = programs_active.get(
ha_type, {}
).get("data", {})
appliance.get_programs_available.return_value = [
program["key"]
for program in programs_available.get(ha_type, {})
.get("data", {})
.get("programs", [])
]
appliance.get_status.return_value = HomeConnectAppliance.json2dict(
api_status.get("data", {}).get("status", [])
)
appliance.get_settings.return_value = HomeConnectAppliance.json2dict(
api_settings.get(ha_type, {}).get("data", {}).get("settings", [])
)
setattr(appliance, "status", {})
appliance.status.update(appliance.get_status.return_value)
appliance.status.update(appliance.get_settings.return_value)
appliance.set_setting.side_effect = (
lambda x, y, appliance=appliance: appliance.status.update({x: {"value": y}})
)
appliance.start_program.side_effect = (
lambda x, appliance=appliance: appliance.status.update(
{"BSH.Common.Root.ActiveProgram": {"value": x}}
)
)
appliance.stop_program.side_effect = (
lambda appliance=appliance: appliance.status.update(
{"BSH.Common.Root.ActiveProgram": {}}
)
)
appliances[ha_id] = appliance
return list(appliances.values()) |
Fixture to specify platforms to test. | def platforms() -> list[str]:
"""Fixture to specify platforms to test."""
return [Platform.SENSOR] |
Provide configuration data for tests. | def config_data():
"""Provide configuration data for tests."""
return {
CONF_USERNAME: "fake",
CONF_PASSWORD: "user",
} |
Provide configuration data for tests. | def another_config_data():
"""Provide configuration data for tests."""
return {
CONF_USERNAME: "user2",
CONF_PASSWORD: "fake2",
} |
Provide configuratio options for test. | def config_options():
"""Provide configuratio options for test."""
return {CONF_COOL_AWAY_TEMPERATURE: 12, CONF_HEAT_AWAY_TEMPERATURE: 22} |
Create a mock config entry. | def config_entry(config_data, config_options):
"""Create a mock config entry."""
return MockConfigEntry(
domain=DOMAIN,
data=config_data,
options=config_options,
) |
Create a mock config entry. | def config_entry2(another_config_data, config_options):
"""Create a mock config entry."""
return MockConfigEntry(
domain=DOMAIN,
data=another_config_data,
options=config_options,
) |
Mock a somecomfort.Device. | def device():
"""Mock a somecomfort.Device."""
mock_device = create_autospec(aiosomecomfort.device.Device, instance=True)
mock_device.deviceid = 1234567
mock_device._data = {
"canControlHumidification": True,
"hasFan": True,
}
mock_device.system_mode = "off"
mock_device.name = "device1"
mock_device.current_temperature = CURRENTTEMPERATURE
mock_device.mac_address = "macaddress1"
mock_device.outdoor_temperature = None
mock_device.outdoor_humidity = None
mock_device.is_alive = True
mock_device.fan_running = False
mock_device.fan_mode = "auto"
mock_device.setpoint_cool = SETPOINTCOOL
mock_device.setpoint_heat = SETPOINTHEAT
mock_device.hold_heat = False
mock_device.hold_cool = False
mock_device.current_humidity = CURRENTHUMIDITY
mock_device.equipment_status = "off"
mock_device.equipment_output_status = "off"
mock_device.raw_ui_data = {
"SwitchOffAllowed": True,
"SwitchAutoAllowed": True,
"SwitchCoolAllowed": True,
"SwitchHeatAllowed": True,
"SwitchEmergencyHeatAllowed": True,
"HeatUpperSetptLimit": HEATUPPERSETPOINTLIMIT,
"HeatLowerSetptLimit": HEATLOWERSETPOINTLIMIT,
"CoolUpperSetptLimit": COOLUPPERSETPOINTLIMIT,
"CoolLowerSetptLimit": COOLLOWERSETPOINTLIMIT,
"HeatNextPeriod": NEXTHEATPERIOD,
"CoolNextPeriod": NEXTCOOLPERIOD,
}
mock_device.raw_fan_data = {
"fanModeOnAllowed": True,
"fanModeAutoAllowed": True,
"fanModeCirculateAllowed": True,
}
mock_device.set_setpoint_cool = AsyncMock()
mock_device.set_setpoint_heat = AsyncMock()
mock_device.set_system_mode = AsyncMock()
mock_device.set_fan_mode = AsyncMock()
mock_device.set_hold_heat = AsyncMock()
mock_device.set_hold_cool = AsyncMock()
mock_device.refresh = AsyncMock()
mock_device.heat_away_temp = HEATAWAY
mock_device.cool_away_temp = COOLAWAY
mock_device.raw_dr_data = {"CoolSetpLimit": None, "HeatSetpLimit": None}
return mock_device |
Mock a somecomfort.Device. | def device_with_outdoor_sensor():
"""Mock a somecomfort.Device."""
mock_device = create_autospec(aiosomecomfort.device.Device, instance=True)
mock_device.deviceid = 1234567
mock_device._data = {
"canControlHumidification": False,
"hasFan": False,
}
mock_device.system_mode = "off"
mock_device.name = "device3"
mock_device.current_temperature = CURRENTTEMPERATURE
mock_device.mac_address = "macaddress1"
mock_device.temperature_unit = "C"
mock_device.outdoor_temperature = OUTDOORTEMP
mock_device.outdoor_humidity = OUTDOORHUMIDITY
mock_device.raw_ui_data = {
"SwitchOffAllowed": True,
"SwitchAutoAllowed": True,
"SwitchCoolAllowed": True,
"SwitchHeatAllowed": True,
"SwitchEmergencyHeatAllowed": True,
"HeatUpperSetptLimit": HEATUPPERSETPOINTLIMIT,
"HeatLowerSetptLimit": HEATLOWERSETPOINTLIMIT,
"CoolUpperSetptLimit": COOLUPPERSETPOINTLIMIT,
"CoolLowerSetptLimit": COOLLOWERSETPOINTLIMIT,
"HeatNextPeriod": NEXTHEATPERIOD,
"CoolNextPeriod": NEXTCOOLPERIOD,
}
mock_device.raw_fan_data = {
"fanModeOnAllowed": True,
"fanModeAutoAllowed": True,
"fanModeCirculateAllowed": True,
}
mock_device.raw_dr_data = {"CoolSetpLimit": None, "HeatSetpLimit": None}
return mock_device |
Mock a somecomfort.Device. | def another_device():
"""Mock a somecomfort.Device."""
mock_device = create_autospec(aiosomecomfort.device.Device, instance=True)
mock_device.deviceid = 7654321
mock_device._data = {
"canControlHumidification": False,
"hasFan": False,
}
mock_device.system_mode = "off"
mock_device.name = "device2"
mock_device.current_temperature = CURRENTTEMPERATURE
mock_device.mac_address = "macaddress1"
mock_device.outdoor_temperature = None
mock_device.outdoor_humidity = None
mock_device.raw_ui_data = {
"SwitchOffAllowed": True,
"SwitchAutoAllowed": True,
"SwitchCoolAllowed": True,
"SwitchHeatAllowed": True,
"SwitchEmergencyHeatAllowed": True,
"HeatUpperSetptLimit": HEATUPPERSETPOINTLIMIT,
"HeatLowerSetptLimit": HEATLOWERSETPOINTLIMIT,
"CoolUpperSetptLimit": COOLUPPERSETPOINTLIMIT,
"CoolLowerSetptLimit": COOLLOWERSETPOINTLIMIT,
"HeatNextPeriod": NEXTHEATPERIOD,
"CoolNextPeriod": NEXTCOOLPERIOD,
}
mock_device.raw_fan_data = {
"fanModeOnAllowed": True,
"fanModeAutoAllowed": True,
"fanModeCirculateAllowed": True,
}
mock_device.raw_dr_data = {"CoolSetpLimit": None, "HeatSetpLimit": None}
return mock_device |
Mock a somecomfort.Location. | def location(device):
"""Mock a somecomfort.Location."""
mock_location = create_autospec(aiosomecomfort.location.Location, instance=True)
mock_location.locationid.return_value = "location1"
mock_location.devices_by_id = {device.deviceid: device}
return mock_location |
Mock a somecomfort.SomeComfort client. | def client(location):
"""Mock a somecomfort.SomeComfort client."""
client_mock = create_autospec(aiosomecomfort.AIOSomeComfort, instance=True)
client_mock.locations_by_id = {location.locationid: location}
client_mock.login = AsyncMock(return_value=True)
client_mock.discover = AsyncMock()
with patch(
"homeassistant.components.honeywell.aiosomecomfort.AIOSomeComfort"
) as sc_class_mock:
sc_class_mock.return_value = client_mock
yield client_mock |
Reset the mocks for test. | def reset_mock(device: MagicMock) -> None:
"""Reset the mocks for test."""
device.set_setpoint_cool.reset_mock()
device.set_setpoint_heat.reset_mock()
device.set_hold_heat.reset_mock()
device.set_hold_cool.reset_mock() |
Return aiohttp_client and allow opening sockets. | def aiohttp_client(event_loop, aiohttp_client, socket_enabled):
"""Return aiohttp_client and allow opening sockets."""
return aiohttp_client |
Fixture to set up a web.Application. | def app(hass):
"""Fixture to set up a web.Application."""
app = web.Application()
app[KEY_HASS] = hass
app.router.add_get("/", mock_handler)
async_setup_forwarded(app, True, [])
return app |
Fixture to set up a web.Application without real_ip middleware. | def app2(hass):
"""Fixture to set up a web.Application without real_ip middleware."""
app = web.Application()
app[KEY_HASS] = hass
app.router.add_get("/", mock_handler)
return app |
Load trusted networks auth provider. | def trusted_networks_auth(hass):
"""Load trusted networks auth provider."""
prv = trusted_networks.TrustedNetworksAuthProvider(
hass,
hass.auth._store,
{"type": "trusted_networks", "trusted_networks": TRUSTED_NETWORKS},
)
hass.auth._providers[(prv.type, prv.id)] = prv
return prv |
Fixture to set up a web.Application. | def app_strict_connection(hass):
"""Fixture to set up a web.Application."""
async def handler(request):
"""Return if request was authenticated."""
return web.json_response(data={"authenticated": request[KEY_AUTHENTICATED]})
app = web.Application()
app[KEY_HASS] = hass
app.router.add_get("/", handler)
async_setup_forwarded(app, True, [])
return app |
Add an endpoint to set a cookie. | def _add_set_cookie_endpoint(app: web.Application, refresh_token: RefreshToken) -> None:
"""Add an endpoint to set a cookie."""
async def set_cookie(request: web.Request) -> web.Response:
hass = request.app[KEY_HASS]
# Clear all sessions
hass.auth.session._temp_sessions.clear()
hass.auth.session._strict_connection_sessions.clear()
if request.query["token"] == "refresh":
await hass.auth.session.async_create_session(request, refresh_token)
else:
await hass.auth.session.async_create_temp_unauthorized_session(request)
session = await get_session(request)
return web.Response(text=session[SESSION_ID])
app.router.add_get("/test/cookie", set_cookie) |
Fixture to inject hassio env. | def hassio_env_fixture():
"""Fixture to inject hassio env."""
with (
patch.dict(os.environ, {"SUPERVISOR": "127.0.0.1"}),
patch(
"homeassistant.components.hassio.HassIO.is_connected",
return_value={"result": "ok", "data": {}},
),
patch.dict(os.environ, {"SUPERVISOR_TOKEN": "123456"}),
):
yield |
Fixture to mock out I/O on getting host by address. | def gethostbyaddr_mock():
"""Fixture to mock out I/O on getting host by address."""
with patch(
"homeassistant.components.http.ban.gethostbyaddr",
return_value=("example.com", ["0.0.0.0.in-addr.arpa"], ["0.0.0.0"]),
):
yield |
Fixture to set up a web.Application. | def client(event_loop, aiohttp_client):
"""Fixture to set up a web.Application."""
app = web.Application()
setup_cors(app, [TRUSTED_ORIGIN])
app[KEY_ALLOW_CONFIGRED_CORS](app.router.add_get("/", mock_handler))
return event_loop.run_until_complete(aiohttp_client(app)) |
Mock extract stack. | def mock_stack():
"""Mock extract stack."""
with patch(
"homeassistant.components.http.extract_stack",
return_value=[
Mock(
filename="/home/paulus/core/homeassistant/core.py",
lineno="23",
line="do_something()",
),
Mock(
filename="/home/paulus/core/homeassistant/components/hue/light.py",
lineno="23",
line="self.light.is_on",
),
Mock(
filename="/home/paulus/core/homeassistant/components/http/__init__.py",
lineno="157",
line="base_url",
),
],
):
yield |
Return a fake request with a strict connection cookie. | def fake_request_with_strict_connection_cookie(cookie_value: str) -> web.Request:
"""Return a fake request with a strict connection cookie."""
request = make_mocked_request(
"GET", "/", headers={"Cookie": f"{COOKIE_NAME}={cookie_value}"}
)
assert COOKIE_NAME in request.cookies
return request |
Fixture for the cookie storage. | def cookie_storage(hass: HomeAssistant) -> HomeAssistantCookieStorage:
"""Fixture for the cookie storage."""
return HomeAssistantCookieStorage(hass) |
Encrypt cookie data. | def _encrypt_cookie_data(cookie_storage: HomeAssistantCookieStorage, data: Any) -> str:
"""Encrypt cookie data."""
cookie_data = cookie_storage._encoder(data).encode("utf-8")
return cookie_storage._fernet.encrypt(cookie_data).decode("utf-8") |
Mock a request. | def mock_request() -> Mock:
"""Mock a request."""
return Mock(app={KEY_HASS: Mock(is_stopping=False)}, match_info={}) |
Mock a request. | def mock_request_with_stopping() -> Mock:
"""Mock a request."""
return Mock(app={KEY_HASS: Mock(is_stopping=True)}, match_info={}) |
Set up a requests_mock with base mocks for login tests. | def login_requests_mock(requests_mock):
"""Set up a requests_mock with base mocks for login tests."""
https_url = urlunparse(
urlparse(FIXTURE_USER_INPUT[CONF_URL])._replace(scheme="https")
)
for url in FIXTURE_USER_INPUT[CONF_URL], https_url:
requests_mock.request(ANY, url, text='<meta name="csrf_token" content="x"/>')
requests_mock.request(
ANY,
f"{url}api/user/state-login",
text=(
f"<response><State>{LoginStateEnum.LOGGED_OUT}</State>"
f"<password_type>{PasswordTypeEnum.SHA256}</password_type></response>"
),
)
requests_mock.request(
ANY,
f"{url}api/user/logout",
text="<response>OK</response>",
)
return requests_mock |
Test that better snakecase works better. | def test_better_snakecase(value, expected) -> None:
"""Test that better snakecase works better."""
assert device_tracker._better_snakecase(value) == expected |
Test that default formatter copes with expected values. | def test_format_default(value, expected) -> None:
"""Test that default formatter copes with expected values."""
assert sensor.format_default(value) == expected |
Mock huawei_lte.Client. | def magic_client(multi_basic_settings_value: dict) -> MagicMock:
"""Mock huawei_lte.Client."""
information = MagicMock(return_value={"SerialNumber": "test-serial-number"})
check_notifications = MagicMock(return_value={"SmsStorageFull": 0})
status = MagicMock(
return_value={"ConnectionStatus": ConnectionStatusEnum.CONNECTED.value}
)
multi_basic_settings = MagicMock(return_value=multi_basic_settings_value)
wifi_feature_switch = MagicMock(return_value={"wifi24g_switch_enable": 1})
device = MagicMock(information=information)
monitoring = MagicMock(check_notifications=check_notifications, status=status)
wlan = MagicMock(
multi_basic_settings=multi_basic_settings,
wifi_feature_switch=wifi_feature_switch,
)
return MagicMock(device=device, monitoring=monitoring, wlan=wlan) |
Make the request refresh delay 0 for instant tests. | def no_request_delay():
"""Make the request refresh delay 0 for instant tests."""
with patch("homeassistant.components.hue.const.REQUEST_REFRESH_DELAY", 0):
yield |
Create a mocked HueBridge instance. | def create_mock_bridge(hass, api_version=1):
"""Create a mocked HueBridge instance."""
bridge = Mock(
hass=hass,
authorized=True,
config_entry=None,
reset_jobs=[],
api_version=api_version,
spec=hue.HueBridge,
)
bridge.logger = logging.getLogger(__name__)
if bridge.api_version == 2:
bridge.api = create_mock_api_v2(hass)
bridge.mock_requests = bridge.api.mock_requests
else:
bridge.api = create_mock_api_v1(hass)
bridge.sensor_manager = hue_sensor_base.SensorManager(bridge)
bridge.mock_requests = bridge.api.mock_requests
bridge.mock_light_responses = bridge.api.mock_light_responses
bridge.mock_group_responses = bridge.api.mock_group_responses
bridge.mock_sensor_responses = bridge.api.mock_sensor_responses
async def async_initialize_bridge():
if bridge.config_entry:
hass.data.setdefault(hue.DOMAIN, {})[bridge.config_entry.entry_id] = bridge
if bridge.api_version == 2:
await async_setup_devices(bridge)
return True
bridge.async_initialize_bridge = async_initialize_bridge
async def async_request_call(task, *args, **kwargs):
await task(*args, **kwargs)
bridge.async_request_call = async_request_call
async def async_reset():
if bridge.config_entry:
hass.data[hue.DOMAIN].pop(bridge.config_entry.entry_id)
return True
bridge.async_reset = async_reset
return bridge |
Mock the Hue V1 api. | def mock_api_v1(hass):
"""Mock the Hue V1 api."""
return create_mock_api_v1(hass) |
Mock the Hue V2 api. | def mock_api_v2(hass):
"""Mock the Hue V2 api."""
return create_mock_api_v2(hass) |
Create a mock V1 API. | def create_mock_api_v1(hass):
"""Create a mock V1 API."""
api = Mock(spec=aiohue_v1.HueBridgeV1)
api.initialize = AsyncMock()
api.mock_requests = []
api.mock_light_responses = deque()
api.mock_group_responses = deque()
api.mock_sensor_responses = deque()
api.mock_scene_responses = deque()
async def mock_request(method, path, **kwargs):
kwargs["method"] = method
kwargs["path"] = path
api.mock_requests.append(kwargs)
if path == "lights":
return api.mock_light_responses.popleft()
if path == "groups":
return api.mock_group_responses.popleft()
if path == "sensors":
return api.mock_sensor_responses.popleft()
if path == "scenes":
return api.mock_scene_responses.popleft()
return None
logger = logging.getLogger(__name__)
api.config = Mock(
bridge_id="ff:ff:ff:ff:ff:ff",
mac_address="aa:bb:cc:dd:ee:ff",
model_id="BSB002",
apiversion="9.9.9",
software_version="1935144040",
)
api.config.name = "Home"
api.lights = aiohue_v1.Lights(logger, {}, mock_request)
api.groups = aiohue_v1.Groups(logger, {}, mock_request)
api.sensors = aiohue_v1.Sensors(logger, {}, mock_request)
api.scenes = aiohue_v1.Scenes(logger, {}, mock_request)
return api |
Load V2 resources mock data. | def v2_resources_test_data():
"""Load V2 resources mock data."""
return json.loads(load_fixture("hue/v2_resources.json")) |
Create a mock V2 API. | def create_mock_api_v2(hass):
"""Create a mock V2 API."""
api = Mock(spec=aiohue_v2.HueBridgeV2)
api.initialize = AsyncMock()
api.mock_requests = []
api.logger = logging.getLogger(__name__)
api.config = aiohue_v2.ConfigController(api)
api.events = aiohue_v2.EventStream(api)
api.devices = aiohue_v2.DevicesController(api)
api.lights = aiohue_v2.LightsController(api)
api.sensors = aiohue_v2.SensorsController(api)
api.groups = aiohue_v2.GroupsController(api)
api.scenes = aiohue_v2.ScenesController(api)
async def mock_request(method, path, **kwargs):
kwargs["method"] = method
kwargs["path"] = path
api.mock_requests.append(kwargs)
return kwargs.get("json")
api.request = mock_request
async def load_test_data(data: list[dict[str, Any]]):
"""Load test data into controllers."""
# append default bridge if none explicitly given in test data
if not any(x for x in data if x["type"] == "bridge"):
data.append(FAKE_BRIDGE)
data.append(FAKE_BRIDGE_DEVICE)
await asyncio.gather(
api.config.initialize(data),
api.devices.initialize(data),
api.lights.initialize(data),
api.scenes.initialize(data),
api.sensors.initialize(data),
api.groups.initialize(data),
)
def emit_event(event_type, data):
"""Emit an event from a (hue resource) dict."""
api.events.emit(EventType(event_type), data)
api.load_test_data = load_test_data
api.emit_event = emit_event
# mock context manager too
api.__aenter__ = AsyncMock(return_value=api)
api.__aexit__ = AsyncMock()
return api |
Mock a Hue bridge with V1 api. | def mock_bridge_v1(hass):
"""Mock a Hue bridge with V1 api."""
return create_mock_bridge(hass, api_version=1) |
Mock a Hue bridge with V2 api. | def mock_bridge_v2(hass):
"""Mock a Hue bridge with V2 api."""
return create_mock_bridge(hass, api_version=2) |
Mock a config entry for a Hue V1 bridge. | def mock_config_entry_v1(hass):
"""Mock a config entry for a Hue V1 bridge."""
return create_config_entry(api_version=1) |
Mock a config entry. | def mock_config_entry_v2(hass):
"""Mock a config entry."""
return create_config_entry(api_version=2) |
Mock a config entry for a Hue bridge. | def create_config_entry(api_version=1, host="mock-host"):
"""Mock a config entry for a Hue bridge."""
return MockConfigEntry(
domain=hue.DOMAIN,
title=f"Mock bridge {api_version}",
data={"host": host, "api_version": api_version, "api_key": ""},
) |
Return an empty, loaded, registry. | def get_device_reg(hass):
"""Return an empty, loaded, registry."""
return mock_device_registry(hass) |
Track calls to a mock service. | def track_calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") |
Mock hue entry setup. | def hue_setup_fixture():
"""Mock hue entry setup."""
with patch("homeassistant.components.hue.async_setup_entry", return_value=True):
yield |
Return a mocked Discovered Bridge. | def get_discovered_bridge(bridge_id="aabbccddeeff", host="1.2.3.4", supports_v2=False):
"""Return a mocked Discovered Bridge."""
return Mock(host=host, id=bridge_id, supports_v2=supports_v2) |
Patch aiohttp responses with fake data for bridge discovery. | def create_mock_api_discovery(aioclient_mock, bridges):
"""Patch aiohttp responses with fake data for bridge discovery."""
aioclient_mock.get(
URL_NUPNP,
json=[
{"internalipaddress": host, "id": bridge_id}
for (host, bridge_id) in bridges
],
)
for host, bridge_id in bridges:
aioclient_mock.get(
f"http://{host}/api/config",
json={"bridgeid": bridge_id},
)
# mock v2 support if v2 found in id
aioclient_mock.get(
f"https://{host}/clip/v2/resources",
status=403 if "v2" in bridge_id else 404,
) |
Iterate schema to find a key. | def _get_schema_default(schema, key_name):
"""Iterate schema to find a key."""
for schema_key in schema:
if schema_key == key_name:
return schema_key.default()
raise KeyError(f"{key_name} not found in schema") |
Mock bridge setup. | def mock_bridge_setup():
"""Mock bridge setup."""
with patch.object(hue, "HueBridge") as mock_bridge:
mock_bridge.return_value.api_version = 2
mock_bridge.return_value.async_initialize_bridge = AsyncMock(return_value=True)
mock_bridge.return_value.api.config = Mock(
bridge_id="mock-id",
mac_address="00:00:00:00:00:00",
model_id="BSB002",
software_version="1.0.0",
bridge_device=Mock(
id="4a507550-8742-4087-8bf5-c2334f29891c",
product_data=Mock(manufacturer_name="Mock"),
),
spec=aiohue_v2.ConfigController,
)
mock_bridge.return_value.api.config.name = "Mock Hue bridge"
yield mock_bridge.return_value |
Test available property. | def test_available() -> None:
"""Test available property."""
light = hue_light.HueLight(
light=Mock(
state={"reachable": False},
raw=LIGHT_RAW,
colorgamuttype=LIGHT_GAMUT_TYPE,
colorgamut=LIGHT_GAMUT,
),
bridge=Mock(config_entry=Mock(options={"allow_unreachable": False})),
coordinator=Mock(last_update_success=True),
is_group=False,
supported_color_modes=hue_light.COLOR_MODES_HUE_EXTENDED,
supported_features=hue_light.SUPPORT_HUE_EXTENDED,
rooms={},
)
assert light.available is False
light = hue_light.HueLight(
light=Mock(
state={"reachable": False},
raw=LIGHT_RAW,
colorgamuttype=LIGHT_GAMUT_TYPE,
colorgamut=LIGHT_GAMUT,
),
coordinator=Mock(last_update_success=True),
is_group=False,
supported_color_modes=hue_light.COLOR_MODES_HUE_EXTENDED,
supported_features=hue_light.SUPPORT_HUE_EXTENDED,
rooms={},
bridge=Mock(config_entry=Mock(options={"allow_unreachable": True})),
)
assert light.available is True
light = hue_light.HueLight(
light=Mock(
state={"reachable": False},
raw=LIGHT_RAW,
colorgamuttype=LIGHT_GAMUT_TYPE,
colorgamut=LIGHT_GAMUT,
),
coordinator=Mock(last_update_success=True),
is_group=True,
supported_color_modes=hue_light.COLOR_MODES_HUE_EXTENDED,
supported_features=hue_light.SUPPORT_HUE_EXTENDED,
rooms={},
bridge=Mock(config_entry=Mock(options={"allow_unreachable": False})),
)
assert light.available is True |
Test hs_color property. | def test_hs_color() -> None:
"""Test hs_color property."""
light = hue_light.HueLight(
light=Mock(
state={"colormode": "ct", "hue": 1234, "sat": 123},
raw=LIGHT_RAW,
colorgamuttype=LIGHT_GAMUT_TYPE,
colorgamut=LIGHT_GAMUT,
),
coordinator=Mock(last_update_success=True),
bridge=Mock(),
is_group=False,
supported_color_modes=hue_light.COLOR_MODES_HUE_EXTENDED,
supported_features=hue_light.SUPPORT_HUE_EXTENDED,
rooms={},
)
assert light.hs_color is None
light = hue_light.HueLight(
light=Mock(
state={"colormode": "hs", "hue": 1234, "sat": 123},
raw=LIGHT_RAW,
colorgamuttype=LIGHT_GAMUT_TYPE,
colorgamut=LIGHT_GAMUT,
),
coordinator=Mock(last_update_success=True),
bridge=Mock(),
is_group=False,
supported_color_modes=hue_light.COLOR_MODES_HUE_EXTENDED,
supported_features=hue_light.SUPPORT_HUE_EXTENDED,
rooms={},
)
assert light.hs_color is None
light = hue_light.HueLight(
light=Mock(
state={"colormode": "xy", "hue": 1234, "sat": 123, "xy": [0.4, 0.5]},
raw=LIGHT_RAW,
colorgamuttype=LIGHT_GAMUT_TYPE,
colorgamut=LIGHT_GAMUT,
),
coordinator=Mock(last_update_success=True),
bridge=Mock(),
is_group=False,
supported_color_modes=hue_light.COLOR_MODES_HUE_EXTENDED,
supported_features=hue_light.SUPPORT_HUE_EXTENDED,
rooms={},
)
assert light.hs_color == color.color_xy_to_hs(0.4, 0.5, LIGHT_GAMUT) |
Stub copying the blueprints to the config folder. | def stub_blueprint_populate_autouse(stub_blueprint_populate: None) -> None:
"""Stub copying the blueprints to the config folder.""" |
Stub copying the blueprints to the config folder. | def stub_blueprint_populate_autouse(stub_blueprint_populate: None) -> None:
"""Stub copying the blueprints to the config folder.""" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.