Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions aiolyric/objects/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,29 @@ class SettingsSpecialMode(LyricBaseObject):
"""Special mode."""


class SettingsFanChangeableValues(LyricBaseObject):
"""Fan changeable values."""

@property
def mode(self):
"""Return the fan mode."""
return self.attributes.get("mode", None)


class SettingsFan(LyricBaseObject):
"""Fan settings."""

@property
def allowed_modes(self):
"""Return the allowed fan modes."""
return self.attributes.get("allowedModes", [])

@property
def changeable_values(self):
"""Return the fan changeable values."""
return SettingsFanChangeableValues(self.attributes.get("changeableValues", {}))


class Settings(LyricBaseObject):
"""Settings."""

Expand All @@ -89,6 +112,11 @@ def hardware_settings(self):
"""Return hardware settings."""
return SettingsHardwareSettings(self.attributes.get("hardwareSettings", {}))

@property
def fan(self):
"""Return fan settings."""
return SettingsFan(self.attributes.get("fan", {}))

@property
def temperature_mode(self):
"""Return temperature mode."""
Expand Down
8 changes: 8 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"allowedTimeIncrements": 10,
"settings": {
"hardwareSettings": {"brightness": 5, "maxBrightness": 5},
"fan": {
"allowedModes": ["On", "Auto", "Circulate"],
"changeableValues": {"mode": "Auto"},
},
"temperatureMode": {"air": True},
"specialMode": {},
"devicePairingEnabled": True,
Expand Down Expand Up @@ -85,6 +89,10 @@
"allowedTimeIncrements": 10,
"settings": {
"hardwareSettings": {"brightness": 5, "maxBrightness": 5},
"fan": {
"allowedModes": ["On", "Auto", "Circulate"],
"changeableValues": {"mode": "Auto"},
},
"temperatureMode": {"air": True},
"specialMode": {},
"devicePairingEnabled": True,
Expand Down
8 changes: 8 additions & 0 deletions tests/objects/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ def test_device(
obj.settings.hardware_settings.max_brightness
== device_fixture_response["settings"]["hardwareSettings"]["maxBrightness"]
)
assert (
obj.settings.fan.allowed_modes
== device_fixture_response["settings"]["fan"]["allowedModes"]
)
assert (
obj.settings.fan.changeable_values.mode
== device_fixture_response["settings"]["fan"]["changeableValues"]["mode"]
)
assert (
obj.settings.temperature_mode.air
== device_fixture_response["settings"]["temperatureMode"]["air"]
Expand Down
10 changes: 10 additions & 0 deletions tests/objects/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ def test_location(
"maxBrightness"
]
)
assert (
obj.devices[0].settings.fan.allowed_modes
== location_fixture_response["devices"][0]["settings"]["fan"]["allowedModes"]
)
assert (
obj.devices[0].settings.fan.changeable_values.mode
== location_fixture_response["devices"][0]["settings"]["fan"][
"changeableValues"
]["mode"]
)
assert (
obj.devices[0].settings.temperature_mode.air
== location_fixture_response["devices"][0]["settings"]["temperatureMode"]["air"]
Expand Down