Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
Vendoring libdyson to avoid conflicts and other dependency install er…
Browse files Browse the repository at this point in the history
…rors (#9)
  • Loading branch information
dotvezz authored Jun 8, 2023
1 parent fc0693e commit 065b0f2
Show file tree
Hide file tree
Showing 25 changed files with 1,923 additions and 20 deletions.
14 changes: 7 additions & 7 deletions custom_components/dyson_cloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
from functools import partial

from homeassistant.exceptions import ConfigEntryNotReady
from libdyson.cloud.account import DysonAccountCN
from libdyson.cloud.device_info import DysonDeviceInfo
from libdyson.const import DEVICE_TYPE_360_EYE
from libdyson.discovery import DysonDiscovery
from libdyson.dyson_device import DysonDevice
from libdyson.exceptions import DysonException, DysonNetworkError
from .vendor.libdyson.cloud.account import DysonAccountCN
from .vendor.libdyson.cloud.device_info import DysonDeviceInfo
from .vendor.libdyson.const import DEVICE_TYPE_360_EYE
from .vendor.libdyson.discovery import DysonDiscovery
from .vendor.libdyson.dyson_device import DysonDevice
from .vendor.libdyson.exceptions import DysonException, DysonNetworkError
from homeassistant.config_entries import ConfigEntry, SOURCE_DISCOVERY
from homeassistant.const import CONF_HOST, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import Entity
from homeassistant.components.zeroconf import async_get_instance
from libdyson.cloud import DysonAccount
from .vendor.libdyson.cloud import DysonAccount
from custom_components.dyson_local import DOMAIN as DYSON_LOCAL_DOMAIN

from .const import CONF_AUTH, CONF_REGION, DATA_ACCOUNT, DATA_DEVICES, DOMAIN
Expand Down
6 changes: 3 additions & 3 deletions custom_components/dyson_cloud/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from homeassistant.core import HomeAssistant
from homeassistant.config_entries import ConfigEntry
from homeassistant.components.camera import Camera
from libdyson.const import DEVICE_TYPE_360_EYE, DEVICE_TYPE_360_HEURIST
from libdyson.cloud.cloud_360_eye import DysonCloud360Eye
from libdyson.cloud import DysonDeviceInfo
from .vendor.libdyson.const import DEVICE_TYPE_360_EYE, DEVICE_TYPE_360_HEURIST
from .vendor.libdyson.cloud.cloud_360_eye import DysonCloud360Eye
from .vendor.libdyson.cloud import DysonDeviceInfo
from datetime import timedelta

from .const import DATA_ACCOUNT, DATA_DEVICES, DOMAIN
Expand Down
12 changes: 6 additions & 6 deletions custom_components/dyson_cloud/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from homeassistant import config_entries
from homeassistant.components.zeroconf import async_get_instance
from homeassistant.const import CONF_EMAIL, CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from libdyson.cloud.account import DysonAccountCN
from .vendor.libdyson.cloud.account import DysonAccountCN
import voluptuous as vol
from libdyson.cloud import DysonAccount, REGIONS
from libdyson.dyson_360_eye import Dyson360Eye
from libdyson.discovery import DysonDiscovery
from libdyson.const import DEVICE_TYPE_360_EYE
from libdyson.exceptions import DysonException, DysonLoginFailure, DysonInvalidAccountStatus, DysonNetworkError, DysonOTPTooFrequently
from .vendor.libdyson.cloud import DysonAccount, REGIONS
from .vendor.libdyson.dyson_360_eye import Dyson360Eye
from .vendor.libdyson.discovery import DysonDiscovery
from .vendor.libdyson.const import DEVICE_TYPE_360_EYE
from .vendor.libdyson.exceptions import DysonException, DysonLoginFailure, DysonInvalidAccountStatus, DysonNetworkError, DysonOTPTooFrequently
from voluptuous.schema_builder import Required

from .const import CONF_AUTH, CONF_REGION, DOMAIN
Expand Down
8 changes: 4 additions & 4 deletions custom_components/dyson_cloud/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"domain": "dyson_cloud",
"name": "Dyson Cloud",
"config_flow": true,
"documentation": "https://github.com/libdyson-wg/ha-dyson",
"issue_tracker": "https://github.com/libdyson-wg/ha-dyson/issues",
"documentation": "https://github.com/libdyson-wg/ha-dyson-cloud",
"issue_tracker": "https://github.com/libdyson-wg/ha-dyson-cloud/issues",
"dependencies": [],
"codeowners": ["@libdyson-wg"],
"requirements": ["libdyson-neon==1.0.2"],
"version": "0.18.0"
"requirements": [],
"version": "0.19.0"
}
75 changes: 75 additions & 0 deletions custom_components/dyson_cloud/vendor/libdyson/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""Dyson Python library."""

from typing import Optional
from .const import (
DEVICE_TYPE_360_EYE,
DEVICE_TYPE_360_HEURIST,
DEVICE_TYPE_PURE_COOL,
DEVICE_TYPE_PURIFIER_COOL_E,
DEVICE_TYPE_PURIFIER_COOL_K,
DEVICE_TYPE_PURE_COOL_DESK,
DEVICE_TYPE_PURE_COOL_LINK,
DEVICE_TYPE_PURE_COOL_LINK_DESK,
DEVICE_TYPE_PURE_HOT_COOL,
DEVICE_TYPE_PURIFIER_HOT_COOL_E,
DEVICE_TYPE_PURIFIER_HOT_COOL_K,
DEVICE_TYPE_PURE_HOT_COOL_LINK,
DEVICE_TYPE_PURE_HUMIDIFY_COOL,
DEVICE_TYPE_PURIFIER_HUMIDIFY_COOL_E,
DEVICE_TYPE_PURIFIER_HUMIDIFY_COOL_K,
)

from .const import CleaningMode # noqa: F401
from .const import CleaningType # noqa: F401
from .const import DEVICE_TYPE_NAMES # noqa: F401
from .const import HumidifyOscillationMode # noqa: F401
from .const import MessageType # noqa: F401
from .const import VacuumEyePowerMode # noqa: F401
from .const import VacuumHeuristPowerMode # noqa: F401
from .const import VacuumState # noqa: F401
from .const import WaterHardness # noqa: F401
from .discovery import DysonDiscovery # noqa: F401
from .dyson_360_eye import Dyson360Eye
from .dyson_360_heurist import Dyson360Heurist
from .dyson_device import DysonDevice
from .dyson_pure_cool import DysonPureCool
from .dyson_pure_cool_link import DysonPureCoolLink
from .dyson_pure_hot_cool import DysonPureHotCool
from .dyson_pure_hot_cool_link import DysonPureHotCoolLink
from .dyson_pure_humidify_cool import DysonPurifierHumidifyCool
from .utils import get_mqtt_info_from_wifi_info # noqa: F401


def get_device(serial: str, credential: str, device_type: str) -> Optional[DysonDevice]:
"""Get a new DysonDevice instance."""
if device_type == DEVICE_TYPE_360_EYE:
return Dyson360Eye(serial, credential)
if device_type == DEVICE_TYPE_360_HEURIST:
return Dyson360Heurist(serial, credential)
if device_type in [
DEVICE_TYPE_PURE_COOL_LINK_DESK,
DEVICE_TYPE_PURE_COOL_LINK,
]:
return DysonPureCoolLink(serial, credential, device_type)
if device_type in [
DEVICE_TYPE_PURE_COOL,
DEVICE_TYPE_PURIFIER_COOL_K,
DEVICE_TYPE_PURIFIER_COOL_E,
DEVICE_TYPE_PURE_COOL_DESK,
]:
return DysonPureCool(serial, credential, device_type)
if device_type == DEVICE_TYPE_PURE_HOT_COOL_LINK:
return DysonPureHotCoolLink(serial, credential, device_type)
if device_type in [
DEVICE_TYPE_PURE_HOT_COOL,
DEVICE_TYPE_PURIFIER_HOT_COOL_E,
DEVICE_TYPE_PURIFIER_HOT_COOL_K,
]:
return DysonPureHotCool(serial, credential, device_type)
if device_type in [
DEVICE_TYPE_PURE_HUMIDIFY_COOL,
DEVICE_TYPE_PURIFIER_HUMIDIFY_COOL_K,
DEVICE_TYPE_PURIFIER_HUMIDIFY_COOL_E,
]:
return DysonPurifierHumidifyCool(serial, credential, device_type)
return None
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Dyson cloud client."""

from .account import DysonAccount, DysonAccountCN # noqa: F401
from .cloud_360_eye import DysonCloud360Eye # noqa: F401
from .cloud_device import DysonCloudDevice # noqa: F401
from .device_info import DysonDeviceInfo # noqa: F401
from .regions import REGIONS # noqa: F401
Loading

0 comments on commit 065b0f2

Please sign in to comment.