Add tuya snapshot tests for Avatto WT598 thermostat (#148398)

This commit is contained in:
epenet 2025-07-08 13:40:16 +02:00 committed by GitHub
parent b775ba2955
commit 1a8d4c5041
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 365 additions and 0 deletions

View File

@ -49,6 +49,11 @@ DEVICE_MOCKS = {
Platform.SELECT,
Platform.SWITCH,
],
"wk_wifi_smart_gas_boiler_thermostat": [
# https://github.com/orgs/home-assistant/discussions/243
Platform.CLIMATE,
Platform.SWITCH,
],
}

View File

@ -0,0 +1,188 @@
{
"endpoint": "https://apigw.tuyaeu.com",
"terminal_id": "xxxxxxxxxxxxxxxxxxx",
"mqtt_connected": true,
"disabled_by": null,
"disabled_polling": false,
"id": "bfb45cb8a9452fba66lexg",
"name": "WiFi Smart Gas Boiler Thermostat ",
"category": "wk",
"product_id": "fi6dne5tu4t1nm6j",
"product_name": "WiFi Smart Gas Boiler Thermostat ",
"online": true,
"sub": false,
"time_zone": "+02:00",
"active_time": "2025-07-05T17:50:52+00:00",
"create_time": "2025-07-05T17:50:52+00:00",
"update_time": "2025-07-05T17:50:52+00:00",
"function": {
"switch": {
"type": "Boolean",
"value": {}
},
"mode": {
"type": "Enum",
"value": {
"range": ["auto"]
}
},
"temp_set": {
"type": "Integer",
"value": {
"unit": "\u2103",
"min": 50,
"max": 350,
"scale": 1,
"step": 5
}
},
"temp_correction": {
"type": "Integer",
"value": {
"unit": "\u2103",
"min": -99,
"max": 99,
"scale": 1,
"step": 1
}
},
"upper_temp": {
"type": "Integer",
"value": {
"unit": "\u2103",
"min": 150,
"max": 350,
"scale": 1,
"step": 5
}
},
"lower_temp": {
"type": "Integer",
"value": {
"unit": "\u2103",
"min": 50,
"max": 140,
"scale": 1,
"step": 5
}
},
"child_lock": {
"type": "Boolean",
"value": {}
},
"frost": {
"type": "Boolean",
"value": {}
},
"factory_reset": {
"type": "Boolean",
"value": {}
}
},
"status_range": {
"switch": {
"type": "Boolean",
"value": {}
},
"mode": {
"type": "Enum",
"value": {
"range": ["auto"]
}
},
"temp_set": {
"type": "Integer",
"value": {
"unit": "\u2103",
"min": 50,
"max": 350,
"scale": 1,
"step": 5
}
},
"temp_current": {
"type": "Integer",
"value": {
"unit": "\u2103",
"min": 0,
"max": 800,
"scale": 1,
"step": 1
}
},
"temp_correction": {
"type": "Integer",
"value": {
"unit": "\u2103",
"min": -99,
"max": 99,
"scale": 1,
"step": 1
}
},
"fault": {
"type": "Bitmap",
"value": {
"label": ["battery_temp_fault"]
}
},
"upper_temp": {
"type": "Integer",
"value": {
"unit": "\u2103",
"min": 150,
"max": 350,
"scale": 1,
"step": 5
}
},
"lower_temp": {
"type": "Integer",
"value": {
"unit": "\u2103",
"min": 50,
"max": 140,
"scale": 1,
"step": 5
}
},
"battery_percentage": {
"type": "Integer",
"value": {
"unit": "%",
"min": 0,
"max": 100,
"scale": 0,
"step": 1
}
},
"child_lock": {
"type": "Boolean",
"value": {}
},
"frost": {
"type": "Boolean",
"value": {}
},
"factory_reset": {
"type": "Boolean",
"value": {}
}
},
"status": {
"switch": true,
"mode": "auto",
"temp_set": 220,
"temp_current": 249,
"temp_correction": -15,
"fault": 0,
"upper_temp": 350,
"lower_temp": 50,
"battery_percentage": 100,
"child_lock": false,
"frost": false,
"factory_reset": false
},
"set_up": true,
"support_local": true
}

View File

@ -0,0 +1,67 @@
# serializer version: 1
# name: test_platform_setup_and_discovery[wk_wifi_smart_gas_boiler_thermostat][climate.wifi_smart_gas_boiler_thermostat-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.OFF: 'off'>,
<HVACMode.HEAT_COOL: 'heat_cool'>,
]),
'max_temp': 35.0,
'min_temp': 5.0,
'target_temp_step': 0.5,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.wifi_smart_gas_boiler_thermostat',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': None,
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': <ClimateEntityFeature: 385>,
'translation_key': None,
'unique_id': 'tuya.bfb45cb8a9452fba66lexg',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[wk_wifi_smart_gas_boiler_thermostat][climate.wifi_smart_gas_boiler_thermostat-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': 24.9,
'friendly_name': 'WiFi Smart Gas Boiler Thermostat ',
'hvac_modes': list([
<HVACMode.OFF: 'off'>,
<HVACMode.HEAT_COOL: 'heat_cool'>,
]),
'max_temp': 35.0,
'min_temp': 5.0,
'supported_features': <ClimateEntityFeature: 385>,
'target_temp_step': 0.5,
'temperature': 22.0,
}),
'context': <ANY>,
'entity_id': 'climate.wifi_smart_gas_boiler_thermostat',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'heat_cool',
})
# ---

View File

@ -630,3 +630,51 @@
'state': 'unavailable',
})
# ---
# name: test_platform_setup_and_discovery[wk_wifi_smart_gas_boiler_thermostat][switch.wifi_smart_gas_boiler_thermostat_child_lock-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.wifi_smart_gas_boiler_thermostat_child_lock',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Child lock',
'platform': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'child_lock',
'unique_id': 'tuya.bfb45cb8a9452fba66lexgchild_lock',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[wk_wifi_smart_gas_boiler_thermostat][switch.wifi_smart_gas_boiler_thermostat_child_lock-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WiFi Smart Gas Boiler Thermostat Child lock',
}),
'context': <ANY>,
'entity_id': 'switch.wifi_smart_gas_boiler_thermostat_child_lock',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---

View File

@ -0,0 +1,57 @@
"""Test Tuya climate platform."""
from __future__ import annotations
from unittest.mock import patch
import pytest
from syrupy.assertion import SnapshotAssertion
from tuya_sharing import CustomerDevice
from homeassistant.components.tuya import ManagerCompat
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import DEVICE_MOCKS, initialize_entry
from tests.common import MockConfigEntry, snapshot_platform
@pytest.mark.parametrize(
"mock_device_code",
[k for k, v in DEVICE_MOCKS.items() if Platform.CLIMATE in v],
)
@patch("homeassistant.components.tuya.PLATFORMS", [Platform.CLIMATE])
async def test_platform_setup_and_discovery(
hass: HomeAssistant,
mock_manager: ManagerCompat,
mock_config_entry: MockConfigEntry,
mock_device: CustomerDevice,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test platform setup and discovery."""
await initialize_entry(hass, mock_manager, mock_config_entry, mock_device)
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
@pytest.mark.parametrize(
"mock_device_code",
[k for k, v in DEVICE_MOCKS.items() if Platform.CLIMATE not in v],
)
@patch("homeassistant.components.tuya.PLATFORMS", [Platform.CLIMATE])
async def test_platform_setup_no_discovery(
hass: HomeAssistant,
mock_manager: ManagerCompat,
mock_config_entry: MockConfigEntry,
mock_device: CustomerDevice,
entity_registry: er.EntityRegistry,
) -> None:
"""Test platform setup and discovery."""
await initialize_entry(hass, mock_manager, mock_config_entry, mock_device)
assert not er.async_entries_for_config_entry(
entity_registry, mock_config_entry.entry_id
)