diff --git a/homeassistant/components/command_line/binary_sensor.py b/homeassistant/components/command_line/binary_sensor.py index 6021a5ef4f7..0cfb35cf008 100644 --- a/homeassistant/components/command_line/binary_sensor.py +++ b/homeassistant/components/command_line/binary_sensor.py @@ -1,4 +1,6 @@ """Support for custom shell commands to retrieve values.""" +from __future__ import annotations + from datetime import timedelta import voluptuous as vol @@ -16,8 +18,11 @@ from homeassistant.const import ( CONF_PAYLOAD_ON, CONF_VALUE_TEMPLATE, ) +from homeassistant.core import HomeAssistant 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.typing import ConfigType, DiscoveryInfoType from .const import CONF_COMMAND_TIMEOUT, DEFAULT_TIMEOUT, DOMAIN, PLATFORMS from .sensor import CommandSensorData @@ -42,7 +47,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 Command line Binary Sensor.""" setup_reload_service(hass, DOMAIN, PLATFORMS) diff --git a/homeassistant/components/command_line/cover.py b/homeassistant/components/command_line/cover.py index 961d9a31f4e..0acebd90d80 100644 --- a/homeassistant/components/command_line/cover.py +++ b/homeassistant/components/command_line/cover.py @@ -1,4 +1,6 @@ """Support for command line covers.""" +from __future__ import annotations + import logging import voluptuous as vol @@ -13,8 +15,11 @@ from homeassistant.const import ( CONF_FRIENDLY_NAME, CONF_VALUE_TEMPLATE, ) +from homeassistant.core import HomeAssistant 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.typing import ConfigType, DiscoveryInfoType from . import call_shell_with_timeout, check_output_or_log from .const import CONF_COMMAND_TIMEOUT, DEFAULT_TIMEOUT, DOMAIN, PLATFORMS @@ -38,7 +43,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 cover controlled by shell commands.""" setup_reload_service(hass, DOMAIN, PLATFORMS) @@ -66,7 +76,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): if not covers: _LOGGER.error("No covers added") - return False + return add_entities(covers) diff --git a/homeassistant/components/command_line/sensor.py b/homeassistant/components/command_line/sensor.py index 43e05a429b6..824b597ac41 100644 --- a/homeassistant/components/command_line/sensor.py +++ b/homeassistant/components/command_line/sensor.py @@ -1,4 +1,6 @@ """Allows to configure custom shell commands to turn a value for a sensor.""" +from __future__ import annotations + from collections.abc import Mapping from datetime import timedelta import json @@ -14,10 +16,13 @@ from homeassistant.const import ( CONF_VALUE_TEMPLATE, STATE_UNKNOWN, ) +from homeassistant.core import HomeAssistant from homeassistant.exceptions import TemplateError from homeassistant.helpers import template 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.typing import ConfigType, DiscoveryInfoType from . import check_output_or_log from .const import CONF_COMMAND_TIMEOUT, DEFAULT_TIMEOUT, DOMAIN, PLATFORMS @@ -42,7 +47,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 Command Sensor.""" setup_reload_service(hass, DOMAIN, PLATFORMS) diff --git a/homeassistant/components/command_line/switch.py b/homeassistant/components/command_line/switch.py index fae4cdbcc6b..3fc9068c937 100644 --- a/homeassistant/components/command_line/switch.py +++ b/homeassistant/components/command_line/switch.py @@ -1,4 +1,6 @@ """Support for custom shell commands to turn a switch on/off.""" +from __future__ import annotations + import logging import voluptuous as vol @@ -17,8 +19,11 @@ from homeassistant.const import ( CONF_SWITCHES, CONF_VALUE_TEMPLATE, ) +from homeassistant.core import HomeAssistant 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.typing import ConfigType, DiscoveryInfoType from . import call_shell_with_timeout, check_output_or_log from .const import CONF_COMMAND_TIMEOUT, DEFAULT_TIMEOUT, DOMAIN, PLATFORMS @@ -42,7 +47,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: """Find and return switches controlled by shell commands.""" setup_reload_service(hass, DOMAIN, PLATFORMS) @@ -76,7 +86,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): if not switches: _LOGGER.error("No switches added") - return False + return add_entities(switches)