Skip to content

Commit

Permalink
Merge 13c1df5 into a91362c
Browse files Browse the repository at this point in the history
  • Loading branch information
etheralm committed Jul 25, 2018
2 parents a91362c + 13c1df5 commit e1c5e46
Show file tree
Hide file tree
Showing 19 changed files with 1,421 additions and 11 deletions.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -16,6 +16,8 @@ http://libpurecoollink.readthedocs.io

### Supported devices

* Dyson pure cool tower (TP04)
* Dyson pure cool desk (DP04)
* Dyson pure cool link devices (Tower and Desk)
* Dyson pure cool+hot devices
* Dyson 360 Eye robot vacuum
Expand All @@ -35,6 +37,7 @@ The following feature are supported:
* Set Air Quality target (Normal, High, Better)
* Enable/disable standby monitoring (the device continue to update sensors when in standby)
* Reset filter life
* Adjust oscillation angle (TP04/DP04)
* Cool+Hot purifier/fan devices
* Set heat mode
* Set heat target
Expand Down
9 changes: 9 additions & 0 deletions docs/api.rst
Expand Up @@ -6,9 +6,11 @@ Developer Interface
.. module:: libpurecoollink.dyson
.. module:: libpurecoollink.dyson_device
.. module:: libpurecoollink.dyson_360_eye
.. module:: libpurecoollink.dyson_pure_cool
.. module:: libpurecoollink.dyson_pure_cool_link
.. module:: libpurecoollink.dyson_pure_hotcool_link
.. module:: libpurecoollink.dyson_pure_state
.. module:: libpurecoollink.dyson_pure_state_v2

This part of the documentation covers all the interfaces of Libpurecoollink.

Expand All @@ -34,6 +36,13 @@ NetworkDevice
Fan/Purifier devices
~~~~~~~~~~~~~~~~~~~~

DysonPureCool
#################

.. autoclass:: libpurecoollink.dyson_pure_cool.DysonPureCool
:members:
:inherited-members:

DysonPureCoolLink
#################

Expand Down
3 changes: 3 additions & 0 deletions docs/index.rst
Expand Up @@ -27,6 +27,8 @@ Discovery is not fully reliable yet. It's working most of the time but sometimes
Supported devices
~~~~~~~~~~~~~~~~~

- Dyson pure cool tower (TP04)
- Dyson pure cool desk (DP04)
- Dyson pure cool link devices (Tower and Desk)
- Dyson Cool+Hot devices
- Dyson 360 Eye robot vacuum
Expand All @@ -45,6 +47,7 @@ The following commands are supported:
- Turn on/off
- Set speed
- Turn on/off oscillation
- Adjust oscillation angle (TP04/DP04)
- Set Auto mode
- Set night mode
- Set sleep timer
Expand Down
40 changes: 40 additions & 0 deletions libpurecoollink/const.py
Expand Up @@ -7,6 +7,11 @@
DYSON_PURE_COOL_LINK_DESK = "469"
DYSON_PURE_HOT_COOL_LINK_TOUR = "455"
DYSON_360_EYE = "N223"
DYSON_PURE_COOL = "438"
DYSON_PURE_COOL_DESKTOP = "520"

SLEEP_TIMER_OFF = 'OFF'
SENSOR_INIT_STATES = ['INIT', 'OFF']


class FanMode(Enum):
Expand All @@ -24,6 +29,13 @@ class Oscillation(Enum):
OSCILLATION_OFF = 'OFF'


class OscillationV2(Enum):
"""Oscillation."""

OSCILLATION_ON = 'OION'
OSCILLATION_OFF = 'OIOF'


class NightMode(Enum):
"""Night mode."""

Expand Down Expand Up @@ -159,3 +171,31 @@ class Dyson360EyeCommand(Enum):
PAUSE = "PAUSE"
RESUME = "RESUME"
ABORT = "ABORT"


class FanPower(Enum):
"""Fan power."""

POWER_OFF = 'OFF'
POWER_ON = 'ON'


class FrontalDirection(Enum):
"""Frontal Direction."""

FRONTAL_OFF = 'OFF'
FRONTAL_ON = 'ON'


class AutoMode(Enum):
"""Auto Mode."""

AUTO_OFF = 'OFF'
AUTO_ON = 'ON'


class ContinuousMonitoring(Enum):
"""Auto Mode."""

MONITORING_OFF = 'OFF'
MONITORING_ON = 'ON'
19 changes: 18 additions & 1 deletion libpurecoollink/dyson.py
Expand Up @@ -3,9 +3,15 @@
# pylint: disable=too-many-public-methods,too-many-instance-attributes

import logging

import requests
from requests.auth import HTTPBasicAuth
from .utils import is_360_eye_device, is_heating_device

import urllib3

from .dyson_pure_cool import DysonPureCool
from .utils import is_360_eye_device, \
is_heating_device, is_dyson_pure_cool_device

from .dyson_360_eye import Dyson360Eye
from .dyson_pure_cool_link import DysonPureCoolLink
Expand Down Expand Up @@ -35,6 +41,10 @@ def __init__(self, email, password, country):

def login(self):
"""Login to dyson web services."""
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
_LOGGER.debug("Disabling insecure request warnings since "
"dyson are using a self signed certificate.")

request_body = {
"Email": self._email,
"Password": self._password
Expand All @@ -58,6 +68,9 @@ def devices(self):
device_response = requests.get(
"https://{0}/v1/provisioningservice/manifest".format(
DYSON_API_URL), verify=False, auth=self._auth)
device_v2_response = requests.get(
"https://{0}/v2/provisioningservice/manifest".format(
DYSON_API_URL), verify=False, auth=self._auth)
devices = []
for device in device_response.json():
if is_360_eye_device(device):
Expand All @@ -68,6 +81,10 @@ def devices(self):
dyson_device = DysonPureCoolLink(device)
devices.append(dyson_device)

for device_v2 in device_v2_response.json():
if is_dyson_pure_cool_device(device_v2):
devices.append(DysonPureCool(device_v2))

return devices
else:
_LOGGER.warning("Not logged to Dyson Web Services.")
Expand Down
5 changes: 4 additions & 1 deletion libpurecoollink/dyson_device.py
Expand Up @@ -83,7 +83,10 @@ def __init__(self, json_body):
:param json_body: JSON message returned by the HTTPS API
"""
self._active = json_body['Active']
if 'Active' in json_body:
self._active = json_body['Active']
else:
self._active = None
self._serial = json_body['Serial']
self._name = json_body['Name']
self._version = json_body['Version']
Expand Down

0 comments on commit e1c5e46

Please sign in to comment.