pyhon-revived 0.18.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 (53) hide show
  1. pyhon_revived-0.18.0/LICENSE +21 -0
  2. pyhon_revived-0.18.0/MANIFEST.in +1 -0
  3. pyhon_revived-0.18.0/PKG-INFO +149 -0
  4. pyhon_revived-0.18.0/README.md +112 -0
  5. pyhon_revived-0.18.0/pyhon/__init__.py +4 -0
  6. pyhon_revived-0.18.0/pyhon/__main__.py +113 -0
  7. pyhon_revived-0.18.0/pyhon/appliance.py +335 -0
  8. pyhon_revived-0.18.0/pyhon/appliances/__init__.py +0 -0
  9. pyhon_revived-0.18.0/pyhon/appliances/base.py +25 -0
  10. pyhon_revived-0.18.0/pyhon/appliances/dw.py +13 -0
  11. pyhon_revived-0.18.0/pyhon/appliances/ov.py +16 -0
  12. pyhon_revived-0.18.0/pyhon/appliances/ref.py +25 -0
  13. pyhon_revived-0.18.0/pyhon/appliances/td.py +21 -0
  14. pyhon_revived-0.18.0/pyhon/appliances/wc.py +5 -0
  15. pyhon_revived-0.18.0/pyhon/appliances/wd.py +17 -0
  16. pyhon_revived-0.18.0/pyhon/appliances/wh.py +16 -0
  17. pyhon_revived-0.18.0/pyhon/appliances/wm.py +17 -0
  18. pyhon_revived-0.18.0/pyhon/attributes.py +58 -0
  19. pyhon_revived-0.18.0/pyhon/command_loader.py +227 -0
  20. pyhon_revived-0.18.0/pyhon/commands.py +208 -0
  21. pyhon_revived-0.18.0/pyhon/connection/__init__.py +0 -0
  22. pyhon_revived-0.18.0/pyhon/connection/api.py +349 -0
  23. pyhon_revived-0.18.0/pyhon/connection/auth.py +298 -0
  24. pyhon_revived-0.18.0/pyhon/connection/device.py +44 -0
  25. pyhon_revived-0.18.0/pyhon/connection/handler/__init__.py +0 -0
  26. pyhon_revived-0.18.0/pyhon/connection/handler/anonym.py +27 -0
  27. pyhon_revived-0.18.0/pyhon/connection/handler/auth.py +38 -0
  28. pyhon_revived-0.18.0/pyhon/connection/handler/base.py +80 -0
  29. pyhon_revived-0.18.0/pyhon/connection/handler/hon.py +119 -0
  30. pyhon_revived-0.18.0/pyhon/connection/mqtt.py +151 -0
  31. pyhon_revived-0.18.0/pyhon/const.py +16 -0
  32. pyhon_revived-0.18.0/pyhon/diagnose.py +99 -0
  33. pyhon_revived-0.18.0/pyhon/exceptions.py +18 -0
  34. pyhon_revived-0.18.0/pyhon/helper.py +5 -0
  35. pyhon_revived-0.18.0/pyhon/hon.py +133 -0
  36. pyhon_revived-0.18.0/pyhon/parameter/__init__.py +0 -0
  37. pyhon_revived-0.18.0/pyhon/parameter/base.py +98 -0
  38. pyhon_revived-0.18.0/pyhon/parameter/enum.py +51 -0
  39. pyhon_revived-0.18.0/pyhon/parameter/fixed.py +27 -0
  40. pyhon_revived-0.18.0/pyhon/parameter/program.py +56 -0
  41. pyhon_revived-0.18.0/pyhon/parameter/range.py +77 -0
  42. pyhon_revived-0.18.0/pyhon/printer.py +87 -0
  43. pyhon_revived-0.18.0/pyhon/py.typed +0 -0
  44. pyhon_revived-0.18.0/pyhon/rules.py +145 -0
  45. pyhon_revived-0.18.0/pyhon/typedefs.py +26 -0
  46. pyhon_revived-0.18.0/pyhon_revived.egg-info/PKG-INFO +149 -0
  47. pyhon_revived-0.18.0/pyhon_revived.egg-info/SOURCES.txt +51 -0
  48. pyhon_revived-0.18.0/pyhon_revived.egg-info/dependency_links.txt +1 -0
  49. pyhon_revived-0.18.0/pyhon_revived.egg-info/entry_points.txt +2 -0
  50. pyhon_revived-0.18.0/pyhon_revived.egg-info/requires.txt +4 -0
  51. pyhon_revived-0.18.0/pyhon_revived.egg-info/top_level.txt +1 -0
  52. pyhon_revived-0.18.0/setup.cfg +4 -0
  53. pyhon_revived-0.18.0/setup.py +46 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Andre Basche
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ include pyhon/py.typed
@@ -0,0 +1,149 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyhon-revived
3
+ Version: 0.18.0
4
+ Summary: Control hOn devices with python
5
+ Author: Andre Basche, Michał Małolepszy
6
+ License: MIT
7
+ Project-URL: GitHub, https://github.com/mmalolepszy/pyhon-revived
8
+ Project-URL: PyPI, https://pypi.org/project/pyhon-revived
9
+ Platform: any
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: aiohttp>=3.8.6
23
+ Requires-Dist: typing-extensions>=4.8
24
+ Requires-Dist: yarl>=1.8
25
+ Requires-Dist: awsiotsdk>=1.21.0
26
+ Dynamic: author
27
+ Dynamic: classifier
28
+ Dynamic: description
29
+ Dynamic: description-content-type
30
+ Dynamic: license
31
+ Dynamic: license-file
32
+ Dynamic: platform
33
+ Dynamic: project-url
34
+ Dynamic: requires-dist
35
+ Dynamic: requires-python
36
+ Dynamic: summary
37
+
38
+ **This python package is unofficial and is not related in any way to Haier. It was developed by reversed engineered requests and can stop working at anytime!**
39
+
40
+ # pyhOn
41
+ [![PyPI - Status](https://img.shields.io/pypi/status/pyhOn)](https://pypi.org/project/pyhOn)
42
+ [![PyPI](https://img.shields.io/pypi/v/pyhOn?color=blue)](https://pypi.org/project/pyhOn)
43
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyhOn)](https://www.python.org/)
44
+ [![PyPI - License](https://img.shields.io/pypi/l/pyhOn)](https://github.com/Andre0512/pyhOn/blob/main/LICENSE)
45
+ [![PyPI - Downloads](https://img.shields.io/pypi/dm/pyhOn)](https://pypistats.org/packages/pyhon)
46
+ Control your Haier, Candy and Hoover appliances with python!
47
+ The idea behind this library is, to make the use of all available commands as simple as possible.
48
+
49
+ ## Installation
50
+ ```bash
51
+ pip install pyhOn
52
+ ```
53
+
54
+ ### Quick overview
55
+ To get an idea of what is possible, use the commandline-tool `pyhOn`. This command requests all available options of connected appliances from the hOn api of your Haier Account.
56
+ ```commandline
57
+ $ pyhOn --user example@mail.com --password pass123
58
+ ========== WM - Waschmaschine ==========
59
+ data:
60
+ attributes:
61
+ parameters:
62
+ ...
63
+ texture: 1
64
+ totalElectricityUsed: 28.71
65
+ totalWashCycle: 35
66
+ totalWaterUsed: 2494
67
+ transMode: 0
68
+ ...
69
+ settings:
70
+ startProgram:
71
+ rinseIterations:
72
+ max: 5
73
+ min: 3
74
+ step: 1
75
+ spinSpeed:
76
+ - 0
77
+ - 400
78
+ - 600
79
+ - 800
80
+ ...
81
+ ```
82
+
83
+ ## Python-API
84
+ ### List devices
85
+ ```python
86
+ import asyncio
87
+ from pyhon import Hon
88
+
89
+ async def devices_example():
90
+ async with Hon(USER, PASSWORD) as hon:
91
+ for appliance in hon.appliances:
92
+ print(appliance.nick_name)
93
+
94
+ asyncio.run(devices_example())
95
+ ```
96
+
97
+ ### Execute a command
98
+ ```python
99
+ async with Hon(USER, PASSWORD) as hon:
100
+ washing_machine = hon.appliances[0]
101
+ pause_command = washing_machine.commands["pauseProgram"]
102
+ await pause_command.send()
103
+ ```
104
+
105
+ ### Set command parameter
106
+ ```python
107
+ async with Hon(USER, PASSWORD) as hon:
108
+ washing_machine = hon.appliances[0]
109
+ start_command = washing_machine.commands["startProgram"]
110
+ for name, setting in start_command.settings:
111
+ print("Setting", name)
112
+ print("Current value", setting.value)
113
+ if setting.typology == "enum":
114
+ print("Available values", setting.values)
115
+ setting.value = setting.values[0]
116
+ elif setting.typology == "range":
117
+ print("Min value", setting.min)
118
+ print("Max value", setting.max)
119
+ print("Step value", setting.step)
120
+ setting.value = setting.min + setting.step
121
+ ```
122
+
123
+ ## Translation
124
+ To get the translation of some keys like programs, you can use the translation command to see all of hOn's available translations
125
+ ```commandline
126
+ $ pyhOn translate es
127
+ AC:
128
+ APPLIANCE_RENAME:
129
+ CONTENT_CHOOSE_NAME: Antes de continuar, debes elegir un nombre...
130
+ DEFAULT_NAME: Aire acondicionado
131
+ TITLE_CHOOSE_NAME: ¡Elije un nombre para tu aire acondicionado!
132
+ TITLE_SAVE_NAME: Para cambiar el nombre de tu aparato:
133
+ ...
134
+ ```
135
+ This generates a huge output. It is recommended to pipe this into a file
136
+ ```commandline
137
+ $ pyhOn translate fr > hon_fr.yaml
138
+ $ pyhOn translate en --json > hon_en.json
139
+ ```
140
+
141
+ ## Usage example
142
+ This library is used for the custom [HomeAssistant Integration "Haier hOn"](https://github.com/Andre0512/hOn).
143
+
144
+ ## Contribution
145
+ Any kind of contribution is welcome!
146
+
147
+ | Please add your appliances data to our [hon-test-data collection](https://github.com/Andre0512/hon-test-data). <br/>This helps us to develop new features and not to break compatibility in newer versions. |
148
+ |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
149
+
@@ -0,0 +1,112 @@
1
+ **This python package is unofficial and is not related in any way to Haier. It was developed by reversed engineered requests and can stop working at anytime!**
2
+
3
+ # pyhOn
4
+ [![PyPI - Status](https://img.shields.io/pypi/status/pyhOn)](https://pypi.org/project/pyhOn)
5
+ [![PyPI](https://img.shields.io/pypi/v/pyhOn?color=blue)](https://pypi.org/project/pyhOn)
6
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyhOn)](https://www.python.org/)
7
+ [![PyPI - License](https://img.shields.io/pypi/l/pyhOn)](https://github.com/Andre0512/pyhOn/blob/main/LICENSE)
8
+ [![PyPI - Downloads](https://img.shields.io/pypi/dm/pyhOn)](https://pypistats.org/packages/pyhon)
9
+ Control your Haier, Candy and Hoover appliances with python!
10
+ The idea behind this library is, to make the use of all available commands as simple as possible.
11
+
12
+ ## Installation
13
+ ```bash
14
+ pip install pyhOn
15
+ ```
16
+
17
+ ### Quick overview
18
+ To get an idea of what is possible, use the commandline-tool `pyhOn`. This command requests all available options of connected appliances from the hOn api of your Haier Account.
19
+ ```commandline
20
+ $ pyhOn --user example@mail.com --password pass123
21
+ ========== WM - Waschmaschine ==========
22
+ data:
23
+ attributes:
24
+ parameters:
25
+ ...
26
+ texture: 1
27
+ totalElectricityUsed: 28.71
28
+ totalWashCycle: 35
29
+ totalWaterUsed: 2494
30
+ transMode: 0
31
+ ...
32
+ settings:
33
+ startProgram:
34
+ rinseIterations:
35
+ max: 5
36
+ min: 3
37
+ step: 1
38
+ spinSpeed:
39
+ - 0
40
+ - 400
41
+ - 600
42
+ - 800
43
+ ...
44
+ ```
45
+
46
+ ## Python-API
47
+ ### List devices
48
+ ```python
49
+ import asyncio
50
+ from pyhon import Hon
51
+
52
+ async def devices_example():
53
+ async with Hon(USER, PASSWORD) as hon:
54
+ for appliance in hon.appliances:
55
+ print(appliance.nick_name)
56
+
57
+ asyncio.run(devices_example())
58
+ ```
59
+
60
+ ### Execute a command
61
+ ```python
62
+ async with Hon(USER, PASSWORD) as hon:
63
+ washing_machine = hon.appliances[0]
64
+ pause_command = washing_machine.commands["pauseProgram"]
65
+ await pause_command.send()
66
+ ```
67
+
68
+ ### Set command parameter
69
+ ```python
70
+ async with Hon(USER, PASSWORD) as hon:
71
+ washing_machine = hon.appliances[0]
72
+ start_command = washing_machine.commands["startProgram"]
73
+ for name, setting in start_command.settings:
74
+ print("Setting", name)
75
+ print("Current value", setting.value)
76
+ if setting.typology == "enum":
77
+ print("Available values", setting.values)
78
+ setting.value = setting.values[0]
79
+ elif setting.typology == "range":
80
+ print("Min value", setting.min)
81
+ print("Max value", setting.max)
82
+ print("Step value", setting.step)
83
+ setting.value = setting.min + setting.step
84
+ ```
85
+
86
+ ## Translation
87
+ To get the translation of some keys like programs, you can use the translation command to see all of hOn's available translations
88
+ ```commandline
89
+ $ pyhOn translate es
90
+ AC:
91
+ APPLIANCE_RENAME:
92
+ CONTENT_CHOOSE_NAME: Antes de continuar, debes elegir un nombre...
93
+ DEFAULT_NAME: Aire acondicionado
94
+ TITLE_CHOOSE_NAME: ¡Elije un nombre para tu aire acondicionado!
95
+ TITLE_SAVE_NAME: Para cambiar el nombre de tu aparato:
96
+ ...
97
+ ```
98
+ This generates a huge output. It is recommended to pipe this into a file
99
+ ```commandline
100
+ $ pyhOn translate fr > hon_fr.yaml
101
+ $ pyhOn translate en --json > hon_en.json
102
+ ```
103
+
104
+ ## Usage example
105
+ This library is used for the custom [HomeAssistant Integration "Haier hOn"](https://github.com/Andre0512/hOn).
106
+
107
+ ## Contribution
108
+ Any kind of contribution is welcome!
109
+
110
+ | Please add your appliances data to our [hon-test-data collection](https://github.com/Andre0512/hon-test-data). <br/>This helps us to develop new features and not to break compatibility in newer versions. |
111
+ |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
112
+
@@ -0,0 +1,4 @@
1
+ from .connection.api import HonAPI
2
+ from .hon import Hon
3
+
4
+ __all__ = ["Hon", "HonAPI"]
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env python
2
+ import argparse
3
+ import asyncio
4
+ import json
5
+ import logging
6
+ import sys
7
+ from getpass import getpass
8
+ from pathlib import Path
9
+ from typing import Tuple, Dict, Any
10
+
11
+ if __name__ == "__main__":
12
+ sys.path.insert(0, str(Path(__file__).parent.parent))
13
+
14
+ # pylint: disable=wrong-import-position
15
+ from pyhon import Hon, HonAPI, diagnose, printer
16
+
17
+ _LOGGER = logging.getLogger(__name__)
18
+
19
+
20
+ def get_arguments() -> Dict[str, Any]:
21
+ """Get parsed arguments."""
22
+ parser = argparse.ArgumentParser(description="pyhOn: Command Line Utility")
23
+ parser.add_argument("-u", "--user", help="user for haier hOn account")
24
+ parser.add_argument("-p", "--password", help="password for haier hOn account")
25
+ subparser = parser.add_subparsers(title="commands", metavar="COMMAND")
26
+ keys = subparser.add_parser("keys", help="print as key format")
27
+ keys.add_argument("keys", help="print as key format", action="store_true")
28
+ keys.add_argument("--all", help="print also full keys", action="store_true")
29
+ export = subparser.add_parser("export")
30
+ export.add_argument("export", help="export pyhon data", action="store_true")
31
+ export.add_argument("--zip", help="create zip archive", action="store_true")
32
+ export.add_argument("--anonymous", help="anonymize data", action="store_true")
33
+ export.add_argument("directory", nargs="?", default=Path().cwd())
34
+ translation = subparser.add_parser(
35
+ "translate", help="print available translation keys"
36
+ )
37
+ translation.add_argument(
38
+ "translate", help="language (de, en, fr...)", metavar="LANGUAGE"
39
+ )
40
+ translation.add_argument("--json", help="print as json", action="store_true")
41
+ parser.add_argument("-i", "--import", help="import pyhon data", nargs="?")
42
+ return vars(parser.parse_args())
43
+
44
+
45
+ async def translate(language: str, json_output: bool = False) -> None:
46
+ async with HonAPI(anonymous=True) as hon:
47
+ keys = await hon.translation_keys(language)
48
+ if json_output:
49
+ print(json.dumps(keys, indent=4))
50
+ else:
51
+ clean_keys = (
52
+ json.dumps(keys)
53
+ .replace("\\n", "\\\\n")
54
+ .replace("\\\\r", "")
55
+ .replace("\\r", "")
56
+ )
57
+ keys = json.loads(clean_keys)
58
+ print(printer.pretty_print(keys))
59
+
60
+
61
+ def get_login_data(args: Dict[str, str]) -> Tuple[str, str]:
62
+ if not (user := args["user"]):
63
+ user = input("User for hOn account: ")
64
+ if not (password := args["password"]):
65
+ password = getpass("Password for hOn account: ")
66
+ return user, password
67
+
68
+
69
+ async def main() -> None:
70
+ args = get_arguments()
71
+ if language := args.get("translate"):
72
+ await translate(language, json_output=args.get("json", ""))
73
+ return
74
+ test_data_path = Path(path) if (path := args.get("import", "")) else None
75
+ async with Hon(*get_login_data(args), test_data_path=test_data_path) as hon:
76
+ for device in hon.appliances:
77
+ if args.get("export"):
78
+ anonymous = args.get("anonymous", False)
79
+ path = Path(args.get("directory", "."))
80
+ if not args.get("zip"):
81
+ for file in await diagnose.appliance_data(device, path, anonymous):
82
+ print(f"Created {file}")
83
+ else:
84
+ archive = await diagnose.zip_archive(device, path, anonymous)
85
+ print(f"Created {archive}")
86
+ continue
87
+ print("=" * 10, device.appliance_type, "-", device.nick_name, "=" * 10)
88
+ if args.get("keys"):
89
+ data = device.data.copy()
90
+ attr = "get" if args.get("all") else "pop"
91
+ print(
92
+ printer.key_print(getattr(data["attributes"], attr)("parameters"))
93
+ )
94
+ print(printer.key_print(getattr(data, attr)("appliance")))
95
+ print(printer.key_print(data))
96
+ print(
97
+ printer.pretty_print(
98
+ printer.create_commands(device.commands, concat=True)
99
+ )
100
+ )
101
+ else:
102
+ print(diagnose.yaml_export(device))
103
+
104
+
105
+ def start() -> None:
106
+ try:
107
+ asyncio.run(main())
108
+ except KeyboardInterrupt:
109
+ print("Aborted.")
110
+
111
+
112
+ if __name__ == "__main__":
113
+ start()