mirror of
https://github.com/home-assistant/core.git
synced 2025-04-22 16:27:56 +00:00
Use default MyStrom devicetype if not present (#96070)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
598610e313
commit
2c9910d9b6
@ -50,6 +50,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
_LOGGER.error("No route to myStrom plug: %s", host)
|
||||
raise ConfigEntryNotReady() from err
|
||||
|
||||
info.setdefault("type", 101)
|
||||
|
||||
device_type = info["type"]
|
||||
if device_type in [101, 106, 107]:
|
||||
device = _get_mystrom_switch(host)
|
||||
|
@ -2,12 +2,11 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
|
||||
def get_default_device_response(device_type: int) -> dict[str, Any]:
|
||||
def get_default_device_response(device_type: int | None) -> dict[str, Any]:
|
||||
"""Return default device response."""
|
||||
return {
|
||||
response = {
|
||||
"version": "2.59.32",
|
||||
"mac": "6001940376EB",
|
||||
"type": device_type,
|
||||
"ssid": "personal",
|
||||
"ip": "192.168.0.23",
|
||||
"mask": "255.255.255.0",
|
||||
@ -17,6 +16,9 @@ def get_default_device_response(device_type: int) -> dict[str, Any]:
|
||||
"connected": True,
|
||||
"signal": 94,
|
||||
}
|
||||
if device_type is not None:
|
||||
response["type"] = device_type
|
||||
return response
|
||||
|
||||
|
||||
def get_default_bulb_state() -> dict[str, Any]:
|
||||
|
@ -44,7 +44,7 @@ async def test_init_switch_and_unload(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test the initialization of a myStrom switch."""
|
||||
await init_integration(hass, config_entry, 101)
|
||||
await init_integration(hass, config_entry, 106)
|
||||
state = hass.states.get("switch.mystrom_device")
|
||||
assert state is not None
|
||||
assert config_entry.state is ConfigEntryState.LOADED
|
||||
@ -58,7 +58,7 @@ async def test_init_switch_and_unload(
|
||||
@pytest.mark.parametrize(
|
||||
("device_type", "platform", "entry_state", "entity_state_none"),
|
||||
[
|
||||
(101, "switch", ConfigEntryState.LOADED, False),
|
||||
(None, "switch", ConfigEntryState.LOADED, False),
|
||||
(102, "light", ConfigEntryState.LOADED, False),
|
||||
(103, "button", ConfigEntryState.SETUP_ERROR, True),
|
||||
(104, "button", ConfigEntryState.SETUP_ERROR, True),
|
||||
|
Loading…
x
Reference in New Issue
Block a user