Add support for fan direction in bond integration (#37789)

* Add support for fan direction in bond integration

* Add support for fan direction (PR feedback)
This commit is contained in:
Eugene Prystupa 2020-07-12 16:30:24 -04:00 committed by GitHub
parent 53844488d8
commit e9440c49d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 98 additions and 9 deletions

View file

@ -2,7 +2,7 @@
from typing import List, Optional
from bond import Bond
from bond import Actions, Bond
class BondDevice:
@ -23,10 +23,24 @@ class BondDevice:
"""Get the type of this device."""
return self._attrs["type"]
def supports_command(self, command: str) -> bool:
"""Return True if this device supports specified command."""
def supports_speed(self) -> bool:
"""Return True if this device supports any of the speed related commands."""
actions: List[str] = self._attrs["actions"]
return command in actions
return len([action for action in actions if action in [Actions.SET_SPEED]]) > 0
def supports_direction(self) -> bool:
"""Return True if this device supports any of the direction related commands."""
actions: List[str] = self._attrs["actions"]
return (
len(
[
action
for action in actions
if action in [Actions.SET_DIRECTION, Actions.TOGGLE_DIRECTION]
]
)
> 0
)
class BondHub: