Skip to content

Commit

Permalink
Implement model_id's in Plugwise (#126069)
Browse files Browse the repository at this point in the history
  • Loading branch information
bouwew authored Sep 16, 2024
1 parent 7ada2f8 commit b73be2d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion homeassistant/components/plugwise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: PlugwiseConfigEntry) ->
identifiers={(DOMAIN, str(coordinator.api.gateway_id))},
manufacturer="Plugwise",
model=coordinator.api.smile_model,
model_id=coordinator.api.smile_model_id,
name=coordinator.api.smile_name,
sw_version=coordinator.api.smile_version[0],
)
) # required for adding the entity-less P1 Gateway

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/plugwise/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(
connections=connections,
manufacturer=data.get("vendor"),
model=data.get("model"),
model_id=data.get("model_id"),
name=coordinator.data.gateway["smile_name"],
sw_version=data.get("firmware"),
hw_version=data.get("hardware"),
Expand Down
11 changes: 11 additions & 0 deletions tests/components/plugwise/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def mock_smile_config_flow() -> Generator[MagicMock]:
smile = smile_mock.return_value
smile.smile_hostname = "smile12345"
smile.smile_model = "Test Model"
smile.smile_model_id = "Test Model ID"
smile.smile_name = "Test Smile Name"
smile.connect.return_value = True
yield smile
Expand All @@ -86,6 +87,7 @@ def mock_smile_adam() -> Generator[MagicMock]:
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile_open_therm"
smile.smile_name = "Adam"
smile.connect.return_value = True
all_data = _read_json(chosen_env, "all_data")
Expand All @@ -112,6 +114,7 @@ def mock_smile_adam_2() -> Generator[MagicMock]:
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile_open_therm"
smile.smile_name = "Adam"
smile.connect.return_value = True
all_data = _read_json(chosen_env, "all_data")
Expand All @@ -138,6 +141,7 @@ def mock_smile_adam_3() -> Generator[MagicMock]:
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile_open_therm"
smile.smile_name = "Adam"
smile.connect.return_value = True
all_data = _read_json(chosen_env, "all_data")
Expand All @@ -164,6 +168,7 @@ def mock_smile_adam_4() -> Generator[MagicMock]:
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile_open_therm"
smile.smile_name = "Adam"
smile.connect.return_value = True
all_data = _read_json(chosen_env, "all_data")
Expand All @@ -189,6 +194,7 @@ def mock_smile_anna() -> Generator[MagicMock]:
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile_thermo"
smile.smile_name = "Smile Anna"
smile.connect.return_value = True
all_data = _read_json(chosen_env, "all_data")
Expand All @@ -214,6 +220,7 @@ def mock_smile_anna_2() -> Generator[MagicMock]:
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile_thermo"
smile.smile_name = "Smile Anna"
smile.connect.return_value = True
all_data = _read_json(chosen_env, "all_data")
Expand All @@ -239,6 +246,7 @@ def mock_smile_anna_3() -> Generator[MagicMock]:
smile.smile_type = "thermostat"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile_thermo"
smile.smile_name = "Smile Anna"
smile.connect.return_value = True
all_data = _read_json(chosen_env, "all_data")
Expand All @@ -264,6 +272,7 @@ def mock_smile_p1() -> Generator[MagicMock]:
smile.smile_type = "power"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile"
smile.smile_name = "Smile P1"
smile.connect.return_value = True
all_data = _read_json(chosen_env, "all_data")
Expand All @@ -289,6 +298,7 @@ def mock_smile_p1_2() -> Generator[MagicMock]:
smile.smile_type = "power"
smile.smile_hostname = "smile98765"
smile.smile_model = "Gateway"
smile.smile_model_id = "smile"
smile.smile_name = "Smile P1"
smile.connect.return_value = True
all_data = _read_json(chosen_env, "all_data")
Expand All @@ -314,6 +324,7 @@ def mock_stretch() -> Generator[MagicMock]:
smile.smile_type = "stretch"
smile.smile_hostname = "stretch98765"
smile.smile_model = "Gateway"
smile.smile_model_id = None
smile.smile_name = "Stretch"
smile.connect.return_value = True
all_data = _read_json(chosen_env, "all_data")
Expand Down
22 changes: 22 additions & 0 deletions tests/components/plugwise/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,28 @@ async def test_gateway_config_entry_not_ready(
assert mock_config_entry.state is entry_state


async def test_device_in_dr(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_smile_p1: MagicMock,
device_registry: dr.DeviceRegistry,
) -> None:
"""Test Gateway device registry data."""
mock_config_entry.add_to_hass(hass)
assert await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done()

device_entry = device_registry.async_get_device(
identifiers={(DOMAIN, "a455b61e52394b2db5081ce025a430f3")}
)
assert device_entry.hw_version == "AME Smile 2.0 board"
assert device_entry.manufacturer == "Plugwise"
assert device_entry.model == "Gateway"
assert device_entry.model_id == "smile"
assert device_entry.name == "Smile P1"
assert device_entry.sw_version == "4.4.2"


@pytest.mark.parametrize(
("entitydata", "old_unique_id", "new_unique_id"),
[
Expand Down

0 comments on commit b73be2d

Please sign in to comment.