Skip to content

Commit

Permalink
Use call_action_from_mapping for existing miot integrations (#1855)
Browse files Browse the repository at this point in the history
Fixes regression caused by introduction of the common device API (#1845)
  • Loading branch information
rytilahti authored Oct 23, 2023
1 parent b25bf7c commit 4e2c5ee
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
22 changes: 11 additions & 11 deletions miio/integrations/dreame/vacuum/dreamevacuum_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,42 +523,42 @@ def status(self) -> DreameVacuumStatus:
@command()
def start(self) -> None:
"""Start cleaning."""
return self.call_action("start_clean")
return self.call_action_from_mapping("start_clean")

@command()
def stop(self) -> None:
"""Stop cleaning."""
return self.call_action("stop_clean")
return self.call_action_from_mapping("stop_clean")

@command()
def home(self) -> None:
"""Return to home."""
return self.call_action("home")
return self.call_action_from_mapping("home")

@command()
def identify(self) -> None:
"""Locate the device (i am here)."""
return self.call_action("locate")
return self.call_action_from_mapping("locate")

@command()
def reset_mainbrush_life(self) -> None:
"""Reset main brush life."""
return self.call_action("reset_mainbrush_life")
return self.call_action_from_mapping("reset_mainbrush_life")

@command()
def reset_filter_life(self) -> None:
"""Reset filter life."""
return self.call_action("reset_filter_life")
return self.call_action_from_mapping("reset_filter_life")

@command()
def reset_sidebrush_life(self) -> None:
"""Reset side brush life."""
return self.call_action("reset_sidebrush_life")
return self.call_action_from_mapping("reset_sidebrush_life")

@command()
def play_sound(self) -> None:
"""Play sound."""
return self.call_action("play_sound")
return self.call_action_from_mapping("play_sound")

@command()
def fan_speed(self):
Expand Down Expand Up @@ -651,7 +651,7 @@ def forward(self, distance: int) -> None:
"Given distance is invalid, should be [%s, %s], was: %s"
% (self.MANUAL_DISTANCE_MIN, self.MANUAL_DISTANCE_MAX, distance)
)
self.call_action(
self.call_action_from_mapping(
"move",
[
{
Expand All @@ -678,7 +678,7 @@ def rotate(self, rotatation: int) -> None:
"Given rotation is invalid, should be [%s, %s], was %s"
% (self.MANUAL_ROTATION_MIN, self.MANUAL_ROTATION_MAX, rotatation)
)
self.call_action(
self.call_action_from_mapping(
"move",
[
{
Expand Down Expand Up @@ -731,7 +731,7 @@ def set_voice(self, url: str, md5sum: str, size: int, voice_id: str):
{"piid": 5, "value": md5sum},
{"piid": 6, "value": size},
]
result_status = self.call_action("set_voice", params=params)
result_status = self.call_action_from_mapping("set_voice", params=params)
if result_status["code"] == 0:
click.echo("Installation complete!")

Expand Down
6 changes: 3 additions & 3 deletions miio/integrations/ijai/vacuum/pro2vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,17 @@ def status(self) -> Pro2Status:
@command()
def home(self):
"""Go Home."""
return self.call_action("home")
return self.call_action_from_mapping("home")

@command()
def start(self) -> None:
"""Start Cleaning."""
return self.call_action("start")
return self.call_action_from_mapping("start")

@command()
def stop(self):
"""Stop Cleaning."""
return self.call_action("stop")
return self.call_action_from_mapping("stop")

@command(
click.argument("fan_speed", type=EnumType(FanSpeedMode)),
Expand Down
14 changes: 7 additions & 7 deletions miio/integrations/mijia/vacuum/g1vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,22 +340,22 @@ def cleaning_summary(self) -> G1CleaningSummary:
@command()
def home(self):
"""Home."""
return self.call_action("home")
return self.call_action_from_mapping("home")

@command()
def start(self) -> None:
"""Start Cleaning."""
return self.call_action("start")
return self.call_action_from_mapping("start")

@command()
def stop(self):
"""Stop Cleaning."""
return self.call_action("stop")
return self.call_action_from_mapping("stop")

@command()
def find(self) -> None:
"""Find the robot."""
return self.call_action("find")
return self.call_action_from_mapping("find")

@command(click.argument("consumable", type=G1Consumable))
def consumable_reset(self, consumable: G1Consumable):
Expand All @@ -364,11 +364,11 @@ def consumable_reset(self, consumable: G1Consumable):
CONSUMABLE=main_brush_life_level|side_brush_life_level|filter_life_level
"""
if consumable.name == G1Consumable.MainBrush:
return self.call_action("reset_main_brush_life_level")
return self.call_action_from_mapping("reset_main_brush_life_level")
elif consumable.name == G1Consumable.SideBrush:
return self.call_action("reset_side_brush_life_level")
return self.call_action_from_mapping("reset_side_brush_life_level")
elif consumable.name == G1Consumable.Filter:
return self.call_action("reset_filter_life_level")
return self.call_action_from_mapping("reset_filter_life_level")

@command(
click.argument("fan_speed", type=EnumType(G1FanSpeed)),
Expand Down
8 changes: 4 additions & 4 deletions miio/integrations/mmgg/petwaterdispenser/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ def set_mode(self, mode: OperatingMode) -> List[Dict[str, Any]]:
@command(default_output=format_output("Resetting sponge filter"))
def reset_sponge_filter(self) -> Dict[str, Any]:
"""Reset sponge filter."""
return self.call_action("reset_filter_life")
return self.call_action_from_mapping("reset_filter_life")

@command(default_output=format_output("Resetting cotton filter"))
def reset_cotton_filter(self) -> Dict[str, Any]:
"""Reset cotton filter."""
return self.call_action("reset_cotton_life")
return self.call_action_from_mapping("reset_cotton_life")

@command(default_output=format_output("Resetting all filters"))
def reset_all_filters(self) -> List[Dict[str, Any]]:
Expand All @@ -134,12 +134,12 @@ def reset_all_filters(self) -> List[Dict[str, Any]]:
@command(default_output=format_output("Resetting cleaning time"))
def reset_cleaning_time(self) -> Dict[str, Any]:
"""Reset cleaning time counter."""
return self.call_action("reset_clean_time")
return self.call_action_from_mapping("reset_clean_time")

@command(default_output=format_output("Resetting device"))
def reset(self) -> Dict[str, Any]:
"""Reset device."""
return self.call_action("reset_device")
return self.call_action_from_mapping("reset_device")

@command(
click.argument("timezone", type=click.IntRange(-12, 12)),
Expand Down
18 changes: 9 additions & 9 deletions miio/integrations/roidmi/vacuum/roidmivacuum_miot.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def cleaning_summary(self) -> RoidmiCleaningSummary:
@command()
def start(self) -> None:
"""Start cleaning."""
return self.call_action("start")
return self.call_action_from_mapping("start")

# @command(click.argument("roomstr", type=str, required=False))
# def start_room_sweep_unknown(self, roomstr: str=None) -> None:
Expand All @@ -613,17 +613,17 @@ def start(self) -> None:
@command()
def stop(self) -> None:
"""Stop cleaning."""
return self.call_action("stop")
return self.call_action_from_mapping("stop")

@command()
def home(self) -> None:
"""Return to home."""
return self.call_action("home")
return self.call_action_from_mapping("home")

@command()
def identify(self) -> None:
"""Locate the device (i am here)."""
return self.call_action("identify")
return self.call_action_from_mapping("identify")

@command(click.argument("on", type=bool))
def set_station_led(self, on: bool):
Expand Down Expand Up @@ -757,7 +757,7 @@ def set_lidar_collision_sensor(self, lidar_collision: bool):
@command()
def start_dust(self) -> None:
"""Start base dust collection."""
return self.call_action("start_station_dust_collection")
return self.call_action_from_mapping("start_station_dust_collection")

# @command(click.argument("voice", type=str))
# def set_voice_unknown(self, voice: str) -> None:
Expand All @@ -770,19 +770,19 @@ def start_dust(self) -> None:
@command()
def reset_filter_life(self) -> None:
"""Reset filter life."""
return self.call_action("reset_filter_life")
return self.call_action_from_mapping("reset_filter_life")

@command()
def reset_mainbrush_life(self) -> None:
"""Reset main brush life."""
return self.call_action("reset_main_brush_life")
return self.call_action_from_mapping("reset_main_brush_life")

@command()
def reset_sidebrush_life(self) -> None:
"""Reset side brushes life."""
return self.call_action("reset_side_brushes_life")
return self.call_action_from_mapping("reset_side_brushes_life")

@command()
def reset_sensor_dirty_life(self) -> None:
"""Reset sensor dirty life."""
return self.call_action("reset_sensor_dirty_life")
return self.call_action_from_mapping("reset_sensor_dirty_life")

0 comments on commit 4e2c5ee

Please sign in to comment.