mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Remove Shelly Wall Display switch entity only if the relay is used as the thermostat actuator (#104506)
This commit is contained in:
parent
c831802774
commit
14387cf94b
@ -42,7 +42,12 @@ from .const import (
|
|||||||
)
|
)
|
||||||
from .coordinator import ShellyBlockCoordinator, ShellyRpcCoordinator, get_entry_data
|
from .coordinator import ShellyBlockCoordinator, ShellyRpcCoordinator, get_entry_data
|
||||||
from .entity import ShellyRpcEntity
|
from .entity import ShellyRpcEntity
|
||||||
from .utils import async_remove_shelly_entity, get_device_entry_gen, get_rpc_key_ids
|
from .utils import (
|
||||||
|
async_remove_shelly_entity,
|
||||||
|
get_device_entry_gen,
|
||||||
|
get_rpc_key_ids,
|
||||||
|
is_relay_used_as_actuator,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@ -125,8 +130,10 @@ def async_setup_rpc_entry(
|
|||||||
climate_ids = []
|
climate_ids = []
|
||||||
for id_ in climate_key_ids:
|
for id_ in climate_key_ids:
|
||||||
climate_ids.append(id_)
|
climate_ids.append(id_)
|
||||||
unique_id = f"{coordinator.mac}-switch:{id_}"
|
|
||||||
async_remove_shelly_entity(hass, "switch", unique_id)
|
if is_relay_used_as_actuator(id_, coordinator.mac, coordinator.device.config):
|
||||||
|
unique_id = f"{coordinator.mac}-switch:{id_}"
|
||||||
|
async_remove_shelly_entity(hass, "switch", unique_id)
|
||||||
|
|
||||||
if not climate_ids:
|
if not climate_ids:
|
||||||
return
|
return
|
||||||
|
@ -430,3 +430,10 @@ def get_release_url(gen: int, model: str, beta: bool) -> str | None:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
return GEN1_RELEASE_URL if gen == 1 else GEN2_RELEASE_URL
|
return GEN1_RELEASE_URL if gen == 1 else GEN2_RELEASE_URL
|
||||||
|
|
||||||
|
|
||||||
|
def is_relay_used_as_actuator(relay_id: int, mac: str, config: dict[str, Any]) -> bool:
|
||||||
|
"""Return True if an internal relay is used as the thermostat actuator."""
|
||||||
|
return f"{mac}/c/switch:{relay_id}".lower() in config[f"thermostat:{relay_id}"].get(
|
||||||
|
"actuator", ""
|
||||||
|
)
|
||||||
|
@ -149,7 +149,12 @@ MOCK_CONFIG = {
|
|||||||
"light:0": {"name": "test light_0"},
|
"light:0": {"name": "test light_0"},
|
||||||
"switch:0": {"name": "test switch_0"},
|
"switch:0": {"name": "test switch_0"},
|
||||||
"cover:0": {"name": "test cover_0"},
|
"cover:0": {"name": "test cover_0"},
|
||||||
"thermostat:0": {"id": 0, "enable": True, "type": "heating"},
|
"thermostat:0": {
|
||||||
|
"id": 0,
|
||||||
|
"enable": True,
|
||||||
|
"type": "heating",
|
||||||
|
"actuator": f"shelly://shellywalldisplay-{MOCK_MAC.lower()}/c/switch:0",
|
||||||
|
},
|
||||||
"sys": {
|
"sys": {
|
||||||
"ui_data": {},
|
"ui_data": {},
|
||||||
"device": {"name": "Test name"},
|
"device": {"name": "Test name"},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user