Skip to content
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

Fix payload of all dmaker.airfresh.t2017 toggles #854

Merged
merged 3 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions miio/airfresh_t2017.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@ def status(self) -> AirFreshStatus:
@command(default_output=format_output("Powering on"))
def on(self):
"""Power on."""
return self.send("set_power", ["on"])
return self.send("set_power", [True])

@command(default_output=format_output("Powering off"))
def off(self):
"""Power off."""
return self.send("set_power", ["off"])
return self.send("set_power", [False])

@command(
click.argument("mode", type=EnumType(OperationMode)),
Expand All @@ -306,10 +306,7 @@ def set_mode(self, mode: OperationMode):
)
def set_display(self, display: bool):
"""Turn led on/off."""
if display:
return self.send("set_display", ["on"])
else:
return self.send("set_display", ["off"])
return self.send("set_display", [display])

@command(
click.argument("orientation", type=EnumType(DisplayOrientation)),
Expand Down Expand Up @@ -345,10 +342,7 @@ def set_ptc_level(self, level: PtcLevel):
)
def set_buzzer(self, buzzer: bool):
"""Set sound on/off."""
if buzzer:
return self.send("set_sound", ["on"])
else:
return self.send("set_sound", ["off"])
return self.send("set_sound", [buzzer])

@command(
click.argument("lock", type=bool),
Expand All @@ -358,10 +352,7 @@ def set_buzzer(self, buzzer: bool):
)
def set_child_lock(self, lock: bool):
"""Set child lock on/off."""
if lock:
return self.send("set_child_lock", ["on"])
else:
return self.send("set_child_lock", ["off"])
return self.send("set_child_lock", [lock])

@command(default_output=format_output("Resetting upper filter"))
def reset_upper_filter(self):
Expand Down
8 changes: 4 additions & 4 deletions miio/tests/test_airfresh_t2017.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def __init__(self, *args, **kwargs):
}
self.return_values = {
"get_prop": self._get_state,
"set_power": lambda x: self._set_state("power", [(x[0] == "on")]),
"set_power": lambda x: self._set_state("power", x),
"set_mode": lambda x: self._set_state("mode", x),
"set_sound": lambda x: self._set_state("sound", [(x[0] == "on")]),
"set_child_lock": lambda x: self._set_state("child_lock", [(x[0] == "on")]),
"set_display": lambda x: self._set_state("display", [(x[0] == "on")]),
"set_sound": lambda x: self._set_state("sound", x),
"set_child_lock": lambda x: self._set_state("child_lock", x),
"set_display": lambda x: self._set_state("display", x),
"set_screen_direction": lambda x: self._set_state("screen_direction", x),
"set_ptc_level": lambda x: self._set_state("ptc_level", x),
"set_ptc_on": lambda x: self._set_state("ptc_on", x),
Expand Down