mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Update laundrify_aio to v1.2.2 (#121068)
* refactor: upgrade laundrify_aio to v1.2.1 * refactor: update laundrify_aio to v1.2.2
This commit is contained in:
parent
83fac6192d
commit
276f6c7ee7
@ -4,6 +4,8 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from laundrify_aio import LaundrifyDevice
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
@ -14,9 +16,8 @@ from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN, MANUFACTURER, MODEL
|
||||
from .const import DOMAIN, MANUFACTURER, MODELS
|
||||
from .coordinator import LaundrifyUpdateCoordinator
|
||||
from .model import LaundrifyDevice
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -52,14 +53,15 @@ class LaundrifyPowerPlug(
|
||||
"""Pass coordinator to CoordinatorEntity."""
|
||||
super().__init__(coordinator)
|
||||
self._device = device
|
||||
unique_id = device["_id"]
|
||||
unique_id = device.id
|
||||
self._attr_unique_id = unique_id
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, unique_id)},
|
||||
name=device["name"],
|
||||
name=device.name,
|
||||
manufacturer=MANUFACTURER,
|
||||
model=MODEL,
|
||||
sw_version=device["firmwareVersion"],
|
||||
model=MODELS[device.model],
|
||||
sw_version=device.firmwareVersion,
|
||||
configuration_url=f"http://{device.internalIP}",
|
||||
)
|
||||
|
||||
@property
|
||||
@ -73,7 +75,7 @@ class LaundrifyPowerPlug(
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return entity state."""
|
||||
return self._device["status"] == "ON"
|
||||
return bool(self._device.status == "ON")
|
||||
|
||||
@callback
|
||||
def _handle_coordinator_update(self) -> None:
|
||||
|
@ -3,7 +3,7 @@
|
||||
DOMAIN = "laundrify"
|
||||
|
||||
MANUFACTURER = "laundrify"
|
||||
MODEL = "WLAN-Adapter (SU02)"
|
||||
MODELS = {"SU02": "WLAN-Adapter classic", "M01": "WLAN-Adapter mini"}
|
||||
|
||||
DEFAULT_POLL_INTERVAL = 60
|
||||
|
||||
|
@ -4,7 +4,7 @@ import asyncio
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from laundrify_aio import LaundrifyAPI
|
||||
from laundrify_aio import LaundrifyAPI, LaundrifyDevice
|
||||
from laundrify_aio.exceptions import ApiConnectionException, UnauthorizedException
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -12,7 +12,6 @@ from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
from .const import DOMAIN, REQUEST_TIMEOUT
|
||||
from .model import LaundrifyDevice
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -38,7 +37,7 @@ class LaundrifyUpdateCoordinator(DataUpdateCoordinator[dict[str, LaundrifyDevice
|
||||
# Note: TimeoutError and aiohttp.ClientError are already
|
||||
# handled by the data update coordinator.
|
||||
async with asyncio.timeout(REQUEST_TIMEOUT):
|
||||
return {m["_id"]: m for m in await self.laundrify_api.get_machines()}
|
||||
return {m.id: m for m in await self.laundrify_api.get_machines()}
|
||||
except UnauthorizedException as err:
|
||||
# Raising ConfigEntryAuthFailed will cancel future updates
|
||||
# and start a config flow with SOURCE_REAUTH (async_step_reauth)
|
||||
|
@ -5,5 +5,5 @@
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/laundrify",
|
||||
"iot_class": "cloud_polling",
|
||||
"requirements": ["laundrify-aio==1.1.2"]
|
||||
"requirements": ["laundrify-aio==1.2.2"]
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
"""Models for laundrify platform."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TypedDict
|
||||
|
||||
|
||||
class LaundrifyDevice(TypedDict):
|
||||
"""laundrify Power Plug."""
|
||||
|
||||
_id: str
|
||||
name: str
|
||||
status: str
|
||||
firmwareVersion: str
|
@ -1224,7 +1224,7 @@ lacrosse-view==1.0.1
|
||||
lakeside==0.13
|
||||
|
||||
# homeassistant.components.laundrify
|
||||
laundrify-aio==1.1.2
|
||||
laundrify-aio==1.2.2
|
||||
|
||||
# homeassistant.components.ld2410_ble
|
||||
ld2410-ble==0.1.1
|
||||
|
@ -999,7 +999,7 @@ krakenex==2.1.0
|
||||
lacrosse-view==1.0.1
|
||||
|
||||
# homeassistant.components.laundrify
|
||||
laundrify-aio==1.1.2
|
||||
laundrify-aio==1.2.2
|
||||
|
||||
# homeassistant.components.ld2410_ble
|
||||
ld2410-ble==0.1.1
|
||||
|
@ -3,6 +3,7 @@
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
from laundrify_aio import LaundrifyAPI, LaundrifyDevice
|
||||
import pytest
|
||||
|
||||
from .const import VALID_ACCESS_TOKEN, VALID_ACCOUNT_ID
|
||||
@ -49,7 +50,10 @@ def laundrify_api_fixture(laundrify_exchange_code, laundrify_validate_token):
|
||||
),
|
||||
patch(
|
||||
"laundrify_aio.LaundrifyAPI.get_machines",
|
||||
return_value=json.loads(load_fixture("laundrify/machines.json")),
|
||||
return_value=[
|
||||
LaundrifyDevice(machine, LaundrifyAPI)
|
||||
for machine in json.loads(load_fixture("laundrify/machines.json"))
|
||||
],
|
||||
) as get_machines_mock,
|
||||
):
|
||||
yield get_machines_mock
|
||||
|
@ -1,8 +1,10 @@
|
||||
[
|
||||
{
|
||||
"_id": "14",
|
||||
"id": "14",
|
||||
"name": "Demo Waschmaschine",
|
||||
"status": "OFF",
|
||||
"internalIP": "192.168.0.123",
|
||||
"model": "SU02",
|
||||
"firmwareVersion": "2.1.0"
|
||||
}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user