diff --git a/homeassistant/components/comelit/config_flow.py b/homeassistant/components/comelit/config_flow.py index 66ab9ae88b3..b95853edf9d 100644 --- a/homeassistant/components/comelit/config_flow.py +++ b/homeassistant/components/comelit/config_flow.py @@ -16,7 +16,7 @@ import homeassistant.helpers.config_validation as cv from .const import _LOGGER, DEFAULT_PORT, DOMAIN DEFAULT_HOST = "192.168.1.252" -DEFAULT_PIN = "111111" +DEFAULT_PIN = 111111 def user_form_schema(user_input: dict[str, Any] | None) -> vol.Schema: @@ -31,7 +31,7 @@ def user_form_schema(user_input: dict[str, Any] | None) -> vol.Schema: ) -STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PIN): str}) +STEP_REAUTH_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PIN): cv.positive_int}) async def validate_input( diff --git a/homeassistant/components/comelit/const.py b/homeassistant/components/comelit/const.py index 7bd49440eb3..57b7f35bc17 100644 --- a/homeassistant/components/comelit/const.py +++ b/homeassistant/components/comelit/const.py @@ -5,7 +5,3 @@ _LOGGER = logging.getLogger(__package__) DOMAIN = "comelit" DEFAULT_PORT = 80 - -# Entity states -STATE_OFF = 0 -STATE_ON = 1 diff --git a/homeassistant/components/comelit/coordinator.py b/homeassistant/components/comelit/coordinator.py index 02a8d805d19..1fc4b0e6668 100644 --- a/homeassistant/components/comelit/coordinator.py +++ b/homeassistant/components/comelit/coordinator.py @@ -68,7 +68,7 @@ class ComelitSerialBridge(DataUpdateCoordinator): ) async def _async_update_data(self) -> dict[str, Any]: - """Update router data.""" + """Update device data.""" _LOGGER.debug("Polling Comelit Serial Bridge host: %s", self._host) logged = False try: diff --git a/homeassistant/components/comelit/cover.py b/homeassistant/components/comelit/cover.py index 08e1136ca9e..8bccd12e9a5 100644 --- a/homeassistant/components/comelit/cover.py +++ b/homeassistant/components/comelit/cover.py @@ -4,7 +4,7 @@ from __future__ import annotations from typing import Any from aiocomelit import ComelitSerialBridgeObject -from aiocomelit.const import COVER, COVER_CLOSE, COVER_OPEN, COVER_STATUS +from aiocomelit.const import COVER, STATE_COVER, STATE_OFF, STATE_ON from homeassistant.components.cover import STATE_CLOSED, CoverDeviceClass, CoverEntity from homeassistant.config_entries import ConfigEntry @@ -60,9 +60,9 @@ class ComelitCoverEntity( def _current_action(self, action: str) -> bool: """Return the current cover action.""" - is_moving = self.device_status == COVER_STATUS.index(action) + is_moving = self.device_status == STATE_COVER.index(action) if is_moving: - self._last_action = COVER_STATUS.index(action) + self._last_action = STATE_COVER.index(action) return is_moving @property @@ -77,11 +77,11 @@ class ComelitCoverEntity( if self._last_state in [None, "unknown"]: return None - if self.device_status != COVER_STATUS.index("stopped"): + if self.device_status != STATE_COVER.index("stopped"): return False if self._last_action: - return self._last_action == COVER_STATUS.index("closing") + return self._last_action == STATE_COVER.index("closing") return self._last_state == STATE_CLOSED @@ -97,18 +97,18 @@ class ComelitCoverEntity( async def async_close_cover(self, **kwargs: Any) -> None: """Close cover.""" - await self._api.set_device_status(COVER, self._device.index, COVER_CLOSE) + await self._api.set_device_status(COVER, self._device.index, STATE_OFF) async def async_open_cover(self, **kwargs: Any) -> None: """Open cover.""" - await self._api.set_device_status(COVER, self._device.index, COVER_OPEN) + await self._api.set_device_status(COVER, self._device.index, STATE_ON) async def async_stop_cover(self, **_kwargs: Any) -> None: """Stop the cover.""" if not self.is_closing and not self.is_opening: return - action = COVER_OPEN if self.is_closing else COVER_CLOSE + action = STATE_OFF if self.is_closing else STATE_ON await self._api.set_device_status(COVER, self._device.index, action) @callback diff --git a/homeassistant/components/comelit/light.py b/homeassistant/components/comelit/light.py index 1bdf3e6a87b..15c4ec8cc7e 100644 --- a/homeassistant/components/comelit/light.py +++ b/homeassistant/components/comelit/light.py @@ -4,7 +4,7 @@ from __future__ import annotations from typing import Any from aiocomelit import ComelitSerialBridgeObject -from aiocomelit.const import LIGHT +from aiocomelit.const import LIGHT, STATE_OFF, STATE_ON from homeassistant.components.light import LightEntity from homeassistant.config_entries import ConfigEntry @@ -12,7 +12,7 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity -from .const import DOMAIN, STATE_OFF, STATE_ON +from .const import DOMAIN from .coordinator import ComelitSerialBridge diff --git a/homeassistant/components/comelit/manifest.json b/homeassistant/components/comelit/manifest.json index 7da4f70ce99..5978f17cfc4 100644 --- a/homeassistant/components/comelit/manifest.json +++ b/homeassistant/components/comelit/manifest.json @@ -6,5 +6,5 @@ "documentation": "https://www.home-assistant.io/integrations/comelit", "iot_class": "local_polling", "loggers": ["aiocomelit"], - "requirements": ["aiocomelit==0.2.0"] + "requirements": ["aiocomelit==0.3.0"] } diff --git a/homeassistant/components/comelit/strings.json b/homeassistant/components/comelit/strings.json index 436fbfd5aec..730674e913a 100644 --- a/homeassistant/components/comelit/strings.json +++ b/homeassistant/components/comelit/strings.json @@ -11,6 +11,7 @@ "user": { "data": { "host": "[%key:common::config_flow::data::host%]", + "port": "[%key:common::config_flow::data::port%]", "pin": "[%key:common::config_flow::data::pin%]" } } diff --git a/requirements_all.txt b/requirements_all.txt index b5733231b2d..f2cda4fd70d 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -216,7 +216,7 @@ aiobafi6==0.9.0 aiobotocore==2.6.0 # homeassistant.components.comelit -aiocomelit==0.2.0 +aiocomelit==0.3.0 # homeassistant.components.dhcp aiodiscover==1.5.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index bae102058d1..fdef44810c8 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -197,7 +197,7 @@ aiobafi6==0.9.0 aiobotocore==2.6.0 # homeassistant.components.comelit -aiocomelit==0.2.0 +aiocomelit==0.3.0 # homeassistant.components.dhcp aiodiscover==1.5.1 diff --git a/tests/components/comelit/const.py b/tests/components/comelit/const.py index a21ddbd425a..10999b04bea 100644 --- a/tests/components/comelit/const.py +++ b/tests/components/comelit/const.py @@ -16,3 +16,5 @@ MOCK_CONFIG = { } MOCK_USER_DATA = MOCK_CONFIG[DOMAIN][CONF_DEVICES][0] + +FAKE_PIN = 5678 diff --git a/tests/components/comelit/test_config_flow.py b/tests/components/comelit/test_config_flow.py index 4e3831809cb..f2d59f46114 100644 --- a/tests/components/comelit/test_config_flow.py +++ b/tests/components/comelit/test_config_flow.py @@ -10,7 +10,7 @@ from homeassistant.const import CONF_HOST, CONF_PIN, CONF_PORT from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType -from .const import MOCK_USER_DATA +from .const import FAKE_PIN, MOCK_USER_DATA from tests.common import MockConfigEntry @@ -108,7 +108,7 @@ async def test_reauth_successful(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={ - CONF_PIN: "other_fake_pin", + CONF_PIN: FAKE_PIN, }, ) await hass.async_block_till_done() @@ -150,7 +150,7 @@ async def test_reauth_not_successful(hass: HomeAssistant, side_effect, error) -> result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={ - CONF_PIN: "other_fake_pin", + CONF_PIN: FAKE_PIN, }, )