generated from sirmrak/ha-integration-template
@@ -0,0 +1,23 @@
|
||||
"""The test_me integration."""
|
||||
import logging
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from .const import DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
||||
"""Set up the test_me component from yaml configuration."""
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
return True
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up test_me from a config entry."""
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
hass.data[DOMAIN][entry.entry_id] = {}
|
||||
await hass.config_entries.async_forward_entry_setups(entry, ["sensor"])
|
||||
return True
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload a config entry."""
|
||||
return await hass.config_entries.async_unload_platforms(entry, ["sensor"])
|
||||
@@ -0,0 +1,25 @@
|
||||
"""Config flow for test_me integration."""
|
||||
from __future__ import annotations
|
||||
import logging
|
||||
from typing import Any
|
||||
import voluptuous as vol
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.core import HomeAssistant
|
||||
from .const import DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
STEP_USER_DATA_SCHEMA = vol.Schema({
|
||||
vol.Required("host"): str,
|
||||
})
|
||||
|
||||
class ConfigFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for test_me."""
|
||||
VERSION = 1
|
||||
|
||||
async def async_step_user(self, user_input: dict[str, Any] | None = None) -> Any:
|
||||
"""Handle the initial step."""
|
||||
errors: dict[str, str] = {}
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(title="test_me Integration", data=user_input)
|
||||
return self.async_show_form(step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors)
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"domain": "test_me",
|
||||
"name": "test_me Integration",
|
||||
"codeowners": ["@sirmrak"],
|
||||
"config_flow": true,
|
||||
"documentation": "https://github.com/sirmrak/test_me",
|
||||
"integration_type": "hub",
|
||||
"iot_class": "local_polling",
|
||||
"requirements": [],
|
||||
"version": "1.0.0"
|
||||
}
|
||||
Reference in New Issue
Block a user