mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Add setup type hints [f] (#63431)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
506a0b526b
commit
1ac3e71462
@ -1,4 +1,6 @@
|
|||||||
"""Support for displaying IPs banned by fail2ban."""
|
"""Support for displaying IPs banned by fail2ban."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -8,7 +10,10 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import CONF_FILE_PATH, CONF_NAME
|
from homeassistant.const import CONF_FILE_PATH, CONF_NAME
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -30,10 +35,15 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
async def async_setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the fail2ban sensor."""
|
"""Set up the fail2ban sensor."""
|
||||||
name = config.get(CONF_NAME)
|
name = config[CONF_NAME]
|
||||||
jails = config.get(CONF_JAILS)
|
jails = config[CONF_JAILS]
|
||||||
log_file = config.get(CONF_FILE_PATH, DEFAULT_LOG)
|
log_file = config.get(CONF_FILE_PATH, DEFAULT_LOG)
|
||||||
|
|
||||||
device_list = []
|
device_list = []
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Support for sensor value(s) stored in local files."""
|
"""Support for sensor value(s) stored in local files."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -11,7 +13,10 @@ from homeassistant.const import (
|
|||||||
CONF_UNIT_OF_MEASUREMENT,
|
CONF_UNIT_OF_MEASUREMENT,
|
||||||
CONF_VALUE_TEMPLATE,
|
CONF_VALUE_TEMPLATE,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -29,10 +34,15 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
async def async_setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the file sensor."""
|
"""Set up the file sensor."""
|
||||||
file_path = config.get(CONF_FILE_PATH)
|
file_path = config[CONF_FILE_PATH]
|
||||||
name = config.get(CONF_NAME)
|
name = config[CONF_NAME]
|
||||||
unit = config.get(CONF_UNIT_OF_MEASUREMENT)
|
unit = config.get(CONF_UNIT_OF_MEASUREMENT)
|
||||||
|
|
||||||
if (value_template := config.get(CONF_VALUE_TEMPLATE)) is not None:
|
if (value_template := config.get(CONF_VALUE_TEMPLATE)) is not None:
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Sensor for monitoring the size of a file."""
|
"""Sensor for monitoring the size of a file."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -7,8 +9,11 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import DATA_MEGABYTES
|
from homeassistant.const import DATA_MEGABYTES
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.reload import setup_reload_service
|
from homeassistant.helpers.reload import setup_reload_service
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
from . import DOMAIN, PLATFORMS
|
from . import DOMAIN, PLATFORMS
|
||||||
|
|
||||||
@ -23,13 +28,18 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the file size sensor."""
|
"""Set up the file size sensor."""
|
||||||
|
|
||||||
setup_reload_service(hass, DOMAIN, PLATFORMS)
|
setup_reload_service(hass, DOMAIN, PLATFORMS)
|
||||||
|
|
||||||
sensors = []
|
sensors = []
|
||||||
for path in config.get(CONF_FILE_PATHS):
|
for path in config[CONF_FILE_PATHS]:
|
||||||
if not hass.config.is_allowed_path(path):
|
if not hass.config.is_allowed_path(path):
|
||||||
_LOGGER.error("Filepath %s is not valid or allowed", path)
|
_LOGGER.error("Filepath %s is not valid or allowed", path)
|
||||||
continue
|
continue
|
||||||
|
@ -12,7 +12,10 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import CONF_NAME, CONF_PIN, CONF_URL, CONF_USERNAME
|
from homeassistant.const import CONF_NAME, CONF_PIN, CONF_URL, CONF_USERNAME
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -51,7 +54,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the sensors.
|
"""Set up the sensors.
|
||||||
|
|
||||||
Login to the bank and get a list of existing accounts. Create a
|
Login to the bank and get a list of existing accounts. Create a
|
||||||
@ -72,7 +80,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
|
|
||||||
client = FinTsClient(credentials, fints_name)
|
client = FinTsClient(credentials, fints_name)
|
||||||
balance_accounts, holdings_accounts = client.detect_accounts()
|
balance_accounts, holdings_accounts = client.detect_accounts()
|
||||||
accounts = []
|
accounts: list[SensorEntity] = []
|
||||||
|
|
||||||
for account in balance_accounts:
|
for account in balance_accounts:
|
||||||
if config[CONF_ACCOUNTS] and account.iban not in account_config:
|
if config[CONF_ACCOUNTS] and account.iban not in account_config:
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Sensor for monitoring the contents of a folder."""
|
"""Sensor for monitoring the contents of a folder."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import glob
|
import glob
|
||||||
import logging
|
import logging
|
||||||
@ -8,7 +10,10 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import DATA_MEGABYTES
|
from homeassistant.const import DATA_MEGABYTES
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -39,14 +44,19 @@ def get_size(files_list):
|
|||||||
return sum(size_list)
|
return sum(size_list)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the folder sensor."""
|
"""Set up the folder sensor."""
|
||||||
path = config.get(CONF_FOLDER_PATHS)
|
path = config[CONF_FOLDER_PATHS]
|
||||||
|
|
||||||
if not hass.config.is_allowed_path(path):
|
if not hass.config.is_allowed_path(path):
|
||||||
_LOGGER.error("Folder %s is not valid or allowed", path)
|
_LOGGER.error("Folder %s is not valid or allowed", path)
|
||||||
else:
|
else:
|
||||||
folder = Folder(path, config.get(CONF_FILTER))
|
folder = Folder(path, config[CONF_FILTER])
|
||||||
add_entities([folder], True)
|
add_entities([folder], True)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user