mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Type hint additions (#26831)
* Type hint additions * Remove optional from sidebar_icon comment Co-Authored-By: Franck Nijhof <frenck@frenck.nl> * Remove optional from sidebar_title comment Co-Authored-By: Franck Nijhof <frenck@frenck.nl> * Fix issues after rebase and mypy 0.730
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
"""Offer state listening automation rules."""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Dict
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import exceptions
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.core import HomeAssistant, CALLBACK_TYPE, callback
|
||||
from homeassistant.const import MATCH_ALL, CONF_PLATFORM, CONF_FOR
|
||||
from homeassistant.helpers import config_validation as cv, template
|
||||
from homeassistant.helpers.event import async_track_state_change, async_track_same_state
|
||||
|
||||
|
||||
# mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs
|
||||
# mypy: allow-incomplete-defs, allow-untyped-calls, allow-untyped-defs
|
||||
# mypy: no-check-untyped-defs
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -38,8 +41,13 @@ TRIGGER_SCHEMA = vol.All(
|
||||
|
||||
|
||||
async def async_attach_trigger(
|
||||
hass, config, action, automation_info, *, platform_type="state"
|
||||
):
|
||||
hass: HomeAssistant,
|
||||
config,
|
||||
action,
|
||||
automation_info,
|
||||
*,
|
||||
platform_type: str = "state",
|
||||
) -> CALLBACK_TYPE:
|
||||
"""Listen for state changes based on configuration."""
|
||||
entity_id = config.get(CONF_ENTITY_ID)
|
||||
from_state = config.get(CONF_FROM, MATCH_ALL)
|
||||
@@ -48,7 +56,7 @@ async def async_attach_trigger(
|
||||
template.attach(hass, time_delta)
|
||||
match_all = from_state == MATCH_ALL and to_state == MATCH_ALL
|
||||
unsub_track_same = {}
|
||||
period = {}
|
||||
period: Dict[str, timedelta] = {}
|
||||
|
||||
@callback
|
||||
def state_automation_listener(entity, from_s, to_s):
|
||||
|
||||
Reference in New Issue
Block a user