Bump aiocomelit to 0.3.0 (#102340)

* Bump aiocomelit to 0.3.0

* missing string
This commit is contained in:
Simone Chemelli 2023-10-19 19:15:06 +02:00 committed by GitHub
parent 5eb0a33795
commit c574cefc30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 22 additions and 23 deletions

View File

@ -16,7 +16,7 @@ import homeassistant.helpers.config_validation as cv
from .const import _LOGGER, DEFAULT_PORT, DOMAIN from .const import _LOGGER, DEFAULT_PORT, DOMAIN
DEFAULT_HOST = "192.168.1.252" DEFAULT_HOST = "192.168.1.252"
DEFAULT_PIN = "111111" DEFAULT_PIN = 111111
def user_form_schema(user_input: dict[str, Any] | None) -> vol.Schema: 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( async def validate_input(

View File

@ -5,7 +5,3 @@ _LOGGER = logging.getLogger(__package__)
DOMAIN = "comelit" DOMAIN = "comelit"
DEFAULT_PORT = 80 DEFAULT_PORT = 80
# Entity states
STATE_OFF = 0
STATE_ON = 1

View File

@ -68,7 +68,7 @@ class ComelitSerialBridge(DataUpdateCoordinator):
) )
async def _async_update_data(self) -> dict[str, Any]: 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) _LOGGER.debug("Polling Comelit Serial Bridge host: %s", self._host)
logged = False logged = False
try: try:

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from typing import Any from typing import Any
from aiocomelit import ComelitSerialBridgeObject 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.components.cover import STATE_CLOSED, CoverDeviceClass, CoverEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -60,9 +60,9 @@ class ComelitCoverEntity(
def _current_action(self, action: str) -> bool: def _current_action(self, action: str) -> bool:
"""Return the current cover action.""" """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: if is_moving:
self._last_action = COVER_STATUS.index(action) self._last_action = STATE_COVER.index(action)
return is_moving return is_moving
@property @property
@ -77,11 +77,11 @@ class ComelitCoverEntity(
if self._last_state in [None, "unknown"]: if self._last_state in [None, "unknown"]:
return None return None
if self.device_status != COVER_STATUS.index("stopped"): if self.device_status != STATE_COVER.index("stopped"):
return False return False
if self._last_action: 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 return self._last_state == STATE_CLOSED
@ -97,18 +97,18 @@ class ComelitCoverEntity(
async def async_close_cover(self, **kwargs: Any) -> None: async def async_close_cover(self, **kwargs: Any) -> None:
"""Close cover.""" """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: async def async_open_cover(self, **kwargs: Any) -> None:
"""Open cover.""" """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: async def async_stop_cover(self, **_kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
if not self.is_closing and not self.is_opening: if not self.is_closing and not self.is_opening:
return 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) await self._api.set_device_status(COVER, self._device.index, action)
@callback @callback

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from typing import Any from typing import Any
from aiocomelit import ComelitSerialBridgeObject 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.components.light import LightEntity
from homeassistant.config_entries import ConfigEntry 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.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DOMAIN, STATE_OFF, STATE_ON from .const import DOMAIN
from .coordinator import ComelitSerialBridge from .coordinator import ComelitSerialBridge

View File

@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/comelit", "documentation": "https://www.home-assistant.io/integrations/comelit",
"iot_class": "local_polling", "iot_class": "local_polling",
"loggers": ["aiocomelit"], "loggers": ["aiocomelit"],
"requirements": ["aiocomelit==0.2.0"] "requirements": ["aiocomelit==0.3.0"]
} }

View File

@ -11,6 +11,7 @@
"user": { "user": {
"data": { "data": {
"host": "[%key:common::config_flow::data::host%]", "host": "[%key:common::config_flow::data::host%]",
"port": "[%key:common::config_flow::data::port%]",
"pin": "[%key:common::config_flow::data::pin%]" "pin": "[%key:common::config_flow::data::pin%]"
} }
} }

View File

@ -216,7 +216,7 @@ aiobafi6==0.9.0
aiobotocore==2.6.0 aiobotocore==2.6.0
# homeassistant.components.comelit # homeassistant.components.comelit
aiocomelit==0.2.0 aiocomelit==0.3.0
# homeassistant.components.dhcp # homeassistant.components.dhcp
aiodiscover==1.5.1 aiodiscover==1.5.1

View File

@ -197,7 +197,7 @@ aiobafi6==0.9.0
aiobotocore==2.6.0 aiobotocore==2.6.0
# homeassistant.components.comelit # homeassistant.components.comelit
aiocomelit==0.2.0 aiocomelit==0.3.0
# homeassistant.components.dhcp # homeassistant.components.dhcp
aiodiscover==1.5.1 aiodiscover==1.5.1

View File

@ -16,3 +16,5 @@ MOCK_CONFIG = {
} }
MOCK_USER_DATA = MOCK_CONFIG[DOMAIN][CONF_DEVICES][0] MOCK_USER_DATA = MOCK_CONFIG[DOMAIN][CONF_DEVICES][0]
FAKE_PIN = 5678

View File

@ -10,7 +10,7 @@ from homeassistant.const import CONF_HOST, CONF_PIN, CONF_PORT
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType 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 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 = await hass.config_entries.flow.async_configure(
result["flow_id"], result["flow_id"],
user_input={ user_input={
CONF_PIN: "other_fake_pin", CONF_PIN: FAKE_PIN,
}, },
) )
await hass.async_block_till_done() 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 = await hass.config_entries.flow.async_configure(
result["flow_id"], result["flow_id"],
user_input={ user_input={
CONF_PIN: "other_fake_pin", CONF_PIN: FAKE_PIN,
}, },
) )