-
-
Notifications
You must be signed in to change notification settings - Fork 570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support dreame.vacuum.ma1808 and dreame.vacuum.mb1808 #1774
Open
st7105
wants to merge
21
commits into
rytilahti:master
Choose a base branch
from
st7105:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8f087c5
Add support dreame.vacuum.ma1808 and dreame.vacuum.mb1808
st7105 27b9e54
Add support "water_flow" field for DREAME_1C*
st7105 c945636
Fix parse properties fields without 'value'
st7105 6bfc111
Fix black formatted
st7105 b2077c1
vacuum: fix _get_cleaning_mode_enum_class
st7105 d527098
Fix black formatted
st7105 65a3783
vacuum: add check value to set_volume
st7105 98d6d90
Add support dreame.vacuum.ma1808 and dreame.vacuum.mb1808
st7105 700bf51
Add support "water_flow" field for DREAME_1C*
st7105 6cdca19
Fix parse properties fields without 'value'
st7105 2765045
Fix black formatted
st7105 0ea677d
vacuum: fix _get_cleaning_mode_enum_class
st7105 8697301
Fix black formatted
st7105 9e38478
vacuum: add check value to set_volume
st7105 2ba0b51
Merge branch 'rytilahti:master' into master
st7105 081a911
heater: add support leshow.heater.nfj3lx
st7105 0801956
Revert "Support pydantic v2 using v1 shims (#1816)"
st7105 eba666d
Merge branch 'service'
st7105 05bbb6f
heater: change to enum buzzer and sway
st7105 cabbc2e
add support cuco.plug.v2eur
st7105 9b00afd
fix version
st7105 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Empty file.
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,3 @@ | ||
from .cuco_plug import CucoPlugMiot | ||
|
||
__all__ = ["CucoPlugMiot"] |
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,94 @@ | ||
import enum | ||
import logging | ||
from typing import Any, Dict | ||
|
||
from miio import DeviceStatus, MiotDevice | ||
from miio.click_common import command, format_output | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
_MAPPINGS = { | ||
"cuco.plug.v2eur": { | ||
# Source https://home.miot-spec.com/spec?type=urn:miot-spec-v2:device:outlet:0000A002:cuco-v2eur:1 | ||
"power": {"siid": 2, "piid": 1}, | ||
"fault": {"siid": 2, "piid": 3}, | ||
"power_consumption": {"siid": 11, "piid": 1}, | ||
"electric_power": {"siid": 11, "piid": 2}, | ||
"indicator_light": {"siid": 13, "piid": 1} | ||
} | ||
} | ||
|
||
|
||
class DeviceFault(enum.Enum): | ||
NoFaults = 0 | ||
OverTemperature = 1 | ||
Overload = 2 | ||
|
||
|
||
class CucoPlugMiotStatus(DeviceStatus): | ||
|
||
def __init__(self, data: Dict[str, Any], model: str) -> None: | ||
self.data = data | ||
self.model = model | ||
|
||
@property | ||
def power(self) -> str: | ||
"""Power state.""" | ||
return "on" if self.is_on else "off" | ||
|
||
@property | ||
def is_on(self) -> bool: | ||
"""True if device is currently on.""" | ||
return self.data["power"] | ||
|
||
@property | ||
def power_consumption(self) -> float: | ||
"""True if device is currently on.""" | ||
return self.data["power_consumption"] | ||
|
||
@property | ||
def electric_power(self) -> int: | ||
"""True if device is currently on.""" | ||
return self.data["electric_power"] | ||
|
||
@property | ||
def indicator_light(self) -> bool: | ||
"""True if device is currently on.""" | ||
return self.data["indicator_light"] | ||
|
||
@property | ||
def fault(self) -> DeviceFault: | ||
value = self.data["fault"] | ||
return DeviceFault(value) | ||
|
||
|
||
class CucoPlugMiot(MiotDevice): | ||
|
||
_mappings = _MAPPINGS | ||
|
||
@command( | ||
default_output=format_output( | ||
"", | ||
"Power: {result.power}\n" | ||
"Power consumption: {result.power_consumption}\n" | ||
"Electric power: {result.electric_power} watt\n" | ||
"LED indicator: {result.indicator_light}\n" | ||
) | ||
) | ||
def status(self) -> CucoPlugMiotStatus: | ||
return CucoPlugMiotStatus( | ||
{ | ||
prop["did"]: prop["value"] if prop["code"] == 0 else None | ||
for prop in self.get_properties_for_mapping() | ||
}, | ||
self.model, | ||
) | ||
|
||
@command(default_output=format_output("Powering on")) | ||
def on(self): | ||
"""Power on.""" | ||
return self.set_property("power", True) | ||
|
||
@command(default_output=format_output("Powering off")) | ||
def off(self): | ||
"""Power off.""" | ||
return self.set_property("power", False) |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are irrelevant changes, right?