Initial implementation for modularized smartdevice (#757)

The initial steps to modularize the smartdevice. Modules are initialized based on the component negotiation, and each module can indicate which features it supports and which queries should be run during the update cycle.
This commit is contained in:
Teemu R
2024-02-19 18:01:31 +01:00
committed by GitHub
parent e86dcb6bf5
commit 11719991c0
21 changed files with 408 additions and 156 deletions

View File

@@ -60,6 +60,11 @@ async def test_childdevice_properties(dev: SmartChildDevice):
)
for prop in properties:
name, _ = prop
# Skip emeter and time properties
# TODO: needs API cleanup, emeter* should probably be removed in favor
# of access through features/modules, handling of time* needs decision.
if name.startswith("emeter_") or name.startswith("time"):
continue
try:
_ = getattr(first, name)
except Exception as ex:

View File

@@ -310,16 +310,13 @@ async def test_modules_not_supported(dev: IotDevice):
@device_smart
async def test_update_sub_errors(dev: SmartDevice, caplog):
async def test_try_get_response(dev: SmartDevice, caplog):
mock_response: dict = {
"get_device_info": {},
"get_device_usage": SmartErrorCode.PARAMS_ERROR,
"get_device_time": {},
"get_device_info": SmartErrorCode.PARAMS_ERROR,
}
caplog.set_level(logging.DEBUG)
with patch.object(dev.protocol, "query", return_value=mock_response):
await dev.update()
msg = "Error PARAMS_ERROR(-1008) getting request get_device_usage for device 127.0.0.123"
dev._try_get_response(mock_response, "get_device_info", {})
msg = "Error PARAMS_ERROR(-1008) getting request get_device_info for device 127.0.0.123"
assert msg in caplog.text