-
-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for gosund miot plug (cuco.plug.cp1)
this is just a poc to show how the new api could function
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import logging | ||
from dataclasses import dataclass, field | ||
|
||
from .click_common import command, format_output | ||
from .miot_device import MiotDevice | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
@dataclass | ||
class GosundPlugStatus: | ||
_max_properties = 1 | ||
state: bool = field(metadata={"siid": 2, "piid": 1}) | ||
|
||
|
||
class GosundPlug(MiotDevice): | ||
"""Support for gosund miot plug (cuco.plug.cp1).""" | ||
|
||
_MAPPING = GosundPlugStatus | ||
|
||
@command() | ||
def status(self) -> GosundPlugStatus: | ||
"""Return current state of the plug.""" | ||
|
||
return self.get_properties_for_dataclass(GosundPlugStatus) | ||
|
||
@command(default_output=format_output("Powering on")) | ||
def on(self): | ||
"""Power on.""" | ||
return self.set_property(state=True) | ||
|
||
@command(default_output=format_output("Powering off")) | ||
def off(self): | ||
"""Power off.""" | ||
return self.set_property(state=False) |