Fix Shelly update entity names (#126512)

This commit is contained in:
Maciej Bieniek 2024-09-23 14:18:24 +02:00 committed by GitHub
parent 11bb8e402e
commit efc1ff6eff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 17 deletions

View File

@ -59,7 +59,7 @@ class RestUpdateDescription(RestEntityDescription, UpdateEntityDescription):
REST_UPDATES: Final = { REST_UPDATES: Final = {
"fwupdate": RestUpdateDescription( "fwupdate": RestUpdateDescription(
name="Firmware update", name="Firmware",
key="fwupdate", key="fwupdate",
latest_version=lambda status: status["update"]["new_version"], latest_version=lambda status: status["update"]["new_version"],
beta=False, beta=False,
@ -68,7 +68,7 @@ REST_UPDATES: Final = {
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
"fwupdate_beta": RestUpdateDescription( "fwupdate_beta": RestUpdateDescription(
name="Beta firmware update", name="Beta firmware",
key="fwupdate", key="fwupdate",
latest_version=lambda status: status["update"].get("beta_version"), latest_version=lambda status: status["update"].get("beta_version"),
beta=True, beta=True,
@ -80,7 +80,7 @@ REST_UPDATES: Final = {
RPC_UPDATES: Final = { RPC_UPDATES: Final = {
"fwupdate": RpcUpdateDescription( "fwupdate": RpcUpdateDescription(
name="Firmware update", name="Firmware",
key="sys", key="sys",
sub_key="available_updates", sub_key="available_updates",
latest_version=lambda status: status.get("stable", {"version": ""})["version"], latest_version=lambda status: status.get("stable", {"version": ""})["version"],
@ -89,7 +89,7 @@ RPC_UPDATES: Final = {
entity_category=EntityCategory.CONFIG, entity_category=EntityCategory.CONFIG,
), ),
"fwupdate_beta": RpcUpdateDescription( "fwupdate_beta": RpcUpdateDescription(
name="Beta firmware update", name="Beta firmware",
key="sys", key="sys",
sub_key="available_updates", sub_key="available_updates",
latest_version=lambda status: status.get("beta", {"version": ""})["version"], latest_version=lambda status: status.get("beta", {"version": ""})["version"],

View File

@ -53,7 +53,7 @@ async def test_block_update(
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
) -> None: ) -> None:
"""Test block device update entity.""" """Test block device update entity."""
entity_id = "update.test_name_firmware_update" entity_id = "update.test_name_firmware"
monkeypatch.setitem(mock_block_device.status["update"], "old_version", "1.0.0") monkeypatch.setitem(mock_block_device.status["update"], "old_version", "1.0.0")
monkeypatch.setitem(mock_block_device.status["update"], "new_version", "2.0.0") monkeypatch.setitem(mock_block_device.status["update"], "new_version", "2.0.0")
monkeypatch.setitem(mock_block_device.status, "cloud", {"connected": False}) monkeypatch.setitem(mock_block_device.status, "cloud", {"connected": False})
@ -105,7 +105,7 @@ async def test_block_beta_update(
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
) -> None: ) -> None:
"""Test block device beta update entity.""" """Test block device beta update entity."""
entity_id = "update.test_name_beta_firmware_update" entity_id = "update.test_name_beta_firmware"
monkeypatch.setitem(mock_block_device.status["update"], "old_version", "1.0.0") monkeypatch.setitem(mock_block_device.status["update"], "old_version", "1.0.0")
monkeypatch.setitem(mock_block_device.status["update"], "new_version", "2.0.0") monkeypatch.setitem(mock_block_device.status["update"], "new_version", "2.0.0")
monkeypatch.setitem(mock_block_device.status["update"], "beta_version", "") monkeypatch.setitem(mock_block_device.status["update"], "beta_version", "")
@ -179,7 +179,7 @@ async def test_block_update_connection_error(
await hass.services.async_call( await hass.services.async_call(
UPDATE_DOMAIN, UPDATE_DOMAIN,
SERVICE_INSTALL, SERVICE_INSTALL,
{ATTR_ENTITY_ID: "update.test_name_firmware_update"}, {ATTR_ENTITY_ID: "update.test_name_firmware"},
blocking=True, blocking=True,
) )
assert "Error starting OTA update" in str(excinfo.value) assert "Error starting OTA update" in str(excinfo.value)
@ -206,7 +206,7 @@ async def test_block_update_auth_error(
await hass.services.async_call( await hass.services.async_call(
UPDATE_DOMAIN, UPDATE_DOMAIN,
SERVICE_INSTALL, SERVICE_INSTALL,
{ATTR_ENTITY_ID: "update.test_name_firmware_update"}, {ATTR_ENTITY_ID: "update.test_name_firmware"},
blocking=True, blocking=True,
) )
@ -237,8 +237,8 @@ async def test_block_version_compare(
STABLE = "20230913-111730/v1.14.0-gcb84623" STABLE = "20230913-111730/v1.14.0-gcb84623"
BETA = "20231107-162609/v1.14.1-rc1-g0617c15" BETA = "20231107-162609/v1.14.1-rc1-g0617c15"
entity_id_beta = "update.test_name_beta_firmware_update" entity_id_beta = "update.test_name_beta_firmware"
entity_id_latest = "update.test_name_firmware_update" entity_id_latest = "update.test_name_firmware"
monkeypatch.setitem(mock_block_device.status["update"], "old_version", STABLE) monkeypatch.setitem(mock_block_device.status["update"], "old_version", STABLE)
monkeypatch.setitem(mock_block_device.status["update"], "new_version", "") monkeypatch.setitem(mock_block_device.status["update"], "new_version", "")
monkeypatch.setitem(mock_block_device.status["update"], "beta_version", BETA) monkeypatch.setitem(mock_block_device.status["update"], "beta_version", BETA)
@ -276,7 +276,7 @@ async def test_rpc_update(
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
) -> None: ) -> None:
"""Test RPC device update entity.""" """Test RPC device update entity."""
entity_id = "update.test_name_firmware_update" entity_id = "update.test_name_firmware"
monkeypatch.setitem(mock_rpc_device.shelly, "ver", "1") monkeypatch.setitem(mock_rpc_device.shelly, "ver", "1")
monkeypatch.setitem( monkeypatch.setitem(
mock_rpc_device.status["sys"], mock_rpc_device.status["sys"],
@ -391,7 +391,7 @@ async def test_rpc_sleeping_update(
"stable": {"version": "2"}, "stable": {"version": "2"},
}, },
) )
entity_id = f"{UPDATE_DOMAIN}.test_name_firmware_update" entity_id = f"{UPDATE_DOMAIN}.test_name_firmware"
await init_integration(hass, 2, sleep_period=1000) await init_integration(hass, 2, sleep_period=1000)
# Entity should be created when device is online # Entity should be created when device is online
@ -436,7 +436,7 @@ async def test_rpc_restored_sleeping_update(
entity_id = register_entity( entity_id = register_entity(
hass, hass,
UPDATE_DOMAIN, UPDATE_DOMAIN,
"test_name_firmware_update", "test_name_firmware",
"sys-fwupdate", "sys-fwupdate",
entry, entry,
device_id=device.id, device_id=device.id,
@ -495,7 +495,7 @@ async def test_rpc_restored_sleeping_update_no_last_state(
entity_id = register_entity( entity_id = register_entity(
hass, hass,
UPDATE_DOMAIN, UPDATE_DOMAIN,
"test_name_firmware_update", "test_name_firmware",
"sys-fwupdate", "sys-fwupdate",
entry, entry,
device_id=device.id, device_id=device.id,
@ -534,7 +534,7 @@ async def test_rpc_beta_update(
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
) -> None: ) -> None:
"""Test RPC device beta update entity.""" """Test RPC device beta update entity."""
entity_id = "update.test_name_beta_firmware_update" entity_id = "update.test_name_beta_firmware"
monkeypatch.setitem(mock_rpc_device.shelly, "ver", "1") monkeypatch.setitem(mock_rpc_device.shelly, "ver", "1")
monkeypatch.setitem( monkeypatch.setitem(
mock_rpc_device.status["sys"], mock_rpc_device.status["sys"],
@ -679,7 +679,7 @@ async def test_rpc_update_errors(
await hass.services.async_call( await hass.services.async_call(
UPDATE_DOMAIN, UPDATE_DOMAIN,
SERVICE_INSTALL, SERVICE_INSTALL,
{ATTR_ENTITY_ID: "update.test_name_firmware_update"}, {ATTR_ENTITY_ID: "update.test_name_firmware"},
blocking=True, blocking=True,
) )
assert error in str(excinfo.value) assert error in str(excinfo.value)
@ -714,7 +714,7 @@ async def test_rpc_update_auth_error(
await hass.services.async_call( await hass.services.async_call(
UPDATE_DOMAIN, UPDATE_DOMAIN,
SERVICE_INSTALL, SERVICE_INSTALL,
{ATTR_ENTITY_ID: "update.test_name_firmware_update"}, {ATTR_ENTITY_ID: "update.test_name_firmware"},
blocking=True, blocking=True,
) )