Add image platform to the template integration (#94928)
* Add image platform to the template integration * Set a default name * Fix typo * Add tests * Improve test coverage * Derive content-type from fetched image
This commit is contained in:
parent
8fda56d2c9
commit
8e2ba81995
7 changed files with 809 additions and 1 deletions
|
@ -18,6 +18,7 @@ from homeassistant.helpers.template import Template
|
|||
from homeassistant.helpers.template_entity import ( # noqa: F401 pylint: disable=unused-import
|
||||
TEMPLATE_ENTITY_BASE_SCHEMA,
|
||||
TemplateEntity,
|
||||
make_template_entity_base_schema,
|
||||
)
|
||||
|
||||
from .const import (
|
||||
|
@ -47,6 +48,17 @@ TEMPLATE_ENTITY_COMMON_SCHEMA = vol.Schema(
|
|||
}
|
||||
).extend(TEMPLATE_ENTITY_BASE_SCHEMA.schema)
|
||||
|
||||
|
||||
def make_template_entity_common_schema(default_name: str) -> vol.Schema:
|
||||
"""Return a schema with default name."""
|
||||
return vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_ATTRIBUTES): vol.Schema({cv.string: cv.template}),
|
||||
vol.Optional(CONF_AVAILABILITY): cv.template,
|
||||
}
|
||||
).extend(make_template_entity_base_schema(default_name).schema)
|
||||
|
||||
|
||||
TEMPLATE_ENTITY_ATTRIBUTES_SCHEMA_LEGACY = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_ATTRIBUTE_TEMPLATES, default={}): vol.Schema(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue