mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Fixes
This commit is contained in:
parent
50e4311416
commit
f1f45d6b5b
@ -3,7 +3,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable, Coroutine, Mapping
|
||||
from datetime import timedelta
|
||||
from functools import partial
|
||||
import logging
|
||||
from typing import Any, cast
|
||||
|
||||
import voluptuous as vol
|
||||
@ -13,6 +15,7 @@ from homeassistant.const import CONF_ENTITIES, CONF_TYPE
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import entity_registry as er, selector
|
||||
from homeassistant.helpers.entity_platform import EntityPlatform
|
||||
from homeassistant.helpers.schema_config_entry_flow import (
|
||||
SchemaCommonFlowHandler,
|
||||
SchemaConfigFlowHandler,
|
||||
@ -48,6 +51,8 @@ _STATISTIC_MEASURES = [
|
||||
"sum",
|
||||
]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def basic_group_options_schema(
|
||||
domain: str | list[str], handler: SchemaCommonFlowHandler | None
|
||||
@ -424,6 +429,15 @@ def ws_start_preview(
|
||||
)
|
||||
preview_entity.hass = hass
|
||||
preview_entity.registry_entry = entity_registry_entry
|
||||
preview_entity.platform = EntityPlatform(
|
||||
hass=hass,
|
||||
logger=_LOGGER,
|
||||
domain=group_type,
|
||||
platform_name=DOMAIN,
|
||||
platform=None,
|
||||
scan_interval=timedelta(hours=1),
|
||||
entity_namespace=None,
|
||||
)
|
||||
|
||||
connection.send_result(msg["id"])
|
||||
connection.subscriptions[msg["id"]] = preview_entity.async_start_preview(
|
||||
|
@ -3,15 +3,17 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Mapping
|
||||
from datetime import timedelta
|
||||
from typing import Any, cast
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import websocket_api
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorDeviceClass
|
||||
from homeassistant.const import CONF_NAME, Platform
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import EntityPlatform
|
||||
from homeassistant.helpers.schema_config_entry_flow import (
|
||||
SchemaCommonFlowHandler,
|
||||
SchemaConfigFlowHandler,
|
||||
@ -36,7 +38,7 @@ from .const import (
|
||||
DEFAULT_NAME,
|
||||
DOMAIN,
|
||||
)
|
||||
from .sensor import MoldIndicator
|
||||
from .sensor import _LOGGER, MoldIndicator
|
||||
|
||||
|
||||
async def validate_input(
|
||||
@ -168,6 +170,15 @@ def ws_start_preview(
|
||||
None,
|
||||
)
|
||||
preview_entity.hass = hass
|
||||
preview_entity.platform = EntityPlatform(
|
||||
hass=hass,
|
||||
logger=_LOGGER,
|
||||
domain=SENSOR_DOMAIN,
|
||||
platform_name=DOMAIN,
|
||||
platform=None,
|
||||
scan_interval=timedelta(hours=1),
|
||||
entity_namespace=None,
|
||||
)
|
||||
|
||||
connection.send_result(msg["id"])
|
||||
connection.subscriptions[msg["id"]] = preview_entity.async_start_preview(
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""OwnTracks Message handlers."""
|
||||
|
||||
from datetime import timedelta
|
||||
import json
|
||||
import logging
|
||||
|
||||
@ -9,6 +10,7 @@ from nacl.secret import SecretBox
|
||||
from homeassistant.components import zone as zone_comp
|
||||
from homeassistant.components.device_tracker import SourceType
|
||||
from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE, STATE_HOME
|
||||
from homeassistant.helpers.entity_platform import EntityPlatform
|
||||
from homeassistant.util import decorator, slugify
|
||||
|
||||
from .helper import supports_encryption
|
||||
@ -317,6 +319,15 @@ async def async_handle_waypoint(hass, name_base, waypoint):
|
||||
)
|
||||
zone.hass = hass
|
||||
zone.entity_id = entity_id
|
||||
zone.platform = EntityPlatform(
|
||||
hass=hass,
|
||||
logger=_LOGGER,
|
||||
domain="zone",
|
||||
platform_name="owntracks",
|
||||
platform=None,
|
||||
scan_interval=timedelta(seconds=15),
|
||||
entity_namespace=None,
|
||||
)
|
||||
zone.async_write_ha_state()
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@ from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.const import CONF_ENTITY_ID, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant, callback, split_entity_id
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import EntityPlatform
|
||||
from homeassistant.helpers.schema_config_entry_flow import (
|
||||
SchemaCommonFlowHandler,
|
||||
SchemaConfigFlowHandler,
|
||||
@ -37,6 +38,7 @@ from homeassistant.helpers.selector import (
|
||||
|
||||
from . import DOMAIN
|
||||
from .sensor import (
|
||||
_LOGGER,
|
||||
CONF_KEEP_LAST_SAMPLE,
|
||||
CONF_MAX_AGE,
|
||||
CONF_PERCENTILE,
|
||||
@ -232,6 +234,15 @@ async def ws_start_preview(
|
||||
msg["user_input"].get(CONF_PERCENTILE),
|
||||
)
|
||||
preview_entity.hass = hass
|
||||
preview_entity.platform = EntityPlatform(
|
||||
hass=hass,
|
||||
logger=_LOGGER,
|
||||
domain=SENSOR_DOMAIN,
|
||||
platform_name=DOMAIN,
|
||||
platform=None,
|
||||
scan_interval=timedelta(hours=1),
|
||||
entity_namespace=None,
|
||||
)
|
||||
|
||||
connection.send_result(msg["id"])
|
||||
connection.subscriptions[msg["id"]] = await preview_entity.async_start_preview(
|
||||
|
@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Mapping
|
||||
from datetime import timedelta
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
@ -13,6 +14,7 @@ from homeassistant.const import CONF_ENTITY_ID, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import selector
|
||||
from homeassistant.helpers.entity_platform import EntityPlatform
|
||||
from homeassistant.helpers.schema_config_entry_flow import (
|
||||
SchemaCommonFlowHandler,
|
||||
SchemaConfigFlowHandler,
|
||||
@ -20,7 +22,7 @@ from homeassistant.helpers.schema_config_entry_flow import (
|
||||
SchemaFlowFormStep,
|
||||
)
|
||||
|
||||
from .binary_sensor import ThresholdSensor
|
||||
from .binary_sensor import _LOGGER, ThresholdSensor
|
||||
from .const import CONF_HYSTERESIS, CONF_LOWER, CONF_UPPER, DEFAULT_HYSTERESIS, DOMAIN
|
||||
|
||||
|
||||
@ -140,6 +142,15 @@ def ws_start_preview(
|
||||
None,
|
||||
)
|
||||
preview_entity.hass = hass
|
||||
preview_entity.platform = EntityPlatform(
|
||||
hass=hass,
|
||||
logger=_LOGGER,
|
||||
domain=SENSOR_DOMAIN,
|
||||
platform_name=DOMAIN,
|
||||
platform=None,
|
||||
scan_interval=timedelta(hours=1),
|
||||
entity_namespace=None,
|
||||
)
|
||||
|
||||
connection.send_result(msg["id"])
|
||||
connection.subscriptions[msg["id"]] = preview_entity.async_start_preview(
|
||||
|
@ -211,6 +211,7 @@ def media_player_entity(
|
||||
media_player.hass = hass
|
||||
media_player.platform = MockEntityPlatform(hass)
|
||||
media_player.entity_id = "media_player.zone_3"
|
||||
media_player.platform = MockEntityPlatform(hass)
|
||||
return media_player
|
||||
|
||||
|
||||
@ -274,7 +275,6 @@ async def test_update(
|
||||
hass: HomeAssistant, media_player_entity: MediaPlayerEntity
|
||||
) -> None:
|
||||
"""Test updating values from blackbird."""
|
||||
|
||||
assert media_player_entity.state == STATE_ON
|
||||
assert media_player_entity.source == "one"
|
||||
|
||||
|
@ -36,8 +36,6 @@ def test_kira_sensor_callback(
|
||||
|
||||
assert sensor.name == "kira"
|
||||
|
||||
sensor.hass = hass
|
||||
|
||||
codeName = "FAKE_CODE"
|
||||
deviceName = "FAKE_DEVICE"
|
||||
codeTuple = (codeName, deviceName)
|
||||
|
@ -39,6 +39,7 @@ from .common import (
|
||||
)
|
||||
|
||||
from tests.common import (
|
||||
MockEntityPlatform,
|
||||
MockModule,
|
||||
async_mock_service,
|
||||
mock_integration,
|
||||
@ -58,9 +59,10 @@ class DefaultEntity(tts.TextToSpeechEntity):
|
||||
_attr_default_language = DEFAULT_LANG
|
||||
|
||||
|
||||
async def test_default_entity_attributes() -> None:
|
||||
async def test_default_entity_attributes(hass: HomeAssistant) -> None:
|
||||
"""Test default entity attributes."""
|
||||
entity = DefaultEntity()
|
||||
entity.platform = MockEntityPlatform(hass)
|
||||
|
||||
assert entity.hass is None
|
||||
assert entity.default_language == DEFAULT_LANG
|
||||
|
Loading…
x
Reference in New Issue
Block a user