mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +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)
|
_LOGGER.error("No route to myStrom plug: %s", host)
|
||||||
raise ConfigEntryNotReady() from err
|
raise ConfigEntryNotReady() from err
|
||||||
|
|
||||||
|
info.setdefault("type", 101)
|
||||||
|
|
||||||
device_type = info["type"]
|
device_type = info["type"]
|
||||||
if device_type in [101, 106, 107]:
|
if device_type in [101, 106, 107]:
|
||||||
device = _get_mystrom_switch(host)
|
device = _get_mystrom_switch(host)
|
||||||
|
@ -2,12 +2,11 @@
|
|||||||
from typing import Any, Optional
|
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 default device response."""
|
||||||
return {
|
response = {
|
||||||
"version": "2.59.32",
|
"version": "2.59.32",
|
||||||
"mac": "6001940376EB",
|
"mac": "6001940376EB",
|
||||||
"type": device_type,
|
|
||||||
"ssid": "personal",
|
"ssid": "personal",
|
||||||
"ip": "192.168.0.23",
|
"ip": "192.168.0.23",
|
||||||
"mask": "255.255.255.0",
|
"mask": "255.255.255.0",
|
||||||
@ -17,6 +16,9 @@ def get_default_device_response(device_type: int) -> dict[str, Any]:
|
|||||||
"connected": True,
|
"connected": True,
|
||||||
"signal": 94,
|
"signal": 94,
|
||||||
}
|
}
|
||||||
|
if device_type is not None:
|
||||||
|
response["type"] = device_type
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
def get_default_bulb_state() -> dict[str, Any]:
|
def get_default_bulb_state() -> dict[str, Any]:
|
||||||
|
@ -44,7 +44,7 @@ async def test_init_switch_and_unload(
|
|||||||
hass: HomeAssistant, config_entry: MockConfigEntry
|
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the initialization of a myStrom switch."""
|
"""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")
|
state = hass.states.get("switch.mystrom_device")
|
||||||
assert state is not None
|
assert state is not None
|
||||||
assert config_entry.state is ConfigEntryState.LOADED
|
assert config_entry.state is ConfigEntryState.LOADED
|
||||||
@ -58,7 +58,7 @@ async def test_init_switch_and_unload(
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("device_type", "platform", "entry_state", "entity_state_none"),
|
("device_type", "platform", "entry_state", "entity_state_none"),
|
||||||
[
|
[
|
||||||
(101, "switch", ConfigEntryState.LOADED, False),
|
(None, "switch", ConfigEntryState.LOADED, False),
|
||||||
(102, "light", ConfigEntryState.LOADED, False),
|
(102, "light", ConfigEntryState.LOADED, False),
|
||||||
(103, "button", ConfigEntryState.SETUP_ERROR, True),
|
(103, "button", ConfigEntryState.SETUP_ERROR, True),
|
||||||
(104, "button", ConfigEntryState.SETUP_ERROR, True),
|
(104, "button", ConfigEntryState.SETUP_ERROR, True),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user