mirror of
https://github.com/home-assistant/core.git
synced 2025-04-28 19:27:51 +00:00
Revert "Allows defining list of attributes excluded from history in manifest.json" (#99300)
Revert "Allows defining list of attributes excluded from history in manifest.json (#99283)" This reverts commit 0366e14630676b2d96f529c9113f5fceb86c705b.
This commit is contained in:
parent
fb4e93071e
commit
7e7cb15d5b
@ -57,6 +57,9 @@ from homeassistant.helpers import condition
|
|||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
|
from homeassistant.helpers.integration_platform import (
|
||||||
|
async_process_integration_platform_for_component,
|
||||||
|
)
|
||||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
from homeassistant.helpers.script import (
|
from homeassistant.helpers.script import (
|
||||||
@ -246,6 +249,10 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
LOGGER, DOMAIN, hass
|
LOGGER, DOMAIN, hass
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Process integration platforms right away since
|
||||||
|
# we will create entities before firing EVENT_COMPONENT_LOADED
|
||||||
|
await async_process_integration_platform_for_component(hass, DOMAIN)
|
||||||
|
|
||||||
# Register automation as valid domain for Blueprint
|
# Register automation as valid domain for Blueprint
|
||||||
async_get_blueprints(hass)
|
async_get_blueprints(hass)
|
||||||
|
|
||||||
|
@ -6,12 +6,5 @@
|
|||||||
"dependencies": ["blueprint", "trace"],
|
"dependencies": ["blueprint", "trace"],
|
||||||
"documentation": "https://www.home-assistant.io/integrations/automation",
|
"documentation": "https://www.home-assistant.io/integrations/automation",
|
||||||
"integration_type": "system",
|
"integration_type": "system",
|
||||||
"quality_scale": "internal",
|
"quality_scale": "internal"
|
||||||
"recorder_excluded_attributes": [
|
|
||||||
"current",
|
|
||||||
"id",
|
|
||||||
"last_triggered",
|
|
||||||
"max",
|
|
||||||
"mode"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
12
homeassistant/components/automation/recorder.py
Normal file
12
homeassistant/components/automation/recorder.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
"""Integration platform for recorder."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
|
||||||
|
from . import ATTR_CUR, ATTR_LAST_TRIGGERED, ATTR_MAX, ATTR_MODE, CONF_ID
|
||||||
|
|
||||||
|
|
||||||
|
@callback
|
||||||
|
def exclude_attributes(hass: HomeAssistant) -> set[str]:
|
||||||
|
"""Exclude extra attributes from being recorded in the database."""
|
||||||
|
return {ATTR_LAST_TRIGGERED, ATTR_MODE, ATTR_CUR, ATTR_MAX, CONF_ID}
|
@ -8,7 +8,6 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.const import CONF_EXCLUDE, EVENT_STATE_CHANGED
|
from homeassistant.const import CONF_EXCLUDE, EVENT_STATE_CHANGED
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.generated.recorder import EXCLUDED_ATTRIBUTES
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entityfilter import (
|
from homeassistant.helpers.entityfilter import (
|
||||||
INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA,
|
INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA,
|
||||||
@ -133,7 +132,7 @@ def is_entity_recorded(hass: HomeAssistant, entity_id: str) -> bool:
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the recorder."""
|
"""Set up the recorder."""
|
||||||
exclude_attributes_by_domain: dict[str, set[str]] = dict(EXCLUDED_ATTRIBUTES)
|
exclude_attributes_by_domain: dict[str, set[str]] = {}
|
||||||
hass.data[EXCLUDE_ATTRIBUTES] = exclude_attributes_by_domain
|
hass.data[EXCLUDE_ATTRIBUTES] = exclude_attributes_by_domain
|
||||||
conf = config[DOMAIN]
|
conf = config[DOMAIN]
|
||||||
entity_filter = convert_include_exclude_filter(conf).get_filter()
|
entity_filter = convert_include_exclude_filter(conf).get_filter()
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
"""Automatically generated file.
|
|
||||||
|
|
||||||
To update, run python3 -m script.hassfest
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXCLUDED_ATTRIBUTES = {
|
|
||||||
"automation": {
|
|
||||||
"current",
|
|
||||||
"id",
|
|
||||||
"last_triggered",
|
|
||||||
"max",
|
|
||||||
"mode",
|
|
||||||
},
|
|
||||||
}
|
|
@ -20,7 +20,6 @@ from . import (
|
|||||||
metadata,
|
metadata,
|
||||||
mqtt,
|
mqtt,
|
||||||
mypy_config,
|
mypy_config,
|
||||||
recorder,
|
|
||||||
requirements,
|
requirements,
|
||||||
services,
|
services,
|
||||||
ssdp,
|
ssdp,
|
||||||
@ -40,7 +39,6 @@ INTEGRATION_PLUGINS = [
|
|||||||
json,
|
json,
|
||||||
manifest,
|
manifest,
|
||||||
mqtt,
|
mqtt,
|
||||||
recorder,
|
|
||||||
requirements,
|
requirements,
|
||||||
services,
|
services,
|
||||||
ssdp,
|
ssdp,
|
||||||
|
@ -264,7 +264,6 @@ INTEGRATION_MANIFEST_SCHEMA = vol.Schema(
|
|||||||
vol.Optional("loggers"): [str],
|
vol.Optional("loggers"): [str],
|
||||||
vol.Optional("disabled"): str,
|
vol.Optional("disabled"): str,
|
||||||
vol.Optional("iot_class"): vol.In(SUPPORTED_IOT_CLASSES),
|
vol.Optional("iot_class"): vol.In(SUPPORTED_IOT_CLASSES),
|
||||||
vol.Optional("recorder_excluded_attributes"): [str],
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
"""Generate recorder file."""
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from .model import Config, Integration
|
|
||||||
from .serializer import format_python_namespace
|
|
||||||
|
|
||||||
|
|
||||||
def generate_and_validate(integrations: dict[str, Integration]) -> str:
|
|
||||||
"""Validate and generate recorder data."""
|
|
||||||
|
|
||||||
data: dict[str, set[str]] = {}
|
|
||||||
|
|
||||||
for domain in sorted(integrations):
|
|
||||||
exclude_list = integrations[domain].manifest.get("recorder_excluded_attributes")
|
|
||||||
|
|
||||||
if not exclude_list:
|
|
||||||
continue
|
|
||||||
|
|
||||||
data[domain] = set(exclude_list)
|
|
||||||
|
|
||||||
return format_python_namespace({"EXCLUDED_ATTRIBUTES": data})
|
|
||||||
|
|
||||||
|
|
||||||
def validate(integrations: dict[str, Integration], config: Config) -> None:
|
|
||||||
"""Validate recorder file."""
|
|
||||||
recorder_path = config.root / "homeassistant/generated/recorder.py"
|
|
||||||
config.cache["recorder"] = content = generate_and_validate(integrations)
|
|
||||||
|
|
||||||
if config.specific_integrations:
|
|
||||||
return
|
|
||||||
|
|
||||||
with open(str(recorder_path)) as fp:
|
|
||||||
if fp.read() != content:
|
|
||||||
config.add_error(
|
|
||||||
"recorder",
|
|
||||||
"File recorder.py is not up to date. Run python3 -m script.hassfest",
|
|
||||||
fixable=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def generate(integrations: dict[str, Integration], config: Config) -> None:
|
|
||||||
"""Generate recorder file."""
|
|
||||||
recorder_path = config.root / "homeassistant/generated/recorder.py"
|
|
||||||
with open(str(recorder_path), "w") as fp:
|
|
||||||
fp.write(f"{config.cache['recorder']}")
|
|
Loading…
x
Reference in New Issue
Block a user