-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose device types supported by Bond as constants
- Loading branch information
Showing
4 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
|
||
from .bond import Bond | ||
from .action import Action, Direction | ||
from .device_type import DeviceType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Bond Device type enumeration.""" | ||
|
||
|
||
class DeviceType: | ||
"""Bond Device type enumeration.""" | ||
CEILING_FAN = "CF" | ||
MOTORIZED_SHADES = "MS" | ||
FIREPLACE = "FP" | ||
GENERIC_DEVICE = "GX" | ||
|
||
@staticmethod | ||
def is_fan(device_type: str) -> bool: | ||
"""Checks if specified device type is a fan.""" | ||
return device_type == DeviceType.CEILING_FAN | ||
|
||
@staticmethod | ||
def is_shades(device_type: str) -> bool: | ||
"""Checks if specified device type is shades.""" | ||
return device_type == DeviceType.MOTORIZED_SHADES | ||
|
||
@staticmethod | ||
def is_fireplace(device_type: str) -> bool: | ||
"""Checks if specified device type is fireplace.""" | ||
return device_type == DeviceType.FIREPLACE | ||
|
||
@staticmethod | ||
def is_generic(device_type: str) -> bool: | ||
"""Checks if specified device type is generic.""" | ||
return device_type == DeviceType.GENERIC_DEVICE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from bond_api.device_type import DeviceType | ||
|
||
|
||
def test_compare_device_types(): | ||
assert DeviceType.CEILING_FAN == "CF" | ||
assert DeviceType.is_fan("CF") | ||
|
||
assert DeviceType.MOTORIZED_SHADES == "MS" | ||
assert DeviceType.is_shades("MS") | ||
|
||
assert DeviceType.FIREPLACE == "FP" | ||
assert DeviceType.is_fireplace("FP") | ||
|
||
assert DeviceType.GENERIC_DEVICE == "GX" | ||
assert DeviceType.is_generic("GX") |