mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
Move Shelly thermostat check to status endpoint (#110543)
* Move Shelly thermostat check to status endpoint * fix key path
This commit is contained in:
parent
eee6a119d5
commit
538ef7764e
@ -43,7 +43,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_rpc_thermostat_internal_actuator,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@ -127,7 +132,7 @@ 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 coordinator.device.shelly.get("relay_in_thermostat", False):
|
if is_rpc_thermostat_internal_actuator(coordinator.device.status):
|
||||||
# Wall Display relay is used as the thermostat actuator,
|
# Wall Display relay is used as the thermostat actuator,
|
||||||
# we need to remove a switch entity
|
# we need to remove a switch entity
|
||||||
unique_id = f"{coordinator.mac}-switch:{id_}"
|
unique_id = f"{coordinator.mac}-switch:{id_}"
|
||||||
|
@ -41,6 +41,7 @@ from .utils import (
|
|||||||
get_rpc_key_ids,
|
get_rpc_key_ids,
|
||||||
is_block_channel_type_light,
|
is_block_channel_type_light,
|
||||||
is_rpc_channel_type_light,
|
is_rpc_channel_type_light,
|
||||||
|
is_rpc_thermostat_internal_actuator,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -134,7 +135,7 @@ def async_setup_rpc_entry(
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if coordinator.model == MODEL_WALL_DISPLAY:
|
if coordinator.model == MODEL_WALL_DISPLAY:
|
||||||
if not coordinator.device.shelly.get("relay_in_thermostat", False):
|
if not is_rpc_thermostat_internal_actuator(coordinator.device.status):
|
||||||
# Wall Display relay is not used as the thermostat actuator,
|
# Wall Display relay is not used as the thermostat actuator,
|
||||||
# we need to remove a climate entity
|
# we need to remove a climate entity
|
||||||
unique_id = f"{coordinator.mac}-thermostat:{id_}"
|
unique_id = f"{coordinator.mac}-thermostat:{id_}"
|
||||||
|
@ -367,6 +367,11 @@ def is_rpc_channel_type_light(config: dict[str, Any], channel: int) -> bool:
|
|||||||
return cast(str, con_types[channel]).lower().startswith("light")
|
return cast(str, con_types[channel]).lower().startswith("light")
|
||||||
|
|
||||||
|
|
||||||
|
def is_rpc_thermostat_internal_actuator(status: dict[str, Any]) -> bool:
|
||||||
|
"""Return true if the thermostat uses an internal relay."""
|
||||||
|
return cast(bool, status["sys"].get("relay_in_thermostat", False))
|
||||||
|
|
||||||
|
|
||||||
def get_rpc_input_triggers(device: RpcDevice) -> list[tuple[str, str]]:
|
def get_rpc_input_triggers(device: RpcDevice) -> list[tuple[str, str]]:
|
||||||
"""Return list of input triggers for RPC device."""
|
"""Return list of input triggers for RPC device."""
|
||||||
triggers = []
|
triggers = []
|
||||||
|
@ -201,7 +201,6 @@ MOCK_SHELLY_RPC = {
|
|||||||
"auth_en": False,
|
"auth_en": False,
|
||||||
"auth_domain": None,
|
"auth_domain": None,
|
||||||
"profile": "cover",
|
"profile": "cover",
|
||||||
"relay_in_thermostat": True,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MOCK_STATUS_COAP = {
|
MOCK_STATUS_COAP = {
|
||||||
@ -248,7 +247,8 @@ MOCK_STATUS_RPC = {
|
|||||||
"available_updates": {
|
"available_updates": {
|
||||||
"beta": {"version": "some_beta_version"},
|
"beta": {"version": "some_beta_version"},
|
||||||
"stable": {"version": "some_beta_version"},
|
"stable": {"version": "some_beta_version"},
|
||||||
}
|
},
|
||||||
|
"relay_in_thermostat": True,
|
||||||
},
|
},
|
||||||
"voltmeter": {"voltage": 4.321},
|
"voltmeter": {"voltage": 4.321},
|
||||||
"wifi": {"rssi": -63},
|
"wifi": {"rssi": -63},
|
||||||
|
@ -146,7 +146,8 @@ async def test_rpc_config_entry_diagnostics(
|
|||||||
"available_updates": {
|
"available_updates": {
|
||||||
"beta": {"version": "some_beta_version"},
|
"beta": {"version": "some_beta_version"},
|
||||||
"stable": {"version": "some_beta_version"},
|
"stable": {"version": "some_beta_version"},
|
||||||
}
|
},
|
||||||
|
"relay_in_thermostat": True,
|
||||||
},
|
},
|
||||||
"wifi": {"rssi": -63},
|
"wifi": {"rssi": -63},
|
||||||
},
|
},
|
||||||
|
@ -327,9 +327,9 @@ async def test_wall_display_relay_mode(
|
|||||||
climate_entity_id = "climate.test_name"
|
climate_entity_id = "climate.test_name"
|
||||||
switch_entity_id = "switch.test_switch_0"
|
switch_entity_id = "switch.test_switch_0"
|
||||||
|
|
||||||
new_shelly = deepcopy(mock_rpc_device.shelly)
|
new_status = deepcopy(mock_rpc_device.status)
|
||||||
new_shelly["relay_in_thermostat"] = False
|
new_status["sys"]["relay_in_thermostat"] = False
|
||||||
monkeypatch.setattr(mock_rpc_device, "shelly", new_shelly)
|
monkeypatch.setattr(mock_rpc_device, "status", new_status)
|
||||||
|
|
||||||
await init_integration(hass, 2, model=MODEL_WALL_DISPLAY)
|
await init_integration(hass, 2, model=MODEL_WALL_DISPLAY)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user