diff --git a/.strict-typing b/.strict-typing index 715cb9f0e305..66075b93743b 100644 --- a/.strict-typing +++ b/.strict-typing @@ -43,7 +43,6 @@ homeassistant.components homeassistant.components.abode.* homeassistant.components.acaia.* homeassistant.components.accuweather.* -homeassistant.components.acer_projector.* homeassistant.components.acmeda.* homeassistant.components.actiontec.* homeassistant.components.actron_air.* diff --git a/homeassistant/components/acer_projector/__init__.py b/homeassistant/components/acer_projector/__init__.py deleted file mode 100644 index 39896d203b1f..000000000000 --- a/homeassistant/components/acer_projector/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""The acer_projector component.""" diff --git a/homeassistant/components/acer_projector/const.py b/homeassistant/components/acer_projector/const.py deleted file mode 100644 index 367040273b7e..000000000000 --- a/homeassistant/components/acer_projector/const.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Use serial protocol of Acer projector to obtain state of the projector.""" - -from typing import Final - -from homeassistant.const import STATE_OFF, STATE_ON - -CONF_READ_TIMEOUT: Final = "timeout" -CONF_WRITE_TIMEOUT: Final = "write_timeout" - -DEFAULT_NAME: Final = "Acer Projector" -DEFAULT_READ_TIMEOUT: Final = 1 -DEFAULT_WRITE_TIMEOUT: Final = 1 - -ECO_MODE: Final = "ECO Mode" - -ICON: Final = "mdi:projector" - -INPUT_SOURCE: Final = "Input Source" - -LAMP: Final = "Lamp" -LAMP_HOURS: Final = "Lamp Hours" - -MODEL: Final = "Model" - -# Commands known to the projector -CMD_DICT: Final[dict[str, str]] = { - LAMP: "* 0 Lamp ?\r", - LAMP_HOURS: "* 0 Lamp\r", - INPUT_SOURCE: "* 0 Src ?\r", - ECO_MODE: "* 0 IR 052\r", - MODEL: "* 0 IR 035\r", - STATE_ON: "* 0 IR 001\r", - STATE_OFF: "* 0 IR 002\r", -} diff --git a/homeassistant/components/acer_projector/manifest.json b/homeassistant/components/acer_projector/manifest.json deleted file mode 100644 index 37de5ef22682..000000000000 --- a/homeassistant/components/acer_projector/manifest.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "domain": "acer_projector", - "name": "Acer Projector", - "codeowners": [], - "documentation": "https://www.home-assistant.io/integrations/acer_projector", - "iot_class": "local_polling", - "quality_scale": "legacy", - "requirements": ["serialx==1.8.2"] -} diff --git a/homeassistant/components/acer_projector/switch.py b/homeassistant/components/acer_projector/switch.py deleted file mode 100644 index 108bd45bce7a..000000000000 --- a/homeassistant/components/acer_projector/switch.py +++ /dev/null @@ -1,155 +0,0 @@ -"""Use serial protocol of Acer projector to obtain state of the projector.""" - -import logging -import re -from typing import Any, override - -from serialx import Serial, SerialException -import voluptuous as vol - -from homeassistant.components.switch import ( - PLATFORM_SCHEMA as SWITCH_PLATFORM_SCHEMA, - SwitchEntity, -) -from homeassistant.const import ( - CONF_FILENAME, - CONF_NAME, - STATE_OFF, - STATE_ON, - STATE_UNKNOWN, -) -from homeassistant.core import HomeAssistant -from homeassistant.exceptions import HomeAssistantError -from homeassistant.helpers import config_validation as cv -from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType - -from .const import ( - CMD_DICT, - CONF_READ_TIMEOUT, - CONF_WRITE_TIMEOUT, - DEFAULT_NAME, - DEFAULT_READ_TIMEOUT, - DEFAULT_WRITE_TIMEOUT, - ECO_MODE, - ICON, - INPUT_SOURCE, - LAMP, - LAMP_HOURS, -) - -_LOGGER = logging.getLogger(__name__) - -PLATFORM_SCHEMA = SWITCH_PLATFORM_SCHEMA.extend( - { - vol.Required(CONF_FILENAME): cv.isdevice, - vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, - vol.Optional(CONF_READ_TIMEOUT, default=DEFAULT_READ_TIMEOUT): cv.positive_int, - vol.Optional( - CONF_WRITE_TIMEOUT, default=DEFAULT_WRITE_TIMEOUT - ): cv.positive_int, - } -) - - -def setup_platform( - hass: HomeAssistant, - config: ConfigType, - add_entities: AddEntitiesCallback, - discovery_info: DiscoveryInfoType | None = None, -) -> None: - """Connect with serial port and return Acer Projector.""" - serial_port = config[CONF_FILENAME] - name = config[CONF_NAME] - read_timeout = config[CONF_READ_TIMEOUT] - write_timeout = config[CONF_WRITE_TIMEOUT] - - add_entities([AcerSwitch(serial_port, name, read_timeout, write_timeout)], True) - - -class AcerSwitch(SwitchEntity): - """Represents an Acer Projector as a switch.""" - - _attr_icon = ICON - - def __init__( - self, - serial_port: str, - name: str, - read_timeout: int, - write_timeout: int, - ) -> None: - """Init of the Acer projector.""" - self._serial_port = serial_port - self._read_timeout = read_timeout - self._write_timeout = write_timeout - - self._attr_name = name - self._attributes = { - LAMP_HOURS: STATE_UNKNOWN, - INPUT_SOURCE: STATE_UNKNOWN, - ECO_MODE: STATE_UNKNOWN, - } - - def _write_read(self, msg: str) -> str: - """Write to the projector and read the return.""" - - # Sometimes the projector won't answer for no reason or the projector - # was disconnected during runtime. - # This way the projector can be reconnected and will still work - try: - with Serial.from_url( - self._serial_port, - read_timeout=self._read_timeout, - write_timeout=self._write_timeout, - ) as serial: - serial.write(msg.encode("utf-8")) - - # Size is an experience value there is no real limit. - # AFAIK there is no limit and no end character so we will usually - # need to wait for timeout - return serial.read_until(size=20).decode("utf-8") - except (OSError, SerialException, TimeoutError) as exc: - raise HomeAssistantError( - f"Problem communicating with {self._serial_port}" - ) from exc - - def _write_read_format(self, msg: str) -> str: - """Write msg, obtain answer and format output.""" - # answers are formatted as ***\answer\r*** - awns = self._write_read(msg) - if match := re.search(r"\r(.+)\r", awns): - return match.group(1) - return STATE_UNKNOWN - - def update(self) -> None: - """Get the latest state from the projector.""" - awns = self._write_read_format(CMD_DICT[LAMP]) - if awns == "Lamp 1": - self._attr_is_on = True - self._attr_available = True - elif awns == "Lamp 0": - self._attr_is_on = False - self._attr_available = True - else: - self._attr_available = False - - for key in self._attributes: - if msg := CMD_DICT.get(key): - awns = self._write_read_format(msg) - self._attributes[key] = awns - self._attr_extra_state_attributes = self._attributes - - @override - def turn_on(self, **kwargs: Any) -> None: - """Turn the projector on.""" - msg = CMD_DICT[STATE_ON] - self._write_read(msg) - self._attr_is_on = True - - @override - def turn_off(self, **kwargs: Any) -> None: - """Turn the projector off.""" - msg = CMD_DICT[STATE_OFF] - self._write_read(msg) - self._attr_is_on = False diff --git a/homeassistant/generated/integrations.json b/homeassistant/generated/integrations.json index cb2055a0c4a6..3fabb1df6e85 100644 --- a/homeassistant/generated/integrations.json +++ b/homeassistant/generated/integrations.json @@ -24,12 +24,6 @@ "config_flow": true, "iot_class": "cloud_polling" }, - "acer_projector": { - "name": "Acer Projector", - "integration_type": "hub", - "config_flow": false, - "iot_class": "local_polling" - }, "acmeda": { "name": "Rollease Acmeda Automate", "integration_type": "hub", diff --git a/mypy.ini b/mypy.ini index 847d54a5120b..5b8c3d01004b 100644 --- a/mypy.ini +++ b/mypy.ini @@ -186,16 +186,6 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true -[mypy-homeassistant.components.acer_projector.*] -check_untyped_defs = true -disallow_incomplete_defs = true -disallow_subclassing_any = true -disallow_untyped_calls = true -disallow_untyped_decorators = true -disallow_untyped_defs = true -warn_return_any = true -warn_unreachable = true - [mypy-homeassistant.components.acmeda.*] check_untyped_defs = true disallow_incomplete_defs = true diff --git a/requirements_all.txt b/requirements_all.txt index 334deeec75e2..52d8557da585 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -3004,7 +3004,6 @@ sentence-stream==1.3.0 # homeassistant.components.sentry sentry-sdk==2.48.0 -# homeassistant.components.acer_projector # homeassistant.components.serial # homeassistant.components.usb serialx==1.8.2 diff --git a/script/hassfest/quality_scale.py b/script/hassfest/quality_scale.py index d026b068a3c3..73be7116c605 100644 --- a/script/hassfest/quality_scale.py +++ b/script/hassfest/quality_scale.py @@ -110,7 +110,6 @@ RULE_URL = ( INTEGRATIONS_WITHOUT_QUALITY_SCALE_FILE = [ "abode", "accuweather", - "acer_projector", "acmeda", "actiontec", "adax", @@ -1059,7 +1058,6 @@ INTEGRATIONS_WITHOUT_QUALITY_SCALE_FILE = [ INTEGRATIONS_WITHOUT_SCALE = [ "abode", "accuweather", - "acer_projector", "acmeda", "actiontec", "adax",