mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
Add logging to Tuya for devices that cannot be supported (#149192)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
9a9f65dc36
commit
4730c5b831
@ -153,6 +153,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: TuyaConfigEntry) -> bool
|
|||||||
# Register known device IDs
|
# Register known device IDs
|
||||||
device_registry = dr.async_get(hass)
|
device_registry = dr.async_get(hass)
|
||||||
for device in manager.device_map.values():
|
for device in manager.device_map.values():
|
||||||
|
if not device.status and not device.status_range and not device.function:
|
||||||
|
# If the device has no status, status_range or function,
|
||||||
|
# it cannot be supported
|
||||||
|
LOGGER.info(
|
||||||
|
"Device %s (%s) has been ignored as it does not provide any"
|
||||||
|
" standard instructions (status, status_range and function are"
|
||||||
|
" all empty) - see %s",
|
||||||
|
device.product_name,
|
||||||
|
device.id,
|
||||||
|
"https://github.com/tuya/tuya-device-sharing-sdk/issues/11",
|
||||||
|
)
|
||||||
device_registry.async_get_or_create(
|
device_registry.async_get_or_create(
|
||||||
config_entry_id=entry.entry_id,
|
config_entry_id=entry.entry_id,
|
||||||
identifiers={(DOMAIN, device.id)},
|
identifiers={(DOMAIN, device.id)},
|
||||||
|
@ -148,6 +148,10 @@ DEVICE_MOCKS = {
|
|||||||
Platform.SELECT,
|
Platform.SELECT,
|
||||||
Platform.SWITCH,
|
Platform.SWITCH,
|
||||||
],
|
],
|
||||||
|
"ydkt_dolceclima_unsupported": [
|
||||||
|
# https://github.com/orgs/home-assistant/discussions/288
|
||||||
|
# unsupported device - no platforms
|
||||||
|
],
|
||||||
"wk_wifi_smart_gas_boiler_thermostat": [
|
"wk_wifi_smart_gas_boiler_thermostat": [
|
||||||
# https://github.com/orgs/home-assistant/discussions/243
|
# https://github.com/orgs/home-assistant/discussions/243
|
||||||
Platform.CLIMATE,
|
Platform.CLIMATE,
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"endpoint": "https://apigw.tuyaeu.com",
|
||||||
|
"terminal_id": "mock_terminal_id",
|
||||||
|
"mqtt_connected": true,
|
||||||
|
"disabled_by": null,
|
||||||
|
"disabled_polling": false,
|
||||||
|
"id": "mock_device_id",
|
||||||
|
"name": "DOLCECLIMA 10 HP WIFI",
|
||||||
|
"category": "ydkt",
|
||||||
|
"product_id": "jevroj5aguwdbs2e",
|
||||||
|
"product_name": "DOLCECLIMA 10 HP WIFI",
|
||||||
|
"online": true,
|
||||||
|
"sub": false,
|
||||||
|
"time_zone": "+02:00",
|
||||||
|
"active_time": "2025-07-09T18:39:25+00:00",
|
||||||
|
"create_time": "2025-07-09T18:39:25+00:00",
|
||||||
|
"update_time": "2025-07-09T18:39:25+00:00",
|
||||||
|
"function": {},
|
||||||
|
"status_range": {},
|
||||||
|
"status": {},
|
||||||
|
"set_up": false,
|
||||||
|
"support_local": true
|
||||||
|
}
|
36
tests/components/tuya/snapshots/test_init.ambr
Normal file
36
tests/components/tuya/snapshots/test_init.ambr
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# serializer version: 1
|
||||||
|
# name: test_unsupported_device[ydkt_dolceclima_unsupported]
|
||||||
|
list([
|
||||||
|
DeviceRegistryEntrySnapshot({
|
||||||
|
'area_id': None,
|
||||||
|
'config_entries': <ANY>,
|
||||||
|
'config_entries_subentries': <ANY>,
|
||||||
|
'configuration_url': None,
|
||||||
|
'connections': set({
|
||||||
|
}),
|
||||||
|
'disabled_by': None,
|
||||||
|
'entry_type': None,
|
||||||
|
'hw_version': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'identifiers': set({
|
||||||
|
tuple(
|
||||||
|
'tuya',
|
||||||
|
'mock_device_id',
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
'is_new': False,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'manufacturer': 'Tuya',
|
||||||
|
'model': 'DOLCECLIMA 10 HP WIFI (unsupported)',
|
||||||
|
'model_id': 'jevroj5aguwdbs2e',
|
||||||
|
'name': 'DOLCECLIMA 10 HP WIFI',
|
||||||
|
'name_by_user': None,
|
||||||
|
'primary_config_entry': <ANY>,
|
||||||
|
'serial_number': None,
|
||||||
|
'suggested_area': None,
|
||||||
|
'sw_version': None,
|
||||||
|
'via_device_id': None,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
# ---
|
49
tests/components/tuya/test_init.py
Normal file
49
tests/components/tuya/test_init.py
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
"""Test Tuya initialization."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
from tuya_sharing import CustomerDevice
|
||||||
|
|
||||||
|
from homeassistant.components.tuya import ManagerCompat
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
|
||||||
|
from . import initialize_entry
|
||||||
|
|
||||||
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("mock_device_code", ["ydkt_dolceclima_unsupported"])
|
||||||
|
async def test_unsupported_device(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_manager: ManagerCompat,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
mock_device: CustomerDevice,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
) -> None:
|
||||||
|
"""Test unsupported device."""
|
||||||
|
|
||||||
|
await initialize_entry(hass, mock_manager, mock_config_entry, mock_device)
|
||||||
|
|
||||||
|
# Device is registered
|
||||||
|
assert (
|
||||||
|
dr.async_entries_for_config_entry(device_registry, mock_config_entry.entry_id)
|
||||||
|
== snapshot
|
||||||
|
)
|
||||||
|
# No entities registered
|
||||||
|
assert not er.async_entries_for_config_entry(
|
||||||
|
entity_registry, mock_config_entry.entry_id
|
||||||
|
)
|
||||||
|
|
||||||
|
# Information log entry added
|
||||||
|
assert (
|
||||||
|
"Device DOLCECLIMA 10 HP WIFI (mock_device_id) has been ignored"
|
||||||
|
" as it does not provide any standard instructions (status, status_range"
|
||||||
|
" and function are all empty) - see "
|
||||||
|
"https://github.com/tuya/tuya-device-sharing-sdk/issues/11" in caplog.text
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user