mirror of
https://github.com/home-assistant/core.git
synced 2026-04-02 16:36:08 +01:00
Fix handling of several thermostat QuickApp's in fibaro (#164344)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -275,8 +275,11 @@ class FibaroController:
|
||||
# otherwise add the first visible device in the group
|
||||
# which is a hack, but solves a problem with FGT having
|
||||
# hidden compatibility devices before the real device
|
||||
if last_climate_parent != device.parent_fibaro_id or (
|
||||
device.has_endpoint_id and last_endpoint != device.endpoint_id
|
||||
# Second hack is for quickapps which have parent id 0 and no children
|
||||
if (
|
||||
last_climate_parent != device.parent_fibaro_id
|
||||
or (device.has_endpoint_id and last_endpoint != device.endpoint_id)
|
||||
or device.parent_fibaro_id == 0
|
||||
):
|
||||
_LOGGER.debug("Handle separately")
|
||||
self.fibaro_devices[platform].append(device)
|
||||
|
||||
@@ -286,6 +286,68 @@ def mock_thermostat_with_operating_mode() -> Mock:
|
||||
return climate
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_thermostat_quickapp_1() -> Mock:
|
||||
"""Fixture for a thermostat."""
|
||||
climate = Mock()
|
||||
climate.fibaro_id = 6
|
||||
climate.parent_fibaro_id = 0
|
||||
climate.has_endpoint_id = False
|
||||
climate.name = "Test climate"
|
||||
climate.room_id = 1
|
||||
climate.dead = False
|
||||
climate.visible = True
|
||||
climate.enabled = True
|
||||
climate.type = "com.fibaro.hvacSystemHeat"
|
||||
climate.base_type = "com.fibaro.hvacSystem"
|
||||
climate.properties = {"manufacturer": ""}
|
||||
climate.actions = {"setHeatingThermostatSetpoint": 1, "setThermostatMode": 1}
|
||||
climate.supported_features = {}
|
||||
climate.has_supported_operating_modes = False
|
||||
climate.has_supported_thermostat_modes = True
|
||||
climate.supported_thermostat_modes = ["Off", "Heat"]
|
||||
climate.has_thermostat_mode = True
|
||||
climate.thermostat_mode = "Heat"
|
||||
climate.has_unit = False
|
||||
climate.has_heating_thermostat_setpoint = False
|
||||
climate.has_heating_thermostat_setpoint_future = False
|
||||
value_mock = Mock()
|
||||
value_mock.has_value = False
|
||||
climate.value = value_mock
|
||||
return climate
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_thermostat_quickapp_2() -> Mock:
|
||||
"""Fixture for a thermostat."""
|
||||
climate = Mock()
|
||||
climate.fibaro_id = 7
|
||||
climate.parent_fibaro_id = 0
|
||||
climate.has_endpoint_id = False
|
||||
climate.name = "Test climate 2"
|
||||
climate.room_id = 1
|
||||
climate.dead = False
|
||||
climate.visible = True
|
||||
climate.enabled = True
|
||||
climate.type = "com.fibaro.hvacSystemHeat"
|
||||
climate.base_type = "com.fibaro.hvacSystem"
|
||||
climate.properties = {"manufacturer": ""}
|
||||
climate.actions = {"setHeatingThermostatSetpoint": 1, "setThermostatMode": 1}
|
||||
climate.supported_features = {}
|
||||
climate.has_supported_operating_modes = False
|
||||
climate.has_supported_thermostat_modes = True
|
||||
climate.supported_thermostat_modes = ["Off", "Heat"]
|
||||
climate.has_thermostat_mode = True
|
||||
climate.thermostat_mode = "Heat"
|
||||
climate.has_unit = False
|
||||
climate.has_heating_thermostat_setpoint = False
|
||||
climate.has_heating_thermostat_setpoint_future = False
|
||||
value_mock = Mock()
|
||||
value_mock.has_value = False
|
||||
climate.value = value_mock
|
||||
return climate
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_fan_device() -> Mock:
|
||||
"""Fixture for a fan endpoint of a thermostat device."""
|
||||
|
||||
@@ -41,6 +41,34 @@ async def test_climate_setup(
|
||||
)
|
||||
|
||||
|
||||
async def test_climate_setup_2_quickapps(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_fibaro_client: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_thermostat_quickapp_1: Mock,
|
||||
mock_thermostat_quickapp_2: Mock,
|
||||
mock_room: Mock,
|
||||
) -> None:
|
||||
"""Test that the climate creates entities for more than one QuickApp."""
|
||||
|
||||
# Arrange
|
||||
mock_fibaro_client.read_rooms.return_value = [mock_room]
|
||||
mock_fibaro_client.read_devices.return_value = [
|
||||
mock_thermostat_quickapp_1,
|
||||
mock_thermostat_quickapp_2,
|
||||
]
|
||||
|
||||
with patch("homeassistant.components.fibaro.PLATFORMS", [Platform.CLIMATE]):
|
||||
# Act
|
||||
await init_integration(hass, mock_config_entry)
|
||||
# Assert
|
||||
entry1 = entity_registry.async_get("climate.room_1_test_climate_6")
|
||||
assert entry1
|
||||
entry2 = entity_registry.async_get("climate.room_1_test_climate_2_7")
|
||||
assert entry2
|
||||
|
||||
|
||||
async def test_hvac_mode_preset(
|
||||
hass: HomeAssistant,
|
||||
mock_fibaro_client: Mock,
|
||||
|
||||
Reference in New Issue
Block a user