Use core constants for helpers (#46240)
parent
00bbf8c3a2
commit
c2302784c2
|
@ -136,7 +136,6 @@ class YamlCollection(ObservableCollection):
|
|||
|
||||
async def async_load(self, data: List[dict]) -> None:
|
||||
"""Load the YAML collection. Overrides existing data."""
|
||||
|
||||
old_ids = set(self.data)
|
||||
|
||||
change_sets = []
|
||||
|
|
|
@ -549,7 +549,6 @@ unit_system = vol.All(
|
|||
|
||||
def template(value: Optional[Any]) -> template_helper.Template:
|
||||
"""Validate a jinja2 template."""
|
||||
|
||||
if value is None:
|
||||
raise vol.Invalid("template value is None")
|
||||
if isinstance(value, (list, dict, template_helper.Template)):
|
||||
|
@ -566,7 +565,6 @@ def template(value: Optional[Any]) -> template_helper.Template:
|
|||
|
||||
def dynamic_template(value: Optional[Any]) -> template_helper.Template:
|
||||
"""Validate a dynamic (non static) jinja2 template."""
|
||||
|
||||
if value is None:
|
||||
raise vol.Invalid("template value is None")
|
||||
if isinstance(value, (list, dict, template_helper.Template)):
|
||||
|
|
|
@ -65,7 +65,6 @@ def async_generate_entity_id(
|
|||
hass: Optional[HomeAssistant] = None,
|
||||
) -> str:
|
||||
"""Generate a unique entity ID based on given entity IDs or used IDs."""
|
||||
|
||||
name = (name or DEVICE_DEFAULT_NAME).lower()
|
||||
preferred_string = entity_id_format.format(slugify(name))
|
||||
|
||||
|
|
|
@ -299,7 +299,6 @@ def _async_remove_indexed_listeners(
|
|||
job: HassJob,
|
||||
) -> None:
|
||||
"""Remove a listener."""
|
||||
|
||||
callbacks = hass.data[data_key]
|
||||
|
||||
for storage_key in storage_keys:
|
||||
|
@ -686,7 +685,6 @@ def async_track_template(
|
|||
Callable to unregister the listener.
|
||||
|
||||
"""
|
||||
|
||||
job = HassJob(action)
|
||||
|
||||
@callback
|
||||
|
@ -1105,7 +1103,6 @@ def async_track_point_in_time(
|
|||
point_in_time: datetime,
|
||||
) -> CALLBACK_TYPE:
|
||||
"""Add a listener that fires once after a specific point in time."""
|
||||
|
||||
job = action if isinstance(action, HassJob) else HassJob(action)
|
||||
|
||||
@callback
|
||||
|
@ -1329,7 +1326,6 @@ def async_track_utc_time_change(
|
|||
local: bool = False,
|
||||
) -> CALLBACK_TYPE:
|
||||
"""Add a listener that will fire if time matches a pattern."""
|
||||
|
||||
job = HassJob(action)
|
||||
# We do not have to wrap the function with time pattern matching logic
|
||||
# if no pattern given
|
||||
|
|
|
@ -70,7 +70,6 @@ def report_integration(
|
|||
|
||||
Async friendly.
|
||||
"""
|
||||
|
||||
found_frame, integration, path = integration_frame
|
||||
|
||||
index = found_frame.filename.index(path)
|
||||
|
|
|
@ -51,7 +51,6 @@ def create_async_httpx_client(
|
|||
|
||||
This method must be run in the event loop.
|
||||
"""
|
||||
|
||||
client = httpx.AsyncClient(
|
||||
verify=verify_ssl,
|
||||
headers={USER_AGENT: SERVER_SOFTWARE},
|
||||
|
|
|
@ -157,13 +157,11 @@ async def async_setup_reload_service(
|
|||
hass: HomeAssistantType, domain: str, platforms: Iterable
|
||||
) -> None:
|
||||
"""Create the reload service for the domain."""
|
||||
|
||||
if hass.services.has_service(domain, SERVICE_RELOAD):
|
||||
return
|
||||
|
||||
async def _reload_config(call: Event) -> None:
|
||||
"""Reload the platforms."""
|
||||
|
||||
await async_reload_integration_platforms(hass, domain, platforms)
|
||||
hass.bus.async_fire(f"event_{domain}_reloaded", context=call.context)
|
||||
|
||||
|
@ -176,7 +174,6 @@ def setup_reload_service(
|
|||
hass: HomeAssistantType, domain: str, platforms: Iterable
|
||||
) -> None:
|
||||
"""Sync version of async_setup_reload_service."""
|
||||
|
||||
asyncio.run_coroutine_threadsafe(
|
||||
async_setup_reload_service(hass, domain, platforms),
|
||||
hass.loop,
|
||||
|
|
|
@ -26,6 +26,7 @@ from homeassistant.const import (
|
|||
ATTR_DEVICE_ID,
|
||||
ATTR_ENTITY_ID,
|
||||
CONF_SERVICE,
|
||||
CONF_SERVICE_DATA,
|
||||
CONF_SERVICE_TEMPLATE,
|
||||
CONF_TARGET,
|
||||
ENTITY_MATCH_ALL,
|
||||
|
@ -62,7 +63,6 @@ if TYPE_CHECKING:
|
|||
|
||||
|
||||
CONF_SERVICE_ENTITY_ID = "entity_id"
|
||||
CONF_SERVICE_DATA = "data"
|
||||
CONF_SERVICE_DATA_TEMPLATE = "data_template"
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
|
|
@ -202,7 +202,6 @@ class Store:
|
|||
|
||||
async def _async_handle_write_data(self, *_args):
|
||||
"""Handle writing the config."""
|
||||
|
||||
async with self._write_lock:
|
||||
self._async_cleanup_delay_listener()
|
||||
self._async_cleanup_final_write_listener()
|
||||
|
|
|
@ -19,7 +19,6 @@ DATA_LOCATION_CACHE = "astral_location_cache"
|
|||
@bind_hass
|
||||
def get_astral_location(hass: HomeAssistantType) -> "astral.Location":
|
||||
"""Get an astral location for the current Home Assistant configuration."""
|
||||
|
||||
from astral import Location # pylint: disable=import-outside-toplevel
|
||||
|
||||
latitude = hass.config.latitude
|
||||
|
|
|
@ -1292,7 +1292,6 @@ def relative_time(value):
|
|||
|
||||
If the input are not a datetime object the input will be returned unmodified.
|
||||
"""
|
||||
|
||||
if not isinstance(value, datetime):
|
||||
return value
|
||||
if not value.tzinfo:
|
||||
|
|
|
@ -264,7 +264,6 @@ class CoordinatorEntity(entity.Entity):
|
|||
|
||||
Only used by the generic entity update service.
|
||||
"""
|
||||
|
||||
# Ignore manual update requests if the entity is disabled
|
||||
if not self.enabled:
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue