-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d299ea
commit 223d7b4
Showing
18 changed files
with
229 additions
and
56 deletions.
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
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
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
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 |
---|---|---|
@@ -1,46 +1,47 @@ | ||
from HABApp.core.const.hints import HasNameAttr as _HasNameAttr | ||
from HABApp.openhab.definitions import OnOffValue, UpDownValue | ||
from HABApp.openhab.interface_sync import send_command | ||
|
||
|
||
class OnOffCommand: | ||
|
||
def is_on(self) -> bool: | ||
def is_on(self: _HasNameAttr) -> bool: | ||
"""Test value against on-value""" | ||
raise NotImplementedError() | ||
|
||
def is_off(self) -> bool: | ||
def is_off(self: _HasNameAttr) -> bool: | ||
"""Test value against off-value""" | ||
raise NotImplementedError() | ||
|
||
def on(self): | ||
def on(self: _HasNameAttr): | ||
"""Command item on""" | ||
send_command(self, OnOffValue.ON) | ||
send_command(self.name, OnOffValue.ON) | ||
|
||
def off(self): | ||
def off(self: _HasNameAttr): | ||
"""Command item off""" | ||
send_command(self, OnOffValue.OFF) | ||
send_command(self.name, OnOffValue.OFF) | ||
|
||
|
||
class PercentCommand: | ||
def percent(self, value: float): | ||
def percent(self: _HasNameAttr, value: float): | ||
"""Command to value (in percent)""" | ||
assert 0 <= value <= 100, value | ||
send_command(self, str(value)) | ||
send_command(self.name, str(value)) | ||
|
||
|
||
class UpDownCommand: | ||
def up(self): | ||
def up(self: _HasNameAttr): | ||
"""Command up""" | ||
send_command(self, UpDownValue.UP) | ||
send_command(self.name, UpDownValue.UP) | ||
|
||
def down(self): | ||
def down(self: _HasNameAttr): | ||
"""Command down""" | ||
send_command(self, UpDownValue.DOWN) | ||
send_command(self.name, UpDownValue.DOWN) | ||
|
||
def is_up(self) -> bool: | ||
def is_up(self: _HasNameAttr) -> bool: | ||
"""Test value against on-value""" | ||
raise NotImplementedError() | ||
|
||
def is_down(self) -> bool: | ||
def is_down(self: _HasNameAttr) -> bool: | ||
"""Test value against off-value""" | ||
raise NotImplementedError() |
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
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
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
Oops, something went wrong.