mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 05:47:10 +00:00
Improve discovery rule in IQS validation (#132251)
* Improve discovery rule in IQS validation * Adjust fyta/powerfox
This commit is contained in:
parent
ea9301aa9e
commit
8c6d638354
@ -53,8 +53,8 @@ rules:
|
|||||||
status: exempt
|
status: exempt
|
||||||
comment: No noisy entities.
|
comment: No noisy entities.
|
||||||
discovery:
|
discovery:
|
||||||
status: exempt
|
status: done
|
||||||
comment: bug in hassfest
|
comment: DHCP
|
||||||
stale-devices: done
|
stale-devices: done
|
||||||
diagnostics: done
|
diagnostics: done
|
||||||
exception-translations: done
|
exception-translations: done
|
||||||
|
@ -57,9 +57,9 @@ rules:
|
|||||||
comment: |
|
comment: |
|
||||||
This integration is connecting to a cloud service.
|
This integration is connecting to a cloud service.
|
||||||
discovery:
|
discovery:
|
||||||
status: exempt
|
status: done
|
||||||
comment: |
|
comment: |
|
||||||
It can find poweropti devices via zeroconf, but will start a normal user flow.
|
It can find poweropti devices via zeroconf, and will start a normal user flow.
|
||||||
docs-data-update: done
|
docs-data-update: done
|
||||||
docs-examples: todo
|
docs-examples: todo
|
||||||
docs-known-limitations: done
|
docs-known-limitations: done
|
||||||
|
@ -7,23 +7,32 @@ import ast
|
|||||||
|
|
||||||
from script.hassfest.model import Integration
|
from script.hassfest.model import Integration
|
||||||
|
|
||||||
DISCOVERY_FUNCTIONS = [
|
MANIFEST_KEYS = [
|
||||||
"async_step_discovery",
|
"bluetooth",
|
||||||
|
"dhcp",
|
||||||
|
"homekit",
|
||||||
|
"mqtt",
|
||||||
|
"ssdp",
|
||||||
|
"usb",
|
||||||
|
"zeroconf",
|
||||||
|
]
|
||||||
|
CONFIG_FLOW_STEPS = {
|
||||||
"async_step_bluetooth",
|
"async_step_bluetooth",
|
||||||
|
"async_step_discovery",
|
||||||
|
"async_step_dhcp",
|
||||||
"async_step_hassio",
|
"async_step_hassio",
|
||||||
"async_step_homekit",
|
"async_step_homekit",
|
||||||
"async_step_mqtt",
|
"async_step_mqtt",
|
||||||
"async_step_ssdp",
|
"async_step_ssdp",
|
||||||
"async_step_zeroconf",
|
|
||||||
"async_step_dhcp",
|
|
||||||
"async_step_usb",
|
"async_step_usb",
|
||||||
]
|
"async_step_zeroconf",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def _has_discovery_function(module: ast.Module) -> bool:
|
def _has_discovery_function(module: ast.Module) -> bool:
|
||||||
"""Test if the module defines at least one of the discovery functions."""
|
"""Test if the module defines at least one of the discovery functions."""
|
||||||
return any(
|
return any(
|
||||||
type(item) is ast.AsyncFunctionDef and item.name in DISCOVERY_FUNCTIONS
|
type(item) is ast.AsyncFunctionDef and item.name in CONFIG_FLOW_STEPS
|
||||||
for item in ast.walk(module)
|
for item in ast.walk(module)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,11 +44,15 @@ def validate(integration: Integration) -> list[str] | None:
|
|||||||
if not config_flow_file.exists():
|
if not config_flow_file.exists():
|
||||||
return ["Integration is missing config_flow.py"]
|
return ["Integration is missing config_flow.py"]
|
||||||
|
|
||||||
config_flow = ast.parse(config_flow_file.read_text())
|
# Check manifest
|
||||||
|
if any(key in integration.manifest for key in MANIFEST_KEYS):
|
||||||
|
return None
|
||||||
|
|
||||||
if not _has_discovery_function(config_flow):
|
# Fallback => check config_flow step
|
||||||
|
config_flow = ast.parse(config_flow_file.read_text())
|
||||||
|
if not (_has_discovery_function(config_flow)):
|
||||||
return [
|
return [
|
||||||
f"Integration is missing one of {DISCOVERY_FUNCTIONS} "
|
f"Integration is missing one of {CONFIG_FLOW_STEPS} "
|
||||||
f"in {config_flow_file}"
|
f"in {config_flow_file}"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user