mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Ask for IoT class during scaffold (#49647)
Co-authored-by: Milan Meulemans <milan.meulemans@live.be> Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
b92f29997e
commit
9f8e683ae3
@ -99,7 +99,7 @@ def main():
|
||||
if args.develop:
|
||||
print("Running tests")
|
||||
print(f"$ pytest -vvv tests/components/{info.domain}")
|
||||
subprocess.run(["pytest", "-vvv", "tests/components/{info.domain}"])
|
||||
subprocess.run(["pytest", "-vvv", f"tests/components/{info.domain}"])
|
||||
print()
|
||||
|
||||
docs.print_relevant_docs(args.template, info)
|
||||
|
@ -2,6 +2,7 @@
|
||||
import json
|
||||
|
||||
from homeassistant.util import slugify
|
||||
from script.hassfest.manifest import SUPPORTED_IOT_CLASSES
|
||||
|
||||
from .const import COMPONENT_DIR
|
||||
from .error import ExitApp
|
||||
@ -46,6 +47,7 @@ def gather_info(arguments) -> Info:
|
||||
"codeowner": "@developer",
|
||||
"requirement": "aiodevelop==1.2.3",
|
||||
"oauth2": True,
|
||||
"iot_class": "local_polling",
|
||||
}
|
||||
)
|
||||
else:
|
||||
@ -86,6 +88,22 @@ def gather_new_integration(determine_auth: bool) -> Info:
|
||||
]
|
||||
],
|
||||
},
|
||||
"iot_class": {
|
||||
"prompt": (
|
||||
f"""How will your integration gather data?
|
||||
|
||||
Valid values are {', '.join(SUPPORTED_IOT_CLASSES)}
|
||||
|
||||
More info @ https://developers.home-assistant.io/docs/creating_integration_manifest#iot-class
|
||||
"""
|
||||
),
|
||||
"validators": [
|
||||
[
|
||||
f"You need to pick one of {', '.join(SUPPORTED_IOT_CLASSES)}",
|
||||
lambda value: value in SUPPORTED_IOT_CLASSES,
|
||||
]
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
if determine_auth:
|
||||
|
@ -67,10 +67,10 @@ def _append(path: Path, text):
|
||||
path.write_text(path.read_text() + text)
|
||||
|
||||
|
||||
def _custom_tasks(template, info) -> None:
|
||||
def _custom_tasks(template, info: Info) -> None:
|
||||
"""Handle custom tasks for templates."""
|
||||
if template == "integration":
|
||||
changes = {"codeowners": [info.codeowner]}
|
||||
changes = {"codeowners": [info.codeowner], "iot_class": info.iot_class}
|
||||
|
||||
if info.requirement:
|
||||
changes["requirements"] = [info.requirement]
|
||||
|
@ -18,6 +18,7 @@ class Info:
|
||||
is_new: bool = attr.ib()
|
||||
codeowner: str = attr.ib(default=None)
|
||||
requirement: str = attr.ib(default=None)
|
||||
iot_class: str = attr.ib(default=None)
|
||||
authentication: str = attr.ib(default=None)
|
||||
discoverable: str = attr.ib(default=None)
|
||||
oauth2: str = attr.ib(default=None)
|
||||
|
@ -10,7 +10,7 @@ from .const import DOMAIN
|
||||
|
||||
# TODO List the platforms that you want to support.
|
||||
# For your initial PR, limit it to 1 platform.
|
||||
PLATFORMS = ["light"]
|
||||
PLATFORMS = ["binary_sensor"]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
Loading…
x
Reference in New Issue
Block a user