Skip to content

Commit

Permalink
Initial support for 360 Vis Nav devices
Browse files Browse the repository at this point in the history
  • Loading branch information
dotvezz committed Apr 1, 2024
1 parent 1985911 commit 76675ea
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 4 deletions.
9 changes: 7 additions & 2 deletions custom_components/dyson_local/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .vendor.libdyson import (
Dyson360Eye,
Dyson360Heurist,
Dyson360VisNav,
DysonPureHotCool,
DysonPureHotCoolLink,
DysonPurifierHumidifyCool,
Expand Down Expand Up @@ -113,7 +114,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
entry.data[CONF_DEVICE_TYPE],
)

if not isinstance(device, Dyson360Eye) and not isinstance(device, Dyson360Heurist):
if (not isinstance(device, Dyson360Eye)
and not isinstance(device, Dyson360Heurist)
and not isinstance(device, Dyson360VisNav)):
# Set up coordinator
async def async_update_data():
"""Poll environmental data from the device."""
Expand Down Expand Up @@ -203,7 +206,9 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

@callback
def _async_get_platforms(device: DysonDevice) -> List[str]:
if isinstance(device, Dyson360Eye) or isinstance(device, Dyson360Heurist):
if (isinstance(device, Dyson360Eye)
or isinstance(device, Dyson360Heurist)
or isinstance(device, Dyson360VisNav)):
return ["binary_sensor", "sensor", "vacuum"]
platforms = ["fan", "select", "sensor", "switch"]
if isinstance(device, DysonPureHotCool):
Expand Down
40 changes: 39 additions & 1 deletion custom_components/dyson_local/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

from typing import Callable

from .vendor.libdyson import Dyson360Eye, Dyson360Heurist, DysonPureHotCoolLink
from .vendor.libdyson import (
Dyson360Eye,
Dyson360Heurist,
Dyson360VisNav,
DysonPureHotCoolLink,
)

from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
Expand All @@ -29,6 +34,13 @@ async def async_setup_entry(
if isinstance(device, Dyson360Eye):
entities.append(DysonVacuumBatteryChargingSensor(device, name))
if isinstance(device, Dyson360Heurist):
entities.extend(
[
DysonVacuumBatteryChargingSensor(device, name),
g(device, name),
]
)
if isinstance(device, Dyson360VisNav):
entities.extend(
[
DysonVacuumBatteryChargingSensor(device, name),
Expand Down Expand Up @@ -92,6 +104,32 @@ def sub_unique_id(self):
return "bin_full"


class Dyson360VisNavBinFullSensor(DysonEntity, BinarySensorEntity):
"""Dyson 360 VisNav bin full sensor."""

_attr_entity_category = EntityCategory.DIAGNOSTIC

@property
def is_on(self) -> bool:
"""Return if the sensor is on."""
return self._device.is_bin_full

@property
def icon(self) -> str:
"""Return the sensor icon."""
return ICON_BIN_FULL

@property
def sub_name(self) -> str:
"""Return the name of the sensor."""
return "Bin Full"

@property
def sub_unique_id(self):
"""Return the sensor's unique id."""
return "bin_full"


class DysonPureHotCoolLinkTiltSensor(DysonEntity, BinarySensorEntity):
"""Dyson Pure Hot+Cool Link tilt sensor."""

Expand Down
3 changes: 2 additions & 1 deletion custom_components/dyson_local/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .vendor.libdyson import (
Dyson360Eye,
Dyson360Heurist,
Dyson360VisNav,
DysonDevice,
DysonPureCoolLink,
DysonPurifierHumidifyCool,
Expand Down Expand Up @@ -44,7 +45,7 @@ async def async_setup_entry(
"""Set up Dyson sensor from a config entry."""
device = hass.data[DOMAIN][DATA_DEVICES][config_entry.entry_id]
name = config_entry.data[CONF_NAME]
if isinstance(device, Dyson360Eye) or isinstance(device, Dyson360Heurist):
if isinstance(device, Dyson360Eye) or isinstance(device, Dyson360Heurist) or isinstance(device, Dyson360VisNav):
entities = [DysonBatterySensor(device, name)]
else:
coordinator = hass.data[DOMAIN][DATA_COORDINATORS][config_entry.entry_id]
Expand Down
4 changes: 4 additions & 0 deletions custom_components/dyson_local/vendor/libdyson/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .const import (
DEVICE_TYPE_360_EYE,
DEVICE_TYPE_360_HEURIST,
DEVICE_TYPE_360_VIS_NAV,
DEVICE_TYPE_PURE_COOL,
DEVICE_TYPE_PURIFIER_COOL_E,
DEVICE_TYPE_PURIFIER_COOL_K,
Expand Down Expand Up @@ -32,6 +33,7 @@
from .discovery import DysonDiscovery # noqa: F401
from .dyson_360_eye import Dyson360Eye
from .dyson_360_heurist import Dyson360Heurist
from .dyson_360_vis_nav import Dyson360VisNav
from .dyson_device import DysonDevice
from .dyson_pure_cool import DysonPureCool
from .dyson_pure_cool_link import DysonPureCoolLink
Expand All @@ -48,6 +50,8 @@ def get_device(serial: str, credential: str, device_type: str) -> Optional[Dyson
return Dyson360Eye(serial, credential)
if device_type == DEVICE_TYPE_360_HEURIST:
return Dyson360Heurist(serial, credential)
if device_type == DEVICE_TYPE_360_VIS_NAV:
return Dyson360VisNav(serial, credential)
if device_type in [
DEVICE_TYPE_PURE_COOL_LINK_DESK,
DEVICE_TYPE_PURE_COOL_LINK,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

FILE_PATH = pathlib.Path(__file__).parent.absolute()


class HTTPBearerAuth(AuthBase):
"""Attaches HTTP Bearder Authentication to the given Request object."""

Expand Down
1 change: 1 addition & 0 deletions custom_components/dyson_local/vendor/libdyson/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

DEVICE_TYPE_360_EYE = "N223"
DEVICE_TYPE_360_HEURIST = "276"
DEVICE_TYPE_360_VIS_NAV = "277"
DEVICE_TYPE_PURE_COOL_LINK_DESK = "469" # DP01? DP02? This one's a bit older, and scraping the Dyson website is unclear
DEVICE_TYPE_PURE_COOL_DESK = "520" # AM06? This one's also a bit older, and also hard to scrape off the Dyson website
DEVICE_TYPE_PURE_COOL_LINK = "475" # TP02
Expand Down
13 changes: 13 additions & 0 deletions custom_components/dyson_local/vendor/libdyson/dyson_360_vis_nav.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Dyson 360 Vis Nav vacuum robot."""

from .const import DEVICE_TYPE_360_VIS_NAV
from .dyson_360_heurist import Dyson360Heurist


class Dyson360VisNav(Dyson360Heurist):
"""Dyson 360 Vis Nav device."""

@property
def device_type(self) -> str:
"""Return the device type."""
return DEVICE_TYPE_360_VIS_NAV

0 comments on commit 76675ea

Please sign in to comment.