python-miio icon indicating copy to clipboard operation
python-miio copied to clipboard

Support for the Xiaomi Induction Cooker

Open basveeling opened this issue 5 years ago • 16 comments

This is a first attempt at supporting the Xiaomi Induction Cooker models (#491), which include models chunmi.ihcooker.eg1 chunmi.ihcooker.exp1 chunmi.ihcooker.chefnic chunmi.ihcooker.hk1 chunmi.ihcooker.korea1 chunmi.ihcooker.tw1 chunmi.ihcooker.v1

Turns out the device is a bit more advanced than the app makes it appear. It supports 16-step recipes with each step having specific power, temperature, timer and next-phase settings. This enables building 'smart' recipes for e.g. automated rice cooking, kettle, pressure cooking, etc.

Supported features:

  • [x] Stopping device
  • [x] Starting a profile with and without confirmation
  • [x] Status of cooker including temperature, power/fire output, recipe phase.
  • [x] Saving a recipe to the menu.
  • [x] Making custom recipes with CookProfile.
  • [x] Update recipe settings while running.
  • [x] Factory reset.
  • [x] Interpreting existing recipes.

To do:

  • [x] Build successfully; currently stuck on an issue with poetry/tox AttributeError: type object 'Callable' has no attribute '_abc_registry' <- I could use some advice here :-).
  • [ ] Run some more real-world tests.
  • [ ] Verify with beta testers.
  • [ ] Verify that other models are correctly supported.
  • [ ] Figure out some of the remaining mystery bits & bytes in the recipe and status fields.
  • [ ] Write more tests on integration.
  • [ ] Figure out how to make recipe building accessible (default yaml file that can be passed to CLI?)

Shout-out to @aquarat, @EUA and @hossF for initial analysis and @esgie for the plugin APK 👍

Here's a read-out of a rice-cooker program. image

basveeling avatar Oct 10 '20 16:10 basveeling

Hi basveeling,

thanks for this works.

for Build successfully; currently stuck on an issue with poetry/tox AttributeError: type object 'Callable' has no attribute '_abc_registry' <- I could use some advice here :-) : maybe it's on line 621 of ihcooker.py, change menu to recip_name : "Menu: {result.recipe_name}\n"

in my side build works.

coolibry avatar Jan 31 '21 08:01 coolibry

Any news on this issue?

didjeru avatar Mar 18 '21 10:03 didjeru

I'm willing to test it. It is working on my induction cooker.

guancio avatar Apr 14 '21 20:04 guancio

There is also #1018 (which aims to support only one model listed in your description). I think it would be great if you @basveeling and @sschirr could combine your efforts & knowledge on this topic :-)

rytilahti avatar Apr 14 '21 21:04 rytilahti

There is also #1018 (which aims to support only one model listed in your description). I think it would be great if you @basveeling and @sschirr could combine your efforts & knowledge on this topic :-)

It seems this is a different device class (chunmi.cooker, whereas this PR concerns chunmi.ihcooker) and the multicooker seems closer to the rice cookers in operation.

basveeling avatar Oct 05 '21 17:10 basveeling

@rytilahti Thank you for the review! With a bit of delay on my side, I believe I have made most of the changes requested, outside of moving the bytestring building to Construct. I can take a look at that at a later point, I leave it up to you to decide if that is a blocking issue for this PR. In the mean time I'm happy to address any other issues, looking forward to hearing your thoughts!

basveeling avatar Oct 05 '21 18:10 basveeling

@rytilahti Thank you for the feedback! A couple of changes in this new version.

  • moved the recipe building to Construct (I needed to add two custom Subconstructs for this, perhaps you know a good place to place these in the directory structure?)
  • I went for a parametrised construct for the two versions, I could not get a single construct to work for both versions.
  • Added a JSON recipe conversion option and example recipe.
  • Some extra commands for making simple recipes based on single power and temperature settings.

basveeling avatar Oct 22 '21 13:10 basveeling

Hi @basveeling and thanks for the update!

  • moved the recipe building to Construct (I needed to add two custom Subconstructs for this, perhaps you know a good place to place these in the directory structure?)

Great! Since #1160 we started to move integrations to their own packages, the idea being that contents of that directory do not spill over to other integrations.

This will allow storing all code, auxiliary files and tests inside a single package. So I would suggest creating miio/integrations/ihcooker/ and move everything contained in this PR there, the directory structure could be something like:

  • ihcooker/data/ for the profile files
  • ihcooker/tests/ for the test file(s)
  • ihcooker/ihcooker.py for the main entry point (the Device-derived class)
  • Additional files, so maybe it makes sense to separate the structures into separate file(s) to make the main module cleaner
  • I went for a parametrised construct for the two versions, I could not get a single construct to work for both versions.

Without reading the code yet, that sounds like a good approach :+1: If you don't mind reshuffling the parts prior I do a full review, that would be great!

rytilahti avatar Oct 22 '21 22:10 rytilahti

Hi @rytilahti, thanks for the suggestion. I've refactored the code to use the new dir structure. It's a large PR so I'd understand if it takes some time :-). Looking forward to your review!

basveeling avatar Oct 23 '21 12:10 basveeling

Hi Teemu / @rytilahti,

I hope all is well. I see there's still a change requested status on this PR, but I think I've addressed all the comments. Just wanted to make sure it's clear this is ready for your review whenever you find the time :-).

Enjoy the holiday period!

basveeling avatar Dec 02 '21 17:12 basveeling

Hi! Following this issue since the start. Want to build my brew master with this cooker. Any news on this? 😁

dangenendt avatar Jun 01 '22 19:06 dangenendt

I have chunmi.ihcooker.v2 tried running miiocli cooker --ip blablabla --token blablabla status and got

WARNING:miio.device:Found an unsupported model 'chunmi.ihcooker.v2' for class 'Cooker'. If this is working for you, please open an issue at https://github.com/rytilahti/python-miio/
Error: {'code': -9999, 'message': 'user ack timeout'}

dmatora avatar Oct 13 '22 05:10 dmatora

@syssi where can I read about extracting react plugin from android (or jailbroken iPhone) device?

dmatora avatar Oct 23 '22 20:10 dmatora

what to do to reactivate this?

trackhacs avatar Jan 29 '23 17:01 trackhacs

@basveeling Maybe you will be interested, and it will be great if you can take a look I rewrote this PR in Dart and use it in a cross-platform Flutter app which controls the cooker. Here is the repository: https://github.com/thewh1teagle/MiCook.

thewh1teagle avatar Feb 27 '23 19:02 thewh1teagle