Make Shelly Wall Display thermostat implementation compatible with firmware 1.2.5 (#104812)
parent
3133585d52
commit
b7bf1e9f3f
|
@ -42,12 +42,7 @@ 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 (
|
from .utils import async_remove_shelly_entity, get_device_entry_gen, get_rpc_key_ids
|
||||||
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(
|
||||||
|
@ -131,7 +126,9 @@ def async_setup_rpc_entry(
|
||||||
for id_ in climate_key_ids:
|
for id_ in climate_key_ids:
|
||||||
climate_ids.append(id_)
|
climate_ids.append(id_)
|
||||||
|
|
||||||
if is_relay_used_as_actuator(id_, coordinator.mac, coordinator.device.config):
|
if coordinator.device.shelly.get("relay_in_thermostat", False):
|
||||||
|
# Wall Display relay is used as the thermostat actuator,
|
||||||
|
# we need to remove a switch entity
|
||||||
unique_id = f"{coordinator.mac}-switch:{id_}"
|
unique_id = f"{coordinator.mac}-switch:{id_}"
|
||||||
async_remove_shelly_entity(hass, "switch", unique_id)
|
async_remove_shelly_entity(hass, "switch", unique_id)
|
||||||
|
|
||||||
|
|
|
@ -118,8 +118,9 @@ def async_setup_rpc_entry(
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if coordinator.model == MODEL_WALL_DISPLAY:
|
if coordinator.model == MODEL_WALL_DISPLAY:
|
||||||
if coordinator.device.shelly["relay_operational"]:
|
if not coordinator.device.shelly.get("relay_in_thermostat", False):
|
||||||
# Wall Display in relay mode, we need to remove a climate entity
|
# Wall Display relay is not used as the thermostat actuator,
|
||||||
|
# we need to remove a climate entity
|
||||||
unique_id = f"{coordinator.mac}-thermostat:{id_}"
|
unique_id = f"{coordinator.mac}-thermostat:{id_}"
|
||||||
async_remove_shelly_entity(hass, "climate", unique_id)
|
async_remove_shelly_entity(hass, "climate", unique_id)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -430,10 +430,3 @@ 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", ""
|
|
||||||
)
|
|
||||||
|
|
|
@ -153,7 +153,6 @@ MOCK_CONFIG = {
|
||||||
"id": 0,
|
"id": 0,
|
||||||
"enable": True,
|
"enable": True,
|
||||||
"type": "heating",
|
"type": "heating",
|
||||||
"actuator": f"shelly://shellywalldisplay-{MOCK_MAC.lower()}/c/switch:0",
|
|
||||||
},
|
},
|
||||||
"sys": {
|
"sys": {
|
||||||
"ui_data": {},
|
"ui_data": {},
|
||||||
|
@ -181,7 +180,7 @@ MOCK_SHELLY_RPC = {
|
||||||
"auth_en": False,
|
"auth_en": False,
|
||||||
"auth_domain": None,
|
"auth_domain": None,
|
||||||
"profile": "cover",
|
"profile": "cover",
|
||||||
"relay_operational": False,
|
"relay_in_thermostat": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
MOCK_STATUS_COAP = {
|
MOCK_STATUS_COAP = {
|
||||||
|
|
|
@ -283,7 +283,8 @@ async def test_block_device_gas_valve(
|
||||||
|
|
||||||
|
|
||||||
async def test_wall_display_thermostat_mode(
|
async def test_wall_display_thermostat_mode(
|
||||||
hass: HomeAssistant, mock_rpc_device, monkeypatch
|
hass: HomeAssistant,
|
||||||
|
mock_rpc_device,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test Wall Display in thermostat mode."""
|
"""Test Wall Display in thermostat mode."""
|
||||||
await init_integration(hass, 2, model=MODEL_WALL_DISPLAY)
|
await init_integration(hass, 2, model=MODEL_WALL_DISPLAY)
|
||||||
|
@ -294,7 +295,10 @@ async def test_wall_display_thermostat_mode(
|
||||||
|
|
||||||
|
|
||||||
async def test_wall_display_relay_mode(
|
async def test_wall_display_relay_mode(
|
||||||
hass: HomeAssistant, entity_registry, mock_rpc_device, monkeypatch
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
mock_rpc_device,
|
||||||
|
monkeypatch,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test Wall Display in thermostat mode."""
|
"""Test Wall Display in thermostat mode."""
|
||||||
entity_id = register_entity(
|
entity_id = register_entity(
|
||||||
|
@ -305,8 +309,7 @@ async def test_wall_display_relay_mode(
|
||||||
)
|
)
|
||||||
|
|
||||||
new_shelly = deepcopy(mock_rpc_device.shelly)
|
new_shelly = deepcopy(mock_rpc_device.shelly)
|
||||||
new_shelly["relay_operational"] = True
|
new_shelly["relay_in_thermostat"] = False
|
||||||
|
|
||||||
monkeypatch.setattr(mock_rpc_device, "shelly", new_shelly)
|
monkeypatch.setattr(mock_rpc_device, "shelly", new_shelly)
|
||||||
|
|
||||||
await init_integration(hass, 2, model=MODEL_WALL_DISPLAY)
|
await init_integration(hass, 2, model=MODEL_WALL_DISPLAY)
|
||||||
|
|
Loading…
Reference in New Issue