mirror of
https://github.com/home-assistant/core.git
synced 2026-10-06 06:15:47 -04:00
Mods
This commit is contained in:
@@ -23,7 +23,7 @@ from homeassistant.helpers.schema_config_entry_flow import (
|
||||
|
||||
from .binary_sensor import CONF_ALL, async_create_preview_binary_sensor
|
||||
from .button import async_create_preview_button
|
||||
from .const import CONF_HIDE_MEMBERS, CONF_IGNORE_NON_NUMERIC, DOMAIN
|
||||
from .const import CONF_GROUP_TYPE, CONF_HIDE_MEMBERS, CONF_IGNORE_NON_NUMERIC, DOMAIN
|
||||
from .cover import async_create_preview_cover
|
||||
from .entity import GroupEntity
|
||||
from .event import async_create_preview_event
|
||||
@@ -179,7 +179,7 @@ GROUP_TYPES = [
|
||||
|
||||
async def choose_options_step(options: dict[str, Any]) -> str:
|
||||
"""Return next step_id for options flow according to group_type."""
|
||||
return cast(str, options["group_type"])
|
||||
return cast(str, options[CONF_GROUP_TYPE])
|
||||
|
||||
|
||||
def set_group_type(
|
||||
@@ -193,7 +193,7 @@ def set_group_type(
|
||||
handler: SchemaCommonFlowHandler, user_input: dict[str, Any]
|
||||
) -> dict[str, Any]:
|
||||
"""Add group type to user input."""
|
||||
return {"group_type": group_type, **user_input}
|
||||
return {CONF_GROUP_TYPE: group_type, **user_input}
|
||||
|
||||
return _set_group_type
|
||||
|
||||
@@ -345,14 +345,13 @@ class GroupConfigFlowHandler(SchemaConfigFlowHandler, domain=DOMAIN):
|
||||
|
||||
async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult:
|
||||
"""Import from a min_max config entry."""
|
||||
print("hej", import_data)
|
||||
"""
|
||||
return self.async_create_entry(
|
||||
title="",
|
||||
data={
|
||||
},
|
||||
)
|
||||
"""
|
||||
new_data = import_data.copy()
|
||||
new_data[CONF_ENTITIES] = new_data.pop("entity_ids")
|
||||
new_data[CONF_GROUP_TYPE] = "sensor"
|
||||
new_data[CONF_HIDE_MEMBERS] = False
|
||||
new_data[CONF_IGNORE_NON_NUMERIC] = False
|
||||
|
||||
return self.async_create_entry(data=new_data)
|
||||
|
||||
@callback
|
||||
@override
|
||||
@@ -444,7 +443,7 @@ def ws_start_preview(
|
||||
config_entry = hass.config_entries.async_get_entry(config_entry_id)
|
||||
if not config_entry:
|
||||
raise HomeAssistantError
|
||||
group_type = config_entry.options["group_type"]
|
||||
group_type = config_entry.options[CONF_GROUP_TYPE]
|
||||
name = config_entry.options["name"]
|
||||
validated = PREVIEW_OPTIONS_SCHEMA[group_type](msg["user_input"])
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
@@ -12,6 +12,7 @@ if TYPE_CHECKING:
|
||||
|
||||
CONF_HIDE_MEMBERS = "hide_members"
|
||||
CONF_IGNORE_NON_NUMERIC = "ignore_non_numeric"
|
||||
CONF_GROUP_TYPE = "group_type"
|
||||
|
||||
DOMAIN = "group"
|
||||
DATA_COMPONENT: HassKey[EntityComponent[Group]] = HassKey(DOMAIN)
|
||||
|
||||
@@ -2,19 +2,17 @@
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.components.group import DOMAIN as GROUP_DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up Min/Max from a config entry."""
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
|
||||
return True
|
||||
|
||||
@@ -34,9 +32,10 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
||||
if entry.version == 1:
|
||||
# Migration to group sensor and remove config entry
|
||||
# Sensor needs migration
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=entry.options
|
||||
GROUP_DOMAIN, context={"source": SOURCE_IMPORT}, data=entry.options
|
||||
)
|
||||
)
|
||||
hass.config_entries.async_update_entry(entry, version=2)
|
||||
|
||||
Reference in New Issue
Block a user