Skip to content

Commit

Permalink
Use call_action_from_mapping for existing miot integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Oct 23, 2023
1 parent b25bf7c commit fba4d2e
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
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")

Check warning on line 526 in miio/integrations/dreame/vacuum/dreamevacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/dreame/vacuum/dreamevacuum_miot.py#L526

Added line #L526 was not covered by tests

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

Check warning on line 531 in miio/integrations/dreame/vacuum/dreamevacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/dreame/vacuum/dreamevacuum_miot.py#L531

Added line #L531 was not covered by tests

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

Check warning on line 536 in miio/integrations/dreame/vacuum/dreamevacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/dreame/vacuum/dreamevacuum_miot.py#L536

Added line #L536 was not covered by tests

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

Check warning on line 541 in miio/integrations/dreame/vacuum/dreamevacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/dreame/vacuum/dreamevacuum_miot.py#L541

Added line #L541 was not covered by tests

@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")

Check warning on line 546 in miio/integrations/dreame/vacuum/dreamevacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/dreame/vacuum/dreamevacuum_miot.py#L546

Added line #L546 was not covered by tests

@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")

Check warning on line 551 in miio/integrations/dreame/vacuum/dreamevacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/dreame/vacuum/dreamevacuum_miot.py#L551

Added line #L551 was not covered by tests

@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")

Check warning on line 556 in miio/integrations/dreame/vacuum/dreamevacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/dreame/vacuum/dreamevacuum_miot.py#L556

Added line #L556 was not covered by tests

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

Check warning on line 561 in miio/integrations/dreame/vacuum/dreamevacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/dreame/vacuum/dreamevacuum_miot.py#L561

Added line #L561 was not covered by tests

@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(

Check warning on line 654 in miio/integrations/dreame/vacuum/dreamevacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/dreame/vacuum/dreamevacuum_miot.py#L654

Added line #L654 was not covered by tests
"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(

Check warning on line 681 in miio/integrations/dreame/vacuum/dreamevacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/dreame/vacuum/dreamevacuum_miot.py#L681

Added line #L681 was not covered by tests
"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)

Check warning on line 734 in miio/integrations/dreame/vacuum/dreamevacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/dreame/vacuum/dreamevacuum_miot.py#L734

Added line #L734 was not covered by tests
if result_status["code"] == 0:
click.echo("Installation complete!")

Expand Down
6 changes: 3 additions & 3 deletions miio/integrations/ijai/vacuum/pro2vacuum.py
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")

Check warning on line 289 in miio/integrations/ijai/vacuum/pro2vacuum.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/ijai/vacuum/pro2vacuum.py#L289

Added line #L289 was not covered by tests

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

Check warning on line 294 in miio/integrations/ijai/vacuum/pro2vacuum.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/ijai/vacuum/pro2vacuum.py#L294

Added line #L294 was not covered by tests

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

Check warning on line 299 in miio/integrations/ijai/vacuum/pro2vacuum.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/ijai/vacuum/pro2vacuum.py#L299

Added line #L299 was not covered by tests

@command(
click.argument("fan_speed", type=EnumType(FanSpeedMode)),
Expand Down
14 changes: 7 additions & 7 deletions miio/integrations/mijia/vacuum/g1vacuum.py
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")

Check warning on line 343 in miio/integrations/mijia/vacuum/g1vacuum.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/mijia/vacuum/g1vacuum.py#L343

Added line #L343 was not covered by tests

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

Check warning on line 348 in miio/integrations/mijia/vacuum/g1vacuum.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/mijia/vacuum/g1vacuum.py#L348

Added line #L348 was not covered by tests

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

Check warning on line 353 in miio/integrations/mijia/vacuum/g1vacuum.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/mijia/vacuum/g1vacuum.py#L353

Added line #L353 was not covered by tests

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

Check warning on line 358 in miio/integrations/mijia/vacuum/g1vacuum.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/mijia/vacuum/g1vacuum.py#L358

Added line #L358 was not covered by tests

@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")

Check warning on line 367 in miio/integrations/mijia/vacuum/g1vacuum.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/mijia/vacuum/g1vacuum.py#L367

Added line #L367 was not covered by tests
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")

Check warning on line 369 in miio/integrations/mijia/vacuum/g1vacuum.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/mijia/vacuum/g1vacuum.py#L369

Added line #L369 was not covered by tests
elif consumable.name == G1Consumable.Filter:
return self.call_action("reset_filter_life_level")
return self.call_action_from_mapping("reset_filter_life_level")

Check warning on line 371 in miio/integrations/mijia/vacuum/g1vacuum.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/mijia/vacuum/g1vacuum.py#L371

Added line #L371 was not covered by tests

@command(
click.argument("fan_speed", type=EnumType(G1FanSpeed)),
Expand Down
8 changes: 4 additions & 4 deletions miio/integrations/mmgg/petwaterdispenser/device.py
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")

Check warning on line 122 in miio/integrations/mmgg/petwaterdispenser/device.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/mmgg/petwaterdispenser/device.py#L122

Added line #L122 was not covered by tests

@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")

Check warning on line 127 in miio/integrations/mmgg/petwaterdispenser/device.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/mmgg/petwaterdispenser/device.py#L127

Added line #L127 was not covered by tests

@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")

Check warning on line 137 in miio/integrations/mmgg/petwaterdispenser/device.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/mmgg/petwaterdispenser/device.py#L137

Added line #L137 was not covered by tests

@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")

Check warning on line 142 in miio/integrations/mmgg/petwaterdispenser/device.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/mmgg/petwaterdispenser/device.py#L142

Added line #L142 was not covered by tests

@command(
click.argument("timezone", type=click.IntRange(-12, 12)),
Expand Down
18 changes: 9 additions & 9 deletions miio/integrations/roidmi/vacuum/roidmivacuum_miot.py
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")

Check warning on line 592 in miio/integrations/roidmi/vacuum/roidmivacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/roidmi/vacuum/roidmivacuum_miot.py#L592

Added line #L592 was not covered by tests

# @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")

Check warning on line 616 in miio/integrations/roidmi/vacuum/roidmivacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/roidmi/vacuum/roidmivacuum_miot.py#L616

Added line #L616 was not covered by tests

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

Check warning on line 621 in miio/integrations/roidmi/vacuum/roidmivacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/roidmi/vacuum/roidmivacuum_miot.py#L621

Added line #L621 was not covered by tests

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

Check warning on line 626 in miio/integrations/roidmi/vacuum/roidmivacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/roidmi/vacuum/roidmivacuum_miot.py#L626

Added line #L626 was not covered by tests

@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")

Check warning on line 760 in miio/integrations/roidmi/vacuum/roidmivacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/roidmi/vacuum/roidmivacuum_miot.py#L760

Added line #L760 was not covered by tests

# @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")

Check warning on line 773 in miio/integrations/roidmi/vacuum/roidmivacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/roidmi/vacuum/roidmivacuum_miot.py#L773

Added line #L773 was not covered by tests

@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")

Check warning on line 778 in miio/integrations/roidmi/vacuum/roidmivacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/roidmi/vacuum/roidmivacuum_miot.py#L778

Added line #L778 was not covered by tests

@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")

Check warning on line 783 in miio/integrations/roidmi/vacuum/roidmivacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/roidmi/vacuum/roidmivacuum_miot.py#L783

Added line #L783 was not covered by tests

@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")

Check warning on line 788 in miio/integrations/roidmi/vacuum/roidmivacuum_miot.py

View check run for this annotation

Codecov / codecov/patch

miio/integrations/roidmi/vacuum/roidmivacuum_miot.py#L788

Added line #L788 was not covered by tests

0 comments on commit fba4d2e

Please sign in to comment.