Integrations m*: Rename HomeAssistantType to HomeAssistant. (#49567)

This commit is contained in:
jan iversen 2021-04-22 23:53:37 +02:00 committed by GitHub
parent 90ede05c82
commit 9410aefd0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 79 additions and 73 deletions

View File

@ -13,10 +13,10 @@ import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import CONF_TOKEN, CONF_USERNAME from homeassistant.const import CONF_TOKEN, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.util import Throttle from homeassistant.util import Throttle
from .const import DOMAIN from .const import DOMAIN
@ -41,7 +41,7 @@ CONFIG_SCHEMA = vol.Schema(
) )
async def async_setup(hass: HomeAssistantType, config: ConfigEntry): async def async_setup(hass: HomeAssistant, config: ConfigEntry):
"""Establish connection with MELCloud.""" """Establish connection with MELCloud."""
if DOMAIN not in config: if DOMAIN not in config:
return True return True
@ -58,7 +58,7 @@ async def async_setup(hass: HomeAssistantType, config: ConfigEntry):
return True return True
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Establish connection with MELClooud.""" """Establish connection with MELClooud."""
conf = entry.data conf = entry.data
mel_devices = await mel_devices_setup(hass, conf[CONF_TOKEN]) mel_devices = await mel_devices_setup(hass, conf[CONF_TOKEN])

View File

@ -30,8 +30,8 @@ from homeassistant.components.climate.const import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TEMP_CELSIUS from homeassistant.const import TEMP_CELSIUS
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.typing import HomeAssistantType
from . import MelCloudDevice from . import MelCloudDevice
from .const import ( from .const import (
@ -67,7 +67,7 @@ ATW_ZONE_HVAC_MODE_REVERSE_LOOKUP = {v: k for k, v in ATW_ZONE_HVAC_MODE_LOOKUP.
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities hass: HomeAssistant, entry: ConfigEntry, async_add_entities
): ):
"""Set up MelCloud device climate based on config_entry.""" """Set up MelCloud device climate based on config_entry."""
mel_devices = hass.data[DOMAIN][entry.entry_id] mel_devices = hass.data[DOMAIN][entry.entry_id]

View File

@ -15,14 +15,14 @@ from homeassistant.components.water_heater import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TEMP_CELSIUS from homeassistant.const import TEMP_CELSIUS
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from . import DOMAIN, MelCloudDevice from . import DOMAIN, MelCloudDevice
from .const import ATTR_STATUS from .const import ATTR_STATUS
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities hass: HomeAssistant, entry: ConfigEntry, async_add_entities
): ):
"""Set up MelCloud device climate based on config_entry.""" """Set up MelCloud device climate based on config_entry."""
mel_devices = hass.data[DOMAIN][entry.entry_id] mel_devices = hass.data[DOMAIN][entry.entry_id]

View File

@ -14,7 +14,7 @@ from homeassistant.components.weather import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_MODE, TEMP_CELSIUS from homeassistant.const import CONF_MODE, TEMP_CELSIUS
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
DataUpdateCoordinator, DataUpdateCoordinator,
@ -44,7 +44,7 @@ def format_condition(condition: str):
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities hass: HomeAssistant, entry: ConfigEntry, async_add_entities
) -> None: ) -> None:
"""Set up the Meteo-France weather platform.""" """Set up the Meteo-France weather platform."""
coordinator = hass.data[DOMAIN][entry.entry_id][COORDINATOR_FORECAST] coordinator = hass.data[DOMAIN][entry.entry_id][COORDINATOR_FORECAST]

View File

@ -10,8 +10,8 @@ from homeassistant.const import (
TEMP_CELSIUS, TEMP_CELSIUS,
UV_INDEX, UV_INDEX,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from .const import ( from .const import (
ATTRIBUTION, ATTRIBUTION,
@ -78,7 +78,7 @@ SENSOR_TYPES = {
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigType, async_add_entities hass: HomeAssistant, entry: ConfigType, async_add_entities
) -> None: ) -> None:
"""Set up the Met Office weather sensor platform.""" """Set up the Met Office weather sensor platform."""
hass_data = hass.data[DOMAIN][entry.entry_id] hass_data = hass.data[DOMAIN][entry.entry_id]

View File

@ -1,8 +1,8 @@
"""Support for UK Met Office weather service.""" """Support for UK Met Office weather service."""
from homeassistant.components.weather import WeatherEntity from homeassistant.components.weather import WeatherEntity
from homeassistant.const import LENGTH_KILOMETERS, TEMP_CELSIUS from homeassistant.const import LENGTH_KILOMETERS, TEMP_CELSIUS
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from .const import ( from .const import (
ATTRIBUTION, ATTRIBUTION,
@ -18,7 +18,7 @@ from .const import (
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigType, async_add_entities hass: HomeAssistant, entry: ConfigType, async_add_entities
) -> None: ) -> None:
"""Set up the Met Office weather sensor platform.""" """Set up the Met Office weather sensor platform."""
hass_data = hass.data[DOMAIN][entry.entry_id] hass_data = hass.data[DOMAIN][entry.entry_id]

View File

@ -31,11 +31,18 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STARTED,
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
) )
from homeassistant.core import CoreState, Event, HassJob, ServiceCall, callback from homeassistant.core import (
CoreState,
Event,
HassJob,
HomeAssistant,
ServiceCall,
callback,
)
from homeassistant.exceptions import HomeAssistantError, Unauthorized from homeassistant.exceptions import HomeAssistantError, Unauthorized
from homeassistant.helpers import config_validation as cv, event, template from homeassistant.helpers import config_validation as cv, event, template
from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send
from homeassistant.helpers.typing import ConfigType, HomeAssistantType, ServiceDataType from homeassistant.helpers.typing import ConfigType, ServiceDataType
from homeassistant.loader import bind_hass from homeassistant.loader import bind_hass
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
from homeassistant.util.async_ import run_callback_threadsafe from homeassistant.util.async_ import run_callback_threadsafe
@ -245,7 +252,7 @@ def _build_publish_data(topic: Any, qos: int, retain: bool) -> ServiceDataType:
@bind_hass @bind_hass
def publish(hass: HomeAssistantType, topic, payload, qos=None, retain=None) -> None: def publish(hass: HomeAssistant, topic, payload, qos=None, retain=None) -> None:
"""Publish message to an MQTT topic.""" """Publish message to an MQTT topic."""
hass.add_job(async_publish, hass, topic, payload, qos, retain) hass.add_job(async_publish, hass, topic, payload, qos, retain)
@ -253,7 +260,7 @@ def publish(hass: HomeAssistantType, topic, payload, qos=None, retain=None) -> N
@callback @callback
@bind_hass @bind_hass
def async_publish( def async_publish(
hass: HomeAssistantType, topic: Any, payload, qos=None, retain=None hass: HomeAssistant, topic: Any, payload, qos=None, retain=None
) -> None: ) -> None:
"""Publish message to an MQTT topic.""" """Publish message to an MQTT topic."""
data = _build_publish_data(topic, qos, retain) data = _build_publish_data(topic, qos, retain)
@ -263,7 +270,7 @@ def async_publish(
@bind_hass @bind_hass
def publish_template( def publish_template(
hass: HomeAssistantType, topic, payload_template, qos=None, retain=None hass: HomeAssistant, topic, payload_template, qos=None, retain=None
) -> None: ) -> None:
"""Publish message to an MQTT topic.""" """Publish message to an MQTT topic."""
hass.add_job(async_publish_template, hass, topic, payload_template, qos, retain) hass.add_job(async_publish_template, hass, topic, payload_template, qos, retain)
@ -271,7 +278,7 @@ def publish_template(
@bind_hass @bind_hass
def async_publish_template( def async_publish_template(
hass: HomeAssistantType, topic, payload_template, qos=None, retain=None hass: HomeAssistant, topic, payload_template, qos=None, retain=None
) -> None: ) -> None:
"""Publish message to an MQTT topic using a template payload.""" """Publish message to an MQTT topic using a template payload."""
data = _build_publish_data(topic, qos, retain) data = _build_publish_data(topic, qos, retain)
@ -308,7 +315,7 @@ def wrap_msg_callback(msg_callback: MessageCallbackType) -> MessageCallbackType:
@bind_hass @bind_hass
async def async_subscribe( async def async_subscribe(
hass: HomeAssistantType, hass: HomeAssistant,
topic: str, topic: str,
msg_callback: MessageCallbackType, msg_callback: MessageCallbackType,
qos: int = DEFAULT_QOS, qos: int = DEFAULT_QOS,
@ -353,7 +360,7 @@ async def async_subscribe(
@bind_hass @bind_hass
def subscribe( def subscribe(
hass: HomeAssistantType, hass: HomeAssistant,
topic: str, topic: str,
msg_callback: MessageCallbackType, msg_callback: MessageCallbackType,
qos: int = DEFAULT_QOS, qos: int = DEFAULT_QOS,
@ -372,7 +379,7 @@ def subscribe(
async def _async_setup_discovery( async def _async_setup_discovery(
hass: HomeAssistantType, conf: ConfigType, config_entry hass: HomeAssistant, conf: ConfigType, config_entry
) -> bool: ) -> bool:
"""Try to start the discovery of MQTT devices. """Try to start the discovery of MQTT devices.
@ -385,7 +392,7 @@ async def _async_setup_discovery(
return success return success
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Start the MQTT protocol service.""" """Start the MQTT protocol service."""
conf: ConfigType | None = config.get(DOMAIN) conf: ConfigType | None = config.get(DOMAIN)
@ -542,7 +549,7 @@ class MQTT:
def __init__( def __init__(
self, self,
hass: HomeAssistantType, hass: HomeAssistant,
config_entry, config_entry,
conf, conf,
) -> None: ) -> None:

View File

@ -26,10 +26,10 @@ from homeassistant.const import (
STATE_ALARM_PENDING, STATE_ALARM_PENDING,
STATE_ALARM_TRIGGERED, STATE_ALARM_TRIGGERED,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from . import ( from . import (
CONF_COMMAND_TOPIC, CONF_COMMAND_TOPIC,
@ -87,7 +87,7 @@ PLATFORM_SCHEMA = mqtt.MQTT_BASE_PLATFORM_SCHEMA.extend(
async def async_setup_platform( async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
): ):
"""Set up MQTT alarm control panel through configuration.yaml.""" """Set up MQTT alarm control panel through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS) await async_setup_reload_service(hass, DOMAIN, PLATFORMS)

View File

@ -18,12 +18,12 @@ from homeassistant.const import (
CONF_PAYLOAD_ON, CONF_PAYLOAD_ON,
CONF_VALUE_TEMPLATE, CONF_VALUE_TEMPLATE,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
import homeassistant.helpers.event as evt import homeassistant.helpers.event as evt
from homeassistant.helpers.event import async_track_point_in_utc_time from homeassistant.helpers.event import async_track_point_in_utc_time
from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
from . import CONF_QOS, CONF_STATE_TOPIC, DOMAIN, PLATFORMS, subscription from . import CONF_QOS, CONF_STATE_TOPIC, DOMAIN, PLATFORMS, subscription
@ -59,7 +59,7 @@ PLATFORM_SCHEMA = mqtt.MQTT_RO_PLATFORM_SCHEMA.extend(
async def async_setup_platform( async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
): ):
"""Set up MQTT binary sensor through configuration.yaml.""" """Set up MQTT binary sensor through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS) await async_setup_reload_service(hass, DOMAIN, PLATFORMS)

View File

@ -6,10 +6,10 @@ import voluptuous as vol
from homeassistant.components import camera from homeassistant.components import camera
from homeassistant.components.camera import Camera from homeassistant.components.camera import Camera
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from . import CONF_QOS, DOMAIN, PLATFORMS, subscription from . import CONF_QOS, DOMAIN, PLATFORMS, subscription
from .. import mqtt from .. import mqtt
@ -28,7 +28,7 @@ PLATFORM_SCHEMA = mqtt.MQTT_BASE_PLATFORM_SCHEMA.extend(
async def async_setup_platform( async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
): ):
"""Set up MQTT camera through configuration.yaml.""" """Set up MQTT camera through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS) await async_setup_reload_service(hass, DOMAIN, PLATFORMS)

View File

@ -46,10 +46,10 @@ from homeassistant.const import (
PRECISION_WHOLE, PRECISION_WHOLE,
STATE_ON, STATE_ON,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from . import ( from . import (
CONF_QOS, CONF_QOS,
@ -251,7 +251,7 @@ PLATFORM_SCHEMA = SCHEMA_BASE.extend(
async def async_setup_platform( async def async_setup_platform(
hass: HomeAssistantType, async_add_entities, config: ConfigType, discovery_info=None hass: HomeAssistant, async_add_entities, config: ConfigType, discovery_info=None
): ):
"""Set up MQTT climate device through configuration.yaml.""" """Set up MQTT climate device through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS) await async_setup_reload_service(hass, DOMAIN, PLATFORMS)

View File

@ -30,10 +30,10 @@ from homeassistant.const import (
STATE_OPENING, STATE_OPENING,
STATE_UNKNOWN, STATE_UNKNOWN,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from . import ( from . import (
CONF_COMMAND_TOPIC, CONF_COMMAND_TOPIC,
@ -184,7 +184,7 @@ PLATFORM_SCHEMA = vol.All(
async def async_setup_platform( async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
): ):
"""Set up MQTT cover through configuration.yaml.""" """Set up MQTT cover through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS) await async_setup_reload_service(hass, DOMAIN, PLATFORMS)

View File

@ -3,7 +3,7 @@ from collections import deque
from functools import wraps from functools import wraps
from typing import Any from typing import Any
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from .const import ATTR_DISCOVERY_PAYLOAD, ATTR_DISCOVERY_TOPIC from .const import ATTR_DISCOVERY_PAYLOAD, ATTR_DISCOVERY_TOPIC
from .models import MessageCallbackType from .models import MessageCallbackType
@ -12,7 +12,7 @@ DATA_MQTT_DEBUG_INFO = "mqtt_debug_info"
STORED_MESSAGES = 10 STORED_MESSAGES = 10
def log_messages(hass: HomeAssistantType, entity_id: str) -> MessageCallbackType: def log_messages(hass: HomeAssistant, entity_id: str) -> MessageCallbackType:
"""Wrap an MQTT message callback to support message logging.""" """Wrap an MQTT message callback to support message logging."""
def _log_message(msg): def _log_message(msg):

View File

@ -24,7 +24,7 @@ from homeassistant.helpers.dispatcher import (
async_dispatcher_connect, async_dispatcher_connect,
async_dispatcher_send, async_dispatcher_send,
) )
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from . import CONF_PAYLOAD, CONF_QOS, DOMAIN, debug_info, trigger as mqtt_trigger from . import CONF_PAYLOAD, CONF_QOS, DOMAIN, debug_info, trigger as mqtt_trigger
from .. import mqtt from .. import mqtt
@ -120,7 +120,7 @@ class Trigger:
device_id: str = attr.ib() device_id: str = attr.ib()
discovery_data: dict = attr.ib() discovery_data: dict = attr.ib()
hass: HomeAssistantType = attr.ib() hass: HomeAssistant = attr.ib()
payload: str = attr.ib() payload: str = attr.ib()
qos: int = attr.ib() qos: int = attr.ib()
remove_signal: Callable[[], None] = attr.ib() remove_signal: Callable[[], None] = attr.ib()

View File

@ -8,11 +8,11 @@ import re
import time import time
from homeassistant.const import CONF_DEVICE, CONF_PLATFORM from homeassistant.const import CONF_DEVICE, CONF_PLATFORM
from homeassistant.core import HomeAssistant
from homeassistant.helpers.dispatcher import ( from homeassistant.helpers.dispatcher import (
async_dispatcher_connect, async_dispatcher_connect,
async_dispatcher_send, async_dispatcher_send,
) )
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.loader import async_get_mqtt from homeassistant.loader import async_get_mqtt
from .. import mqtt from .. import mqtt
@ -79,9 +79,7 @@ class MQTTConfig(dict):
"""Dummy class to allow adding attributes.""" """Dummy class to allow adding attributes."""
async def async_start( async def async_start(hass: HomeAssistant, discovery_topic, config_entry=None) -> bool:
hass: HomeAssistantType, discovery_topic, config_entry=None
) -> bool:
"""Start MQTT Discovery.""" """Start MQTT Discovery."""
mqtt_integrations = {} mqtt_integrations = {}
@ -295,7 +293,7 @@ async def async_start(
return True return True
async def async_stop(hass: HomeAssistantType) -> bool: async def async_stop(hass: HomeAssistant) -> bool:
"""Stop MQTT Discovery.""" """Stop MQTT Discovery."""
if DISCOVERY_UNSUBSCRIBE in hass.data: if DISCOVERY_UNSUBSCRIBE in hass.data:
for unsub in hass.data[DISCOVERY_UNSUBSCRIBE]: for unsub in hass.data[DISCOVERY_UNSUBSCRIBE]:

View File

@ -28,10 +28,10 @@ from homeassistant.const import (
CONF_PAYLOAD_ON, CONF_PAYLOAD_ON,
CONF_STATE, CONF_STATE,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from homeassistant.util.percentage import ( from homeassistant.util.percentage import (
int_states_in_range, int_states_in_range,
ordered_list_item_to_percentage, ordered_list_item_to_percentage,
@ -181,7 +181,7 @@ PLATFORM_SCHEMA = vol.All(
async def async_setup_platform( async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
): ):
"""Set up MQTT fan through configuration.yaml.""" """Set up MQTT fan through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS) await async_setup_reload_service(hass, DOMAIN, PLATFORMS)

View File

@ -6,10 +6,10 @@ import voluptuous as vol
from homeassistant.components import lock from homeassistant.components import lock
from homeassistant.components.lock import LockEntity from homeassistant.components.lock import LockEntity
from homeassistant.const import CONF_NAME, CONF_OPTIMISTIC, CONF_VALUE_TEMPLATE from homeassistant.const import CONF_NAME, CONF_OPTIMISTIC, CONF_VALUE_TEMPLATE
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from . import ( from . import (
CONF_COMMAND_TOPIC, CONF_COMMAND_TOPIC,
@ -50,7 +50,7 @@ PLATFORM_SCHEMA = mqtt.MQTT_RW_PLATFORM_SCHEMA.extend(
async def async_setup_platform( async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
): ):
"""Set up MQTT lock panel through configuration.yaml.""" """Set up MQTT lock panel through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS) await async_setup_reload_service(hass, DOMAIN, PLATFORMS)

View File

@ -7,11 +7,11 @@ import voluptuous as vol
from homeassistant.components import number from homeassistant.components import number
from homeassistant.components.number import NumberEntity from homeassistant.components.number import NumberEntity
from homeassistant.const import CONF_NAME, CONF_OPTIMISTIC from homeassistant.const import CONF_NAME, CONF_OPTIMISTIC
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from . import ( from . import (
CONF_COMMAND_TOPIC, CONF_COMMAND_TOPIC,
@ -40,7 +40,7 @@ PLATFORM_SCHEMA = mqtt.MQTT_RW_PLATFORM_SCHEMA.extend(
async def async_setup_platform( async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
): ):
"""Set up MQTT number through configuration.yaml.""" """Set up MQTT number through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS) await async_setup_reload_service(hass, DOMAIN, PLATFORMS)

View File

@ -6,9 +6,10 @@ import voluptuous as vol
from homeassistant.components import scene from homeassistant.components import scene
from homeassistant.components.scene import Scene from homeassistant.components.scene import Scene
from homeassistant.const import CONF_ICON, CONF_NAME, CONF_PAYLOAD_ON, CONF_UNIQUE_ID from homeassistant.const import CONF_ICON, CONF_NAME, CONF_PAYLOAD_ON, CONF_UNIQUE_ID
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from . import CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN, DOMAIN, PLATFORMS from . import CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN, DOMAIN, PLATFORMS
from .. import mqtt from .. import mqtt
@ -35,7 +36,7 @@ PLATFORM_SCHEMA = mqtt.MQTT_BASE_PLATFORM_SCHEMA.extend(
async def async_setup_platform( async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
): ):
"""Set up MQTT scene through configuration.yaml.""" """Set up MQTT scene through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS) await async_setup_reload_service(hass, DOMAIN, PLATFORMS)

View File

@ -15,11 +15,11 @@ from homeassistant.const import (
CONF_UNIT_OF_MEASUREMENT, CONF_UNIT_OF_MEASUREMENT,
CONF_VALUE_TEMPLATE, CONF_VALUE_TEMPLATE,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_point_in_utc_time from homeassistant.helpers.event import async_track_point_in_utc_time
from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
from . import CONF_QOS, CONF_STATE_TOPIC, DOMAIN, PLATFORMS, subscription from . import CONF_QOS, CONF_STATE_TOPIC, DOMAIN, PLATFORMS, subscription
@ -48,7 +48,7 @@ PLATFORM_SCHEMA = mqtt.MQTT_RO_PLATFORM_SCHEMA.extend(
async def async_setup_platform( async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
): ):
"""Set up MQTT sensors through configuration.yaml.""" """Set up MQTT sensors through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS) await async_setup_reload_service(hass, DOMAIN, PLATFORMS)

View File

@ -5,7 +5,7 @@ from typing import Any, Callable
import attr import attr
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from homeassistant.loader import bind_hass from homeassistant.loader import bind_hass
from . import debug_info from . import debug_info
@ -18,7 +18,7 @@ from .models import MessageCallbackType
class EntitySubscription: class EntitySubscription:
"""Class to hold data about an active entity topic subscription.""" """Class to hold data about an active entity topic subscription."""
hass: HomeAssistantType = attr.ib() hass: HomeAssistant = attr.ib()
topic: str = attr.ib() topic: str = attr.ib()
message_callback: MessageCallbackType = attr.ib() message_callback: MessageCallbackType = attr.ib()
unsubscribe_callback: Callable[[], None] | None = attr.ib() unsubscribe_callback: Callable[[], None] | None = attr.ib()
@ -63,7 +63,7 @@ class EntitySubscription:
@bind_hass @bind_hass
async def async_subscribe_topics( async def async_subscribe_topics(
hass: HomeAssistantType, hass: HomeAssistant,
new_state: dict[str, EntitySubscription] | None, new_state: dict[str, EntitySubscription] | None,
topics: dict[str, Any], topics: dict[str, Any],
): ):
@ -106,6 +106,6 @@ async def async_subscribe_topics(
@bind_hass @bind_hass
async def async_unsubscribe_topics(hass: HomeAssistantType, sub_state: dict): async def async_unsubscribe_topics(hass: HomeAssistant, sub_state: dict):
"""Unsubscribe from all MQTT topics managed by async_subscribe_topics.""" """Unsubscribe from all MQTT topics managed by async_subscribe_topics."""
return await async_subscribe_topics(hass, sub_state, {}) return await async_subscribe_topics(hass, sub_state, {})

View File

@ -13,11 +13,11 @@ from homeassistant.const import (
CONF_VALUE_TEMPLATE, CONF_VALUE_TEMPLATE,
STATE_ON, STATE_ON,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.reload import async_setup_reload_service from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from . import ( from . import (
CONF_COMMAND_TOPIC, CONF_COMMAND_TOPIC,
@ -52,7 +52,7 @@ PLATFORM_SCHEMA = mqtt.MQTT_RW_PLATFORM_SCHEMA.extend(
async def async_setup_platform( async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
): ):
"""Set up MQTT switch through configuration.yaml.""" """Set up MQTT switch through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS) await async_setup_reload_service(hass, DOMAIN, PLATFORMS)

View File

@ -13,7 +13,7 @@ from homeassistant.components.meteo_france.const import (
) )
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_MODE from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_MODE
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -214,7 +214,7 @@ async def test_abort_if_already_setup(hass, client_single):
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
async def test_options_flow(hass: HomeAssistantType): async def test_options_flow(hass: HomeAssistant):
"""Test config flow options.""" """Test config flow options."""
config_entry = MockConfigEntry( config_entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,