kettle-x2p-cli 1.2.0__tar.gz → 1.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/CHANGELOG.md +10 -0
  2. {kettle_x2p_cli-1.2.0/src/kettle_x2p_cli.egg-info → kettle_x2p_cli-1.3.0}/PKG-INFO +5 -5
  3. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/README.md +4 -4
  4. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/src/kettle/__init__.py +1 -1
  5. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/src/kettle/cli.py +13 -6
  6. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0/src/kettle_x2p_cli.egg-info}/PKG-INFO +5 -5
  7. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/tests/test_cli.py +23 -2
  8. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/LICENSE +0 -0
  9. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/MANIFEST.in +0 -0
  10. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/SPEC.md +0 -0
  11. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/pyproject.toml +0 -0
  12. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/setup.cfg +0 -0
  13. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/src/kettle/__main__.py +0 -0
  14. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/src/kettle/aes.py +0 -0
  15. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/src/kettle/config.py +0 -0
  16. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/src/kettle/miio.py +0 -0
  17. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/src/kettle/wizard.py +0 -0
  18. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/src/kettle_x2p_cli.egg-info/SOURCES.txt +0 -0
  19. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/src/kettle_x2p_cli.egg-info/dependency_links.txt +0 -0
  20. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/src/kettle_x2p_cli.egg-info/entry_points.txt +0 -0
  21. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/src/kettle_x2p_cli.egg-info/top_level.txt +0 -0
  22. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/tests/helpers.py +0 -0
  23. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/tests/test_aes.py +0 -0
  24. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/tests/test_miio.py +0 -0
  25. {kettle_x2p_cli-1.2.0 → kettle_x2p_cli-1.3.0}/tests/test_wizard.py +0 -0
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.3.0] - 2026-10-21
11
+ ### Added
12
+ - `-y` as a short form of `--yes`.
13
+
14
+ ### Changed
15
+ - The fault is shown as `OK (0)` or `something wrong (N)` in `status`, in the line printed after `boil`/`warm`
16
+ and in the refusal to heat.
17
+ - `status` shows the target mode with its name and code, like the state: `heating (0)`, `boiling (1)`,
18
+ `preset 1 (10)` to `preset 6 (15)`, and `unknown (N)` for any other code.
19
+
10
20
  ## [1.2.0] - 2026-10-20
11
21
  ### Changed
12
22
  - **Breaking:** `--yes`, `--dry-run`, `--timeout` and `--debug` now go after the command, like `--keep`
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kettle-x2p-cli
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: Local control of the Xiaomi Smart Kettle 2 Pro over your Wi-Fi, no cloud at runtime.
5
5
  Author-email: Ilia Petrov-Komotskii <ilia@inkedkettle.art>
6
6
  License-Expression: MIT
@@ -31,7 +31,7 @@ About to send set_properties:
31
31
  (2,4) = 80
32
32
  ...
33
33
  Start heating? [y/N] y
34
- status: heating, 41 C, fault 0
34
+ status: heating, 41 C, fault OK (0)
35
35
  ```
36
36
 
37
37
  Written for the EU model (BHR9107EU, `xiaomi.kettle.v20`, 1.7 L, 1800 W), tested on firmware `2.2.7_0016`.
@@ -71,7 +71,7 @@ Go after the command, e.g. `kettle warm 70 --dry-run`. `kettle <command> --help`
71
71
  | Option | What it does |
72
72
  |---|---|
73
73
  | `--keep [[<40-99>] <1-24>]` (`-k`) | For `boil` and `warm`: after heating, keep the water warm at that temperature for that many hours (fractions like `1.5` work). Both parts are optional: the temperature defaults to the heating target (99 °C for `boil`), the time to 1 hour, and a single value is the time. |
74
- | `--yes` | For `boil`, `warm` and `shell`: skip the heating confirmation. |
74
+ | `--yes` (`-y`) | For `boil`, `warm` and `shell`: skip the heating confirmation. |
75
75
  | `--dry-run` | For `boil`, `warm`, `cancel`, `shell` and `provision`: print the requests, send nothing. |
76
76
  | `--timeout <seconds>` | Seconds to wait for a reply from the kettle (default: 3). |
77
77
  | `--debug` | Print the raw packets and requests. |
@@ -183,8 +183,8 @@ else is rejected before it is sent.
183
183
  (the kettle silently ignores requests it cannot decrypt). Run `kettle setup` again if you re-paired it.
184
184
  - **Setup does not find the kettle**: your computer and the kettle must be on the same network (no guest network
185
185
  or VLAN between them). You can enter the IP by hand; it is in your router's client list.
186
- - **"kettle reports fault ..."**: check the water level and that the kettle sits on its base. Fault codes are not
187
- documented by Xiaomi; `0` means none.
186
+ - **"kettle fault: something wrong (N)"**: check the water level and that the kettle sits on its base. Fault codes are
187
+ not documented by Xiaomi; `OK (0)` means none.
188
188
 
189
189
  ---
190
190
 
@@ -11,7 +11,7 @@ About to send set_properties:
11
11
  (2,4) = 80
12
12
  ...
13
13
  Start heating? [y/N] y
14
- status: heating, 41 C, fault 0
14
+ status: heating, 41 C, fault OK (0)
15
15
  ```
16
16
 
17
17
  Written for the EU model (BHR9107EU, `xiaomi.kettle.v20`, 1.7 L, 1800 W), tested on firmware `2.2.7_0016`.
@@ -51,7 +51,7 @@ Go after the command, e.g. `kettle warm 70 --dry-run`. `kettle <command> --help`
51
51
  | Option | What it does |
52
52
  |---|---|
53
53
  | `--keep [[<40-99>] <1-24>]` (`-k`) | For `boil` and `warm`: after heating, keep the water warm at that temperature for that many hours (fractions like `1.5` work). Both parts are optional: the temperature defaults to the heating target (99 °C for `boil`), the time to 1 hour, and a single value is the time. |
54
- | `--yes` | For `boil`, `warm` and `shell`: skip the heating confirmation. |
54
+ | `--yes` (`-y`) | For `boil`, `warm` and `shell`: skip the heating confirmation. |
55
55
  | `--dry-run` | For `boil`, `warm`, `cancel`, `shell` and `provision`: print the requests, send nothing. |
56
56
  | `--timeout <seconds>` | Seconds to wait for a reply from the kettle (default: 3). |
57
57
  | `--debug` | Print the raw packets and requests. |
@@ -163,8 +163,8 @@ else is rejected before it is sent.
163
163
  (the kettle silently ignores requests it cannot decrypt). Run `kettle setup` again if you re-paired it.
164
164
  - **Setup does not find the kettle**: your computer and the kettle must be on the same network (no guest network
165
165
  or VLAN between them). You can enter the IP by hand; it is in your router's client list.
166
- - **"kettle reports fault ..."**: check the water level and that the kettle sits on its base. Fault codes are not
167
- documented by Xiaomi; `0` means none.
166
+ - **"kettle fault: something wrong (N)"**: check the water level and that the kettle sits on its base. Fault codes are
167
+ not documented by Xiaomi; `OK (0)` means none.
168
168
 
169
169
  ---
170
170
 
@@ -1,3 +1,3 @@
1
1
  """Local control of the Xiaomi Smart Kettle 2 Pro over the LAN."""
2
2
 
3
- version = "1.2.0"
3
+ version = "1.3.0"
@@ -19,6 +19,13 @@ STATUS, FAULT, TEMP, TARGET, AUTO_KEEP, KEEP_TEMP, ON = (2, 1), (2, 2), (2, 3),
19
19
  KEEP_MIN, LIFTED, WARMING, TARGET_MODE, HEAT_MODE, BOIL_MODE = (3, 1), (3, 7), (3, 10), (3, 11), (3, 12), (3, 13)
20
20
  STOP_ACTION = (3, 1)
21
21
  STATUS_NAMES = {0: "idle", 1: "heating", 2: "boiling", 3: "cooling down", 4: "keep warm"}
22
+ TARGET_MODE_NAMES = {0: "heating", 1: "boiling", **{n: f"preset {n - 9}" for n in range(10, 16)}}
23
+ # the spec has no fault list; only 0 is known. Add the low-water code here once it is confirmed on the device.
24
+ FAULT_NAMES = {0: "OK"}
25
+
26
+
27
+ def fault_text(code: int) -> str:
28
+ return f"{FAULT_NAMES.get(code, 'something wrong')} ({code})"
22
29
 
23
30
 
24
31
  class KettleError(Exception):
@@ -116,12 +123,12 @@ def cmd_status(args):
116
123
  with c:
117
124
  v = read_props(c, [STATUS, FAULT, TEMP, TARGET, AUTO_KEEP, KEEP_TEMP, KEEP_MIN, LIFTED, WARMING, TARGET_MODE])
118
125
  print(f"status : {STATUS_NAMES.get(v[STATUS], v[STATUS])} ({v[STATUS]})")
119
- print(f"fault : {v[FAULT]}")
126
+ print(f"fault : {fault_text(v[FAULT])}")
120
127
  print(f"temperature : {v[TEMP]} C")
121
128
  print(f"target : {v[TARGET]} C")
122
129
  print(f"keep warm : {'on' if v[AUTO_KEEP] else 'off'} at {v[KEEP_TEMP]} C for {v[KEEP_MIN]} min")
123
130
  print(f"warming time : {v[WARMING]} min")
124
- print(f"target mode : {v[TARGET_MODE]}")
131
+ print(f"target mode : {TARGET_MODE_NAMES.get(v[TARGET_MODE], 'unknown')} ({v[TARGET_MODE]})")
125
132
  print(f"lifted : {v[LIFTED]}")
126
133
  print("water level : not exposed by this model (a low-water fault shows up in `fault`)")
127
134
 
@@ -185,7 +192,7 @@ def start_heating(args, build, label: str) -> None:
185
192
  check_model(c, cfg, args)
186
193
  v = read_props(c, [STATUS, FAULT, TEMP, LIFTED, KEEP_TEMP, KEEP_MIN])
187
194
  if v[FAULT] != 0:
188
- die(f"kettle reports fault {v[FAULT]} (possibly low water); not heating")
195
+ die(f"kettle fault: {fault_text(v[FAULT])}; not heating")
189
196
  if v[LIFTED]:
190
197
  die("kettle is lifted off its base; not heating")
191
198
  if v[STATUS] != 0:
@@ -205,7 +212,7 @@ def start_heating(args, build, label: str) -> None:
205
212
  print("accepted. waiting 3 s then reading status...")
206
213
  time.sleep(3)
207
214
  v = read_props(c, [STATUS, FAULT, TEMP])
208
- print(f"status: {STATUS_NAMES.get(v[STATUS], v[STATUS])}, {v[TEMP]} C, fault {v[FAULT]}")
215
+ print(f"status: {STATUS_NAMES.get(v[STATUS], v[STATUS])}, {v[TEMP]} C, fault {fault_text(v[FAULT])}")
209
216
  if v[STATUS] == 0:
210
217
  print("kettle is still idle: the batch alone did not start it. Re-run with --set-on "
211
218
  "(also writes on=true) once you are watching the kettle.")
@@ -359,7 +366,7 @@ def cmd_shell(args):
359
366
  break
360
367
  if line in ("help", "?"):
361
368
  print("boil [-k [[TEMP] TIME]] | warm <40-99> [-k [[TEMP] TIME]] | cancel | stop | status | info")
362
- print("options go after the command: --yes skips the heating confirmation, --dry-run only prints the RPC")
369
+ print("options go after the command: -y/--yes skips the heating confirmation, --dry-run only prints the RPC")
363
370
  continue
364
371
  try:
365
372
  tokens = shlex.split(line)
@@ -397,7 +404,7 @@ DEFAULT_TIMEOUT = 3.0
397
404
  # options that go after the command: name -> (option strings, usage example, add_argument kwargs)
398
405
  COMMAND_OPTIONS = {
399
406
  "keep": (("-k", "--keep"), "boil --keep", dict(nargs="*", type=float, help=KEEP_HELP)),
400
- "yes": (("--yes",), "boil --yes", dict(action="store_true", help="skip heating confirmation")),
407
+ "yes": (("-y", "--yes"), "boil --yes", dict(action="store_true", help="skip heating confirmation")),
401
408
  "dry_run": (("--dry-run",), "warm 70 --dry-run",
402
409
  dict(action="store_true", help="print the RPC instead of sending")),
403
410
  "timeout": (("--timeout",), "status --timeout 5",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kettle-x2p-cli
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: Local control of the Xiaomi Smart Kettle 2 Pro over your Wi-Fi, no cloud at runtime.
5
5
  Author-email: Ilia Petrov-Komotskii <ilia@inkedkettle.art>
6
6
  License-Expression: MIT
@@ -31,7 +31,7 @@ About to send set_properties:
31
31
  (2,4) = 80
32
32
  ...
33
33
  Start heating? [y/N] y
34
- status: heating, 41 C, fault 0
34
+ status: heating, 41 C, fault OK (0)
35
35
  ```
36
36
 
37
37
  Written for the EU model (BHR9107EU, `xiaomi.kettle.v20`, 1.7 L, 1800 W), tested on firmware `2.2.7_0016`.
@@ -71,7 +71,7 @@ Go after the command, e.g. `kettle warm 70 --dry-run`. `kettle <command> --help`
71
71
  | Option | What it does |
72
72
  |---|---|
73
73
  | `--keep [[<40-99>] <1-24>]` (`-k`) | For `boil` and `warm`: after heating, keep the water warm at that temperature for that many hours (fractions like `1.5` work). Both parts are optional: the temperature defaults to the heating target (99 °C for `boil`), the time to 1 hour, and a single value is the time. |
74
- | `--yes` | For `boil`, `warm` and `shell`: skip the heating confirmation. |
74
+ | `--yes` (`-y`) | For `boil`, `warm` and `shell`: skip the heating confirmation. |
75
75
  | `--dry-run` | For `boil`, `warm`, `cancel`, `shell` and `provision`: print the requests, send nothing. |
76
76
  | `--timeout <seconds>` | Seconds to wait for a reply from the kettle (default: 3). |
77
77
  | `--debug` | Print the raw packets and requests. |
@@ -183,8 +183,8 @@ else is rejected before it is sent.
183
183
  (the kettle silently ignores requests it cannot decrypt). Run `kettle setup` again if you re-paired it.
184
184
  - **Setup does not find the kettle**: your computer and the kettle must be on the same network (no guest network
185
185
  or VLAN between them). You can enter the IP by hand; it is in your router's client list.
186
- - **"kettle reports fault ..."**: check the water level and that the kettle sits on its base. Fault codes are not
187
- documented by Xiaomi; `0` means none.
186
+ - **"kettle fault: something wrong (N)"**: check the water level and that the kettle sits on its base. Fault codes are
187
+ not documented by Xiaomi; `OK (0)` means none.
188
188
 
189
189
  ---
190
190
 
@@ -73,7 +73,7 @@ class HeatingCommandTests(DeviceCase):
73
73
  positions = [out.index(f"\n {n} ") for n in names]
74
74
  self.assertEqual(positions, sorted(positions))
75
75
  flags = [out.index(f"\n {f}") for f in ("-h, --help", "-v, --version", "--ip", "--token", "--force-model",
76
- "-k, --keep", "--yes", "--dry-run", "--timeout", "--debug")]
76
+ "-k, --keep", "-y, --yes", "--dry-run", "--timeout", "--debug")]
77
77
  self.assertEqual(flags, sorted(flags))
78
78
  self.assertLess(out.index("\ncall options"), out.index("\n --ip"))
79
79
  self.assertLess(out.index("\n --force-model"), out.index("\ncommand options"))
@@ -165,9 +165,30 @@ class HeatingCommandTests(DeviceCase):
165
165
  class ReadCommandTests(DeviceCase):
166
166
  def test_status(self):
167
167
  _, out, _ = self.cli("status")
168
- for text in ("idle", "25 C", "water level"):
168
+ for text in ("idle", "25 C", "water level", "target mode : heating (0)"):
169
169
  self.assertIn(text, out)
170
170
 
171
+ def test_y_is_a_short_form_of_yes(self):
172
+ self.assertEqual(self.cli("boil", "-y")[0], 0)
173
+ self.assertEqual(self.dev.props[(2, 1)], 1) # started heating without a prompt
174
+ self.assertIn("-y, --yes", self.cli("--help")[1])
175
+
176
+ def test_status_words_the_fault(self):
177
+ self.assertIn("fault : OK (0)", self.cli("status")[1])
178
+ self.dev.props[(2, 2)] = 7
179
+ self.assertIn("fault : something wrong (7)", self.cli("status")[1])
180
+ code, _, err = self.cli("boil", "--yes")
181
+ self.assertEqual(code, 1)
182
+ self.assertIn("something wrong (7)", err)
183
+
184
+ def test_status_names_the_target_mode(self):
185
+ for code, text in ((0, "heating (0)"), (1, "boiling (1)"), (10, "preset 1 (10)"),
186
+ (15, "preset 6 (15)"), (5, "unknown (5)"), (16, "unknown (16)")):
187
+ with self.subTest(code=code):
188
+ self.dev.props[(3, 11)] = code
189
+ _, out, _ = self.cli("status")
190
+ self.assertIn(f"target mode : {text}", out)
191
+
171
192
  def test_info_hides_the_token_and_saves_the_config(self):
172
193
  _, out, _ = self.cli("info")
173
194
  self.assertNotIn("ff" * 16, out)
File without changes
File without changes
File without changes