Skip to content

Commit

Permalink
Merge pull request #766 from MTrab:Fix-2025.3-dependencies-fail
Browse files Browse the repository at this point in the history
Bump pyworxcloud to fix v2025.3 dependencies
  • Loading branch information
MTrab authored Feb 28, 2025
2 parents a3f8740 + 0951ceb commit f2a5897
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 101 deletions.
3 changes: 2 additions & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"github.vscode-pull-request-github",
"ryanluker.vscode-coverage-gutters",
"ms-python.vscode-pylance",
"ms-python.isort"
"ms-python.isort",
"ms-python.black-formatter"
],
"settings": {
"files.eol": "\n",
Expand Down
1 change: 1 addition & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ ignore = [
"D411", # Missing blank line before section
"E501", # line too long
"E731", # do not assign a lambda expression, use a def
"E722", # do not use bare `except`
]

[flake8-pytest-style]
Expand Down
4 changes: 2 additions & 2 deletions custom_components/landroid_cloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:


async def _async_setup(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Setup the integration using a config entry."""
"""Handle setup of the integration, using a config entry."""
integration = await async_get_integration(hass, DOMAIN)
LOGGER.log(
None,
Expand Down Expand Up @@ -227,7 +227,7 @@ async def _async_setup(hass: HomeAssistant, entry: ConfigEntry) -> bool:


async def async_init_device(hass, entry, name, device) -> None:
"""Initialize a device"""
"""Initialize a device."""
LOGGER.log(
LoggerType.SETUP,
"Setting up device '%s' on account '%s'",
Expand Down
9 changes: 5 additions & 4 deletions custom_components/landroid_cloud/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def __init__(self, hass: HomeAssistant, device_name: str, entry: ConfigEntry):
Args:
hass (HomeAssistant): Home Assistant object
index (int): Device number to connect to. 0 is the first device associated.
device (WorxCloud): pyWorxlandroid object for the connection.
device_name (str): Name of the mower device.
entry (ConfigEntry): Home Assistant configuration entry for the cloud account.
"""
self.hass = hass
self.entry_id = entry.entry_id
Expand Down Expand Up @@ -75,7 +75,7 @@ def mqtt_conn_check(self, state: bool) -> None:
).result()

async def async_await_features(self, timeout: int = 10) -> None:
"""Used to await feature checks."""
"""Await feature checks."""
timeout_at = datetime.now() + timedelta(seconds=timeout)

while not self.features_loaded:
Expand Down Expand Up @@ -103,6 +103,7 @@ def check_features(
callback_func (_type_, optional):
Function to be called when the features
have been assessed. Defaults to None.
"""
self.logger.log(LoggerType.FEATURE_ASSESSMENT, "Assessing available features")
if isinstance(features, type(None)):
Expand Down Expand Up @@ -146,7 +147,7 @@ def has_feature(self, api_feature: DeviceCapability) -> bool:
def receive_data(
self, name: str, device: DeviceHandler # pylint: disable=unused-argument
) -> None:
"""Callback function when the MQTT broker sends new data."""
"""Handle data when the MQTT broker sends new data."""
self.device = device
self.logger.log(
LoggerType.DATA_UPDATE,
Expand Down
6 changes: 1 addition & 5 deletions custom_components/landroid_cloud/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@
entity_category=EntityCategory.DIAGNOSTIC,
device_class=BinarySensorDeviceClass.MOISTURE,
entity_registry_enabled_default=True,
value_fn=lambda landroid: (
landroid.rainsensor["triggered"]
if "triggered" in landroid.rainsensor
else None
),
value_fn=lambda landroid: landroid.rainsensor.get("triggered", None),
),
]

Expand Down
1 change: 1 addition & 0 deletions custom_components/landroid_cloud/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

async def validate_input(hass: core.HomeAssistant, data):
"""Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
"""

Expand Down
2 changes: 1 addition & 1 deletion custom_components/landroid_cloud/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
# Available cloud vendors
CLOUDS = []
for name, cloud in inspect.getmembers(CloudType):
if inspect.isclass(cloud) and not "__" in name:
if inspect.isclass(cloud) and "__" not in name:
CLOUDS.append(name.capitalize())

# State mapping
Expand Down
70 changes: 32 additions & 38 deletions custom_components/landroid_cloud/device_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import annotations

import asyncio
import contextlib
import json
import logging
import time
Expand Down Expand Up @@ -33,7 +34,6 @@
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_registry import EntityRegistry
from homeassistant.util import slugify as util_slugify
from pyworxcloud import DeviceCapability, WorxCloud
Expand All @@ -44,7 +44,6 @@
ZoneNotDefined,
)
from pyworxcloud.utils import DeviceHandler
from sqlalchemy import true

from .api import LandroidAPI
from .attribute_map import ATTR_MAP
Expand All @@ -66,7 +65,6 @@
SERVICE_OTS,
SERVICE_SCHEDULE,
SERVICE_SEND_RAW,
SERVICE_SETZONE,
STATE_INITIALIZING,
STATE_MAP,
STATE_OFFLINE,
Expand Down Expand Up @@ -153,19 +151,18 @@ class LandroidSelectEntityDescription(SelectEntityDescription):


class LandroidCloudBaseEntity(LandroidLogger):
"""
Define a base Landroid Cloud entity class.\n
\n
Override these functions as needed by the specific device integration:\n
async def async_edgecut(self, data: dict|None = None) -> None:\n
async def async_toggle_lock(self, data: dict|None = None) -> None:\n
async def async_toggle_partymode(self, data: dict|None = None) -> None:\n
async def async_restart(self, data: dict|None = None) -> None:\n
async def async_set_zone(self, data: dict|None = None) -> None:\n
async def async_config(self, data: dict|None = None) -> None:\n
async def async_ots(self, data: dict|None = None) -> None:\n
async def async_set_schedule(self, data: dict|None = None) -> None:\n
async def async_set_torque(self, data: dict|None = None) -> None:\n
"""Define a base Landroid Cloud entity class.
Override these functions as needed by the specific device integration:
async def async_edgecut(self, data: dict|None = None) -> None:
async def async_toggle_lock(self, data: dict|None = None) -> None:
async def async_toggle_partymode(self, data: dict|None = None) -> None:
async def async_restart(self, data: dict|None = None) -> None:
async def async_set_zone(self, data: dict|None = None) -> None:
async def async_config(self, data: dict|None = None) -> None:
async def async_ots(self, data: dict|None = None) -> None:
async def async_set_schedule(self, data: dict|None = None) -> None:
async def async_set_torque(self, data: dict|None = None) -> None:
"""

_battery_level: int | None = None
Expand All @@ -191,11 +188,11 @@ def __init__(self, hass: HomeAssistant, api: LandroidAPI):

@property
def base_features(self) -> int:
"""Called to get the base features."""
"""Call to get the base features."""
return None

async def async_edgecut(self, data: dict | None = None) -> None:
"""Called to start edge cut task."""
"""Call to start edge cut task."""
return None

async def async_toggle_lock(self, data: dict | None = None) -> None:
Expand Down Expand Up @@ -246,7 +243,7 @@ def get_config_scheme() -> Any:

@property
def device_info(self):
"""Return device info"""
"""Return device info."""
info = {
"identifiers": {
(
Expand Down Expand Up @@ -277,10 +274,10 @@ async def async_added_to_hass(self):
entry = entity_reg.async_get(self.entity_id)
self.api.device_id = entry.device_id
if (
not self.hass.data[DOMAIN][self.api.entry_id][ATTR_DEVICEIDS][
self.hass.data[DOMAIN][self.api.entry_id][ATTR_DEVICEIDS][
self.api.device.name
]
== entry.device_id
!= entry.device_id
):
self.hass.data[DOMAIN][self.api.entry_id][ATTR_DEVICEIDS].update(
{self.api.device.name: entry.device_id}
Expand All @@ -299,16 +296,16 @@ async def async_added_to_hass(self):

@callback
def update_callback(self):
"""Base update callback function"""
"""Handle base update callback."""
return False

@callback
def update_selected_zone(self):
"""Update zone selections in select entity"""
"""Update zone selections in select entity."""
return False

async def async_update(self):
"""Default async_update"""
"""Handle default async_update actions."""
return

@callback
Expand Down Expand Up @@ -367,10 +364,8 @@ def data_update(self):
self.log(LoggerType.DATA_UPDATE, "Device data: \n%s", vars(self.api.device))

device: DeviceHandler = self.api.device
# device: WorxCloud = self.api.device

data = {}
old_data = self._attributes

for key, value in ATTR_MAP.items():
if hasattr(device, key):
Expand Down Expand Up @@ -505,6 +500,7 @@ class LandroidCloudMowerBase(LandroidCloudBaseEntity, LawnMowerEntity):
_attr_translation_key = DOMAIN

async def async_added_to_hass(self):
"""Check data and register services when added to hass."""
await super().async_added_to_hass()
logger = LandroidLogger(name=__name__, api=self.api, log_level=LogLevel.DEBUG)
logger.log(
Expand Down Expand Up @@ -618,7 +614,7 @@ async def async_dock(self, **kwargs: Any) -> None:
await asyncio.sleep(1)
if self.state in [STATE_RETURNING, LawnMowerActivity.DOCKED]:
break
if not self.state in [STATE_RETURNING, LawnMowerActivity.DOCKED]:
if self.state not in [STATE_RETURNING, LawnMowerActivity.DOCKED]:
await self.hass.async_add_executor_job(
self.api.cloud.home, device.serial_number
)
Expand Down Expand Up @@ -661,7 +657,7 @@ async def async_set_schedule(self, data: dict | None = None) -> None:
day = day[1]
if day["start"] in data:
# Found day in dataset, generating an update to the schedule
if not day["end"] in data:
if day["end"] not in data:
raise HomeAssistantError(
f"No end time specified for {day['clear']}"
)
Expand Down Expand Up @@ -817,7 +813,7 @@ async def async_config(self, data: dict | None = None) -> None:
raise HomeAssistantError(
"Incorrect format for multizone probabilities array"
)
if not sum(sections) in [100, 0]:
if sum(sections) not in [100, 0]:
raise HomeAssistantError(
"Sum of zone probabilities array MUST be 100"
f"or 0 (disabled), request was: {sum(sections)}"
Expand Down Expand Up @@ -921,7 +917,7 @@ async def handle_update(self) -> None:
try:
self.async_write_ha_state()
except RuntimeError:
pass
contextlib.suppress(RuntimeError)

@property
def current_option(self) -> str | None:
Expand Down Expand Up @@ -1083,7 +1079,6 @@ async def handle_update(self) -> None:
write = True
self._attr_available = self._api.device.online


old_val = self._attr_native_value
old_attrib = self._attr_extra_state_attributes
new_attrib = {}
Expand Down Expand Up @@ -1155,7 +1150,7 @@ async def handle_update(self) -> None:
try:
self.async_write_ha_state()
except RuntimeError:
pass
contextlib.suppress(RuntimeError)


class LandroidNumber(NumberEntity):
Expand Down Expand Up @@ -1238,7 +1233,7 @@ async def handle_update(self) -> None:
try:
self._value = self.entity_description.value_fn(self._api)
except AttributeError:
pass
contextlib.suppress(AttributeError)

_LOGGER.debug(
"(%s, Update signal) Updating number '%s' to '%s'",
Expand All @@ -1249,10 +1244,10 @@ async def handle_update(self) -> None:
try:
self.async_write_ha_state()
except RuntimeError:
pass
contextlib.suppress(RuntimeError)

def set_native_value(self, value: float) -> None:
"""Set number value"""
"""Set number value."""
_LOGGER.debug(
"(%s, Set value) Setting number value for '%s' to %s",
self._api.friendly_name,
Expand Down Expand Up @@ -1335,7 +1330,6 @@ async def handle_update(self) -> None:
if self._attr_available != self._api.device.online:
self._attr_available = self._api.device.online


try:
self._attr_is_on = self.entity_description.value_fn(self._api.device)
except AttributeError:
Expand All @@ -1350,7 +1344,7 @@ async def handle_update(self) -> None:
try:
self.async_write_ha_state()
except RuntimeError:
pass
contextlib.suppress(RuntimeError)

async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on the switch."""
Expand Down Expand Up @@ -1477,4 +1471,4 @@ async def handle_update(self) -> None:
try:
self.async_write_ha_state()
except RuntimeError:
pass
contextlib.suppress(RuntimeError)
6 changes: 0 additions & 6 deletions custom_components/landroid_cloud/devices/ferrex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
from __future__ import annotations

import voluptuous as vol
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
from homeassistant.components.lawn_mower import LawnMowerEntity
from homeassistant.components.select import SelectEntityDescription
from homeassistant.core import HomeAssistant
from pyworxcloud import WorxCloud

from ..api import LandroidAPI
from ..const import (
ATTR_BOUNDARY,
ATTR_MULTIZONE_DISTANCES,
Expand All @@ -21,7 +16,6 @@
LandroidFeatureSupport,
)
from ..device_base import SUPPORT_LANDROID_BASE, LandroidCloudMowerBase
from ..utils.logger import LoggerType

# from homeassistant.helpers.dispatcher import dispatcher_send

Expand Down
6 changes: 0 additions & 6 deletions custom_components/landroid_cloud/devices/kress.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
from __future__ import annotations

import voluptuous as vol
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
from homeassistant.components.lawn_mower import LawnMowerEntity
from homeassistant.components.select import SelectEntityDescription
from homeassistant.core import HomeAssistant
from pyworxcloud import WorxCloud

from ..api import LandroidAPI
from ..const import (
ATTR_BOUNDARY,
ATTR_MULTIZONE_DISTANCES,
Expand All @@ -21,7 +16,6 @@
LandroidFeatureSupport,
)
from ..device_base import SUPPORT_LANDROID_BASE, LandroidCloudMowerBase
from ..utils.logger import LoggerType

# from homeassistant.helpers.dispatcher import dispatcher_send

Expand Down
Loading

0 comments on commit f2a5897

Please sign in to comment.