Skip to content

Commit 4e2c5ee

Browse files
authored
Use call_action_from_mapping for existing miot integrations (#1855)
Fixes regression caused by introduction of the common device API (#1845)
1 parent b25bf7c commit 4e2c5ee

File tree

5 files changed

+34
-34
lines changed

5 files changed

+34
-34
lines changed

miio/integrations/dreame/vacuum/dreamevacuum_miot.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -523,42 +523,42 @@ def status(self) -> DreameVacuumStatus:
523523
@command()
524524
def start(self) -> None:
525525
"""Start cleaning."""
526-
return self.call_action("start_clean")
526+
return self.call_action_from_mapping("start_clean")
527527

528528
@command()
529529
def stop(self) -> None:
530530
"""Stop cleaning."""
531-
return self.call_action("stop_clean")
531+
return self.call_action_from_mapping("stop_clean")
532532

533533
@command()
534534
def home(self) -> None:
535535
"""Return to home."""
536-
return self.call_action("home")
536+
return self.call_action_from_mapping("home")
537537

538538
@command()
539539
def identify(self) -> None:
540540
"""Locate the device (i am here)."""
541-
return self.call_action("locate")
541+
return self.call_action_from_mapping("locate")
542542

543543
@command()
544544
def reset_mainbrush_life(self) -> None:
545545
"""Reset main brush life."""
546-
return self.call_action("reset_mainbrush_life")
546+
return self.call_action_from_mapping("reset_mainbrush_life")
547547

548548
@command()
549549
def reset_filter_life(self) -> None:
550550
"""Reset filter life."""
551-
return self.call_action("reset_filter_life")
551+
return self.call_action_from_mapping("reset_filter_life")
552552

553553
@command()
554554
def reset_sidebrush_life(self) -> None:
555555
"""Reset side brush life."""
556-
return self.call_action("reset_sidebrush_life")
556+
return self.call_action_from_mapping("reset_sidebrush_life")
557557

558558
@command()
559559
def play_sound(self) -> None:
560560
"""Play sound."""
561-
return self.call_action("play_sound")
561+
return self.call_action_from_mapping("play_sound")
562562

563563
@command()
564564
def fan_speed(self):
@@ -651,7 +651,7 @@ def forward(self, distance: int) -> None:
651651
"Given distance is invalid, should be [%s, %s], was: %s"
652652
% (self.MANUAL_DISTANCE_MIN, self.MANUAL_DISTANCE_MAX, distance)
653653
)
654-
self.call_action(
654+
self.call_action_from_mapping(
655655
"move",
656656
[
657657
{
@@ -678,7 +678,7 @@ def rotate(self, rotatation: int) -> None:
678678
"Given rotation is invalid, should be [%s, %s], was %s"
679679
% (self.MANUAL_ROTATION_MIN, self.MANUAL_ROTATION_MAX, rotatation)
680680
)
681-
self.call_action(
681+
self.call_action_from_mapping(
682682
"move",
683683
[
684684
{
@@ -731,7 +731,7 @@ def set_voice(self, url: str, md5sum: str, size: int, voice_id: str):
731731
{"piid": 5, "value": md5sum},
732732
{"piid": 6, "value": size},
733733
]
734-
result_status = self.call_action("set_voice", params=params)
734+
result_status = self.call_action_from_mapping("set_voice", params=params)
735735
if result_status["code"] == 0:
736736
click.echo("Installation complete!")
737737

miio/integrations/ijai/vacuum/pro2vacuum.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,17 +286,17 @@ def status(self) -> Pro2Status:
286286
@command()
287287
def home(self):
288288
"""Go Home."""
289-
return self.call_action("home")
289+
return self.call_action_from_mapping("home")
290290

291291
@command()
292292
def start(self) -> None:
293293
"""Start Cleaning."""
294-
return self.call_action("start")
294+
return self.call_action_from_mapping("start")
295295

296296
@command()
297297
def stop(self):
298298
"""Stop Cleaning."""
299-
return self.call_action("stop")
299+
return self.call_action_from_mapping("stop")
300300

301301
@command(
302302
click.argument("fan_speed", type=EnumType(FanSpeedMode)),

miio/integrations/mijia/vacuum/g1vacuum.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,22 +340,22 @@ def cleaning_summary(self) -> G1CleaningSummary:
340340
@command()
341341
def home(self):
342342
"""Home."""
343-
return self.call_action("home")
343+
return self.call_action_from_mapping("home")
344344

345345
@command()
346346
def start(self) -> None:
347347
"""Start Cleaning."""
348-
return self.call_action("start")
348+
return self.call_action_from_mapping("start")
349349

350350
@command()
351351
def stop(self):
352352
"""Stop Cleaning."""
353-
return self.call_action("stop")
353+
return self.call_action_from_mapping("stop")
354354

355355
@command()
356356
def find(self) -> None:
357357
"""Find the robot."""
358-
return self.call_action("find")
358+
return self.call_action_from_mapping("find")
359359

360360
@command(click.argument("consumable", type=G1Consumable))
361361
def consumable_reset(self, consumable: G1Consumable):
@@ -364,11 +364,11 @@ def consumable_reset(self, consumable: G1Consumable):
364364
CONSUMABLE=main_brush_life_level|side_brush_life_level|filter_life_level
365365
"""
366366
if consumable.name == G1Consumable.MainBrush:
367-
return self.call_action("reset_main_brush_life_level")
367+
return self.call_action_from_mapping("reset_main_brush_life_level")
368368
elif consumable.name == G1Consumable.SideBrush:
369-
return self.call_action("reset_side_brush_life_level")
369+
return self.call_action_from_mapping("reset_side_brush_life_level")
370370
elif consumable.name == G1Consumable.Filter:
371-
return self.call_action("reset_filter_life_level")
371+
return self.call_action_from_mapping("reset_filter_life_level")
372372

373373
@command(
374374
click.argument("fan_speed", type=EnumType(G1FanSpeed)),

miio/integrations/mmgg/petwaterdispenser/device.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ def set_mode(self, mode: OperatingMode) -> List[Dict[str, Any]]:
119119
@command(default_output=format_output("Resetting sponge filter"))
120120
def reset_sponge_filter(self) -> Dict[str, Any]:
121121
"""Reset sponge filter."""
122-
return self.call_action("reset_filter_life")
122+
return self.call_action_from_mapping("reset_filter_life")
123123

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

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

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

144144
@command(
145145
click.argument("timezone", type=click.IntRange(-12, 12)),

miio/integrations/roidmi/vacuum/roidmivacuum_miot.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ def cleaning_summary(self) -> RoidmiCleaningSummary:
589589
@command()
590590
def start(self) -> None:
591591
"""Start cleaning."""
592-
return self.call_action("start")
592+
return self.call_action_from_mapping("start")
593593

594594
# @command(click.argument("roomstr", type=str, required=False))
595595
# def start_room_sweep_unknown(self, roomstr: str=None) -> None:
@@ -613,17 +613,17 @@ def start(self) -> None:
613613
@command()
614614
def stop(self) -> None:
615615
"""Stop cleaning."""
616-
return self.call_action("stop")
616+
return self.call_action_from_mapping("stop")
617617

618618
@command()
619619
def home(self) -> None:
620620
"""Return to home."""
621-
return self.call_action("home")
621+
return self.call_action_from_mapping("home")
622622

623623
@command()
624624
def identify(self) -> None:
625625
"""Locate the device (i am here)."""
626-
return self.call_action("identify")
626+
return self.call_action_from_mapping("identify")
627627

628628
@command(click.argument("on", type=bool))
629629
def set_station_led(self, on: bool):
@@ -757,7 +757,7 @@ def set_lidar_collision_sensor(self, lidar_collision: bool):
757757
@command()
758758
def start_dust(self) -> None:
759759
"""Start base dust collection."""
760-
return self.call_action("start_station_dust_collection")
760+
return self.call_action_from_mapping("start_station_dust_collection")
761761

762762
# @command(click.argument("voice", type=str))
763763
# def set_voice_unknown(self, voice: str) -> None:
@@ -770,19 +770,19 @@ def start_dust(self) -> None:
770770
@command()
771771
def reset_filter_life(self) -> None:
772772
"""Reset filter life."""
773-
return self.call_action("reset_filter_life")
773+
return self.call_action_from_mapping("reset_filter_life")
774774

775775
@command()
776776
def reset_mainbrush_life(self) -> None:
777777
"""Reset main brush life."""
778-
return self.call_action("reset_main_brush_life")
778+
return self.call_action_from_mapping("reset_main_brush_life")
779779

780780
@command()
781781
def reset_sidebrush_life(self) -> None:
782782
"""Reset side brushes life."""
783-
return self.call_action("reset_side_brushes_life")
783+
return self.call_action_from_mapping("reset_side_brushes_life")
784784

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

0 commit comments

Comments
 (0)