mielelogic-api 1.0.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 (54) hide show
  1. mielelogic_api-1.0.0/.editorconfig +19 -0
  2. mielelogic_api-1.0.0/.github/workflows/ci.yml +41 -0
  3. mielelogic_api-1.0.0/.github/workflows/lint.yml +44 -0
  4. mielelogic_api-1.0.0/.github/workflows/publish.yml +60 -0
  5. mielelogic_api-1.0.0/.github/workflows/validate.yml +40 -0
  6. mielelogic_api-1.0.0/.gitignore +223 -0
  7. mielelogic_api-1.0.0/.pre-commit-config.yaml +34 -0
  8. mielelogic_api-1.0.0/.python-version +1 -0
  9. mielelogic_api-1.0.0/AGENTS.md +90 -0
  10. mielelogic_api-1.0.0/LICENSE +287 -0
  11. mielelogic_api-1.0.0/PKG-INFO +271 -0
  12. mielelogic_api-1.0.0/README.md +253 -0
  13. mielelogic_api-1.0.0/TODO.md +1 -0
  14. mielelogic_api-1.0.0/custom_components/mielelogic/__init__.py +62 -0
  15. mielelogic_api-1.0.0/custom_components/mielelogic/binary_sensor.py +99 -0
  16. mielelogic_api-1.0.0/custom_components/mielelogic/config_flow.py +91 -0
  17. mielelogic_api-1.0.0/custom_components/mielelogic/const.py +22 -0
  18. mielelogic_api-1.0.0/custom_components/mielelogic/coordinator.py +210 -0
  19. mielelogic_api-1.0.0/custom_components/mielelogic/entity.py +24 -0
  20. mielelogic_api-1.0.0/custom_components/mielelogic/manifest.json +14 -0
  21. mielelogic_api-1.0.0/custom_components/mielelogic/sensor.py +257 -0
  22. mielelogic_api-1.0.0/custom_components/mielelogic/strings.json +49 -0
  23. mielelogic_api-1.0.0/custom_components/mielelogic/translations/en.json +49 -0
  24. mielelogic_api-1.0.0/hacs.json +5 -0
  25. mielelogic_api-1.0.0/mielelogic_api/__init__.py +17 -0
  26. mielelogic_api-1.0.0/mielelogic_api/_api.py +40 -0
  27. mielelogic_api-1.0.0/mielelogic_api/_version.py +8 -0
  28. mielelogic_api-1.0.0/mielelogic_api/client.py +254 -0
  29. mielelogic_api-1.0.0/mielelogic_api/dto.py +404 -0
  30. mielelogic_api-1.0.0/mielelogic_api/exceptions.py +13 -0
  31. mielelogic_api-1.0.0/mielelogic_api/settings.py +49 -0
  32. mielelogic_api-1.0.0/mielelogic_cli/__init__.py +1 -0
  33. mielelogic_api-1.0.0/mielelogic_cli/app.py +383 -0
  34. mielelogic_api-1.0.0/pyproject.toml +89 -0
  35. mielelogic_api-1.0.0/scripts/develop +144 -0
  36. mielelogic_api-1.0.0/scripts/export_live_snapshot.py +80 -0
  37. mielelogic_api-1.0.0/tests/__init__.py +0 -0
  38. mielelogic_api-1.0.0/tests/conftest.py +99 -0
  39. mielelogic_api-1.0.0/tests/custom_components/__init__.py +1 -0
  40. mielelogic_api-1.0.0/tests/custom_components/mielelogic/__init__.py +1 -0
  41. mielelogic_api-1.0.0/tests/custom_components/mielelogic/conftest.py +15 -0
  42. mielelogic_api-1.0.0/tests/custom_components/mielelogic/test_config_flow.py +93 -0
  43. mielelogic_api-1.0.0/tests/custom_components/mielelogic/test_coordinator.py +277 -0
  44. mielelogic_api-1.0.0/tests/custom_components/mielelogic/test_sensor.py +132 -0
  45. mielelogic_api-1.0.0/tests/mielelogic_api/__init__.py +1 -0
  46. mielelogic_api-1.0.0/tests/mielelogic_api/test_client.py +133 -0
  47. mielelogic_api-1.0.0/tests/mielelogic_api/test_dto.py +96 -0
  48. mielelogic_api-1.0.0/tests/mielelogic_api/test_external_api_endpoint.py +35 -0
  49. mielelogic_api-1.0.0/tests/mielelogic_api/test_settings.py +14 -0
  50. mielelogic_api-1.0.0/tests/mielelogic_cli/__init__.py +1 -0
  51. mielelogic_api-1.0.0/tests/mielelogic_cli/test_app.py +94 -0
  52. mielelogic_api-1.0.0/tests/support/__init__.py +1 -0
  53. mielelogic_api-1.0.0/tests/support/factories.py +184 -0
  54. mielelogic_api-1.0.0/uv.lock +3453 -0
@@ -0,0 +1,19 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+ root = true
5
+
6
+ [*]
7
+ indent_style = space
8
+ end_of_line = lf
9
+ charset = utf-8
10
+ trim_trailing_whitespace = true
11
+ insert_final_newline = true
12
+
13
+ [*.{sh,bash,json,toml,yml,yaml}]
14
+ indent_size = 2
15
+
16
+ [LICENSE]
17
+ indent_style = unset
18
+ indent_size = unset
19
+ trim_trailing_whitespace = unset
@@ -0,0 +1,41 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+ workflow_dispatch:
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ concurrency:
16
+ group: ${{ github.workflow }}-${{ github.ref }}
17
+ cancel-in-progress: true
18
+
19
+ jobs:
20
+ tests:
21
+ name: Tests
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - name: Checkout the repository
25
+ uses: actions/checkout@v6
26
+
27
+ - name: Set up Python
28
+ uses: actions/setup-python@v6
29
+ with:
30
+ python-version: "3.13"
31
+
32
+ - name: Install uv
33
+ uses: astral-sh/setup-uv@v6
34
+ with:
35
+ enable-cache: true
36
+
37
+ - name: Sync environment
38
+ run: uv sync --all-groups --frozen
39
+
40
+ - name: Run test suite
41
+ run: uv run poe test-ci
@@ -0,0 +1,44 @@
1
+ name: Lint
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+ workflow_dispatch:
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ concurrency:
16
+ group: ${{ github.workflow }}-${{ github.ref }}
17
+ cancel-in-progress: true
18
+
19
+ jobs:
20
+ ruff:
21
+ name: Ruff
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - name: Checkout the repository
25
+ uses: actions/checkout@v6
26
+
27
+ - name: Set up Python
28
+ uses: actions/setup-python@v6
29
+ with:
30
+ python-version: "3.13"
31
+
32
+ - name: Install uv
33
+ uses: astral-sh/setup-uv@v6
34
+ with:
35
+ enable-cache: true
36
+
37
+ - name: Sync environment
38
+ run: uv sync --all-groups --frozen
39
+
40
+ - name: Lint
41
+ run: uv run poe lint
42
+
43
+ - name: Check formatting
44
+ run: uv run poe format-check
@@ -0,0 +1,60 @@
1
+ name: Publish PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*.*.*"
7
+
8
+ permissions:
9
+ contents: read
10
+ id-token: write
11
+
12
+ concurrency:
13
+ group: ${{ github.workflow }}-${{ github.ref }}
14
+ cancel-in-progress: true
15
+
16
+ jobs:
17
+ build:
18
+ name: Build distribution
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - name: Checkout the repository
22
+ uses: actions/checkout@v6
23
+ with:
24
+ fetch-depth: 0
25
+
26
+ - name: Set up Python
27
+ uses: actions/setup-python@v6
28
+ with:
29
+ python-version: "3.13"
30
+
31
+ - name: Install uv
32
+ uses: astral-sh/setup-uv@v6
33
+ with:
34
+ enable-cache: true
35
+
36
+ - name: Build distribution
37
+ run: uv build
38
+
39
+ - name: Upload distribution artifacts
40
+ uses: actions/upload-artifact@v4
41
+ with:
42
+ name: python-dist
43
+ path: dist/
44
+
45
+ publish:
46
+ name: Publish to PyPI
47
+ runs-on: ubuntu-latest
48
+ needs: build
49
+ environment:
50
+ name: pypi
51
+ url: https://pypi.org/project/mielelogic-api/
52
+ steps:
53
+ - name: Download distribution artifacts
54
+ uses: actions/download-artifact@v4
55
+ with:
56
+ name: python-dist
57
+ path: dist/
58
+
59
+ - name: Publish distribution to PyPI
60
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,40 @@
1
+ name: Validate
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ schedule:
6
+ - cron: "0 0 * * *"
7
+ push:
8
+ branches:
9
+ - main
10
+ pull_request:
11
+ branches:
12
+ - main
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ concurrency:
18
+ group: ${{ github.workflow }}-${{ github.ref }}
19
+ cancel-in-progress: true
20
+
21
+ jobs:
22
+ hassfest:
23
+ name: Hassfest validation
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - name: Checkout the repository
27
+ uses: actions/checkout@v6
28
+
29
+ - name: Run hassfest validation
30
+ uses: home-assistant/actions/hassfest@master
31
+
32
+ hacs:
33
+ name: HACS validation
34
+ runs-on: ubuntu-latest
35
+ steps:
36
+ - name: Run HACS validation
37
+ uses: hacs/action@main
38
+ with:
39
+ category: integration
40
+ ignore: brands
@@ -0,0 +1,223 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+
204
+ # Home Assistant dev config
205
+ .ha-dev-config/
206
+ .ha-dev-venv/
207
+
208
+ # Ruff stuff:
209
+ .ruff_cache/
210
+
211
+ # PyPI configuration file
212
+ .pypirc
213
+
214
+ # Marimo
215
+ marimo/_static/
216
+ marimo/_lsp/
217
+ __marimo__/
218
+
219
+ # Streamlit
220
+ .streamlit/secrets.toml
221
+
222
+ # Snapshot directory
223
+ snapshots/
@@ -0,0 +1,34 @@
1
+ # See https://pre-commit.com for more information
2
+ default_language_version:
3
+ python: python3
4
+ fail_fast: false
5
+
6
+ repos:
7
+ - repo: local
8
+ hooks:
9
+ - id: ruff-lint
10
+ name: ruff lint
11
+ entry: ruff check
12
+ language: system
13
+ types: [python]
14
+ args: [--fix]
15
+
16
+ - id: ruff-format
17
+ name: ruff format
18
+ entry: ruff format
19
+ language: system
20
+ types: [python]
21
+
22
+ - id: pytest
23
+ name: pytest
24
+ entry: pytest
25
+ language: system
26
+ types: [python]
27
+ pass_filenames: false
28
+ args: [tests]
29
+
30
+ - id: editorconfig-checker
31
+ name: editorconfig-checker
32
+ entry: ec
33
+ language: system
34
+ types: [text]
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,90 @@
1
+ # AGENTS.md
2
+
3
+ ## Project summary
4
+
5
+ This repository contains two related but separate Python code areas in one uv project:
6
+
7
+ 1. `mielelogic_api/` The standalone async MieleLogic API client library.
8
+ 2. `custom_components/mielelogic/` The Home Assistant custom integration that uses the client library.
9
+
10
+ Keep these concerns separated in code structure, even though the development environment is shared.
11
+
12
+ ## Environment usage
13
+
14
+ - For agent execution, prefer `uv run ...` for Python-related commands instead of shell activation.
15
+ - Do not write `uv run ...` in user-facing documentation or examples unless the task explicitly asks for it.
16
+ - User-facing documentation should assume an activated environment via `source .venv/bin/activate` or `source .envrc`, then show commands without the `uv run` prefix.
17
+ - Use `uv sync` only when dependencies or dependency groups changed, or when the environment is inconsistent.
18
+ - Do not add extra wrapper env vars or command flags unless there is a concrete reason.
19
+
20
+ ## `uv sync`
21
+
22
+ - Use `uv sync` when dependencies or dependency groups changed, or when the environment is inconsistent with `pyproject.toml` / `uv.lock`.
23
+ - Run it from the repo root.
24
+ - Do not use `uv sync` casually before every command.
25
+
26
+ ## Poe usage
27
+
28
+ - For agent execution, prefer Poe through `uv run`.
29
+ - In user-facing docs, assume the environment is already activated and show plain `poe ...` commands.
30
+
31
+ - `poe test` is for the library and CLI tests only. It runs as `pytest tests/mielelogic_cli tests/mielelogic_api` in the shared `.venv`.
32
+ - `poe test-ha` is for Home Assistant integration tests only. It runs as `pytest tests/custom_components/mielelogic` in the shared `.venv`.
33
+ - `poe test-network` is for the opt-in live API tests marked with `@pytest.mark.network`.
34
+
35
+ ## Verification
36
+
37
+ - After changing code, run the relevant test suite, possibly limiting to tests touching the changes you have made, before considering the work done.
38
+ - For root library changes, run:
39
+
40
+ ```bash
41
+ poe test # pytest tests/mielelogic_cli tests/mielelogic_api
42
+ ```
43
+
44
+ - For Home Assistant integration changes, run:
45
+
46
+ ```bash
47
+ poe test-ha # pytest tests/custom_components/mielelogic
48
+ ```
49
+
50
+ - For changes that affect both layers, run:
51
+
52
+ ```bash
53
+ poe test-all # sequence running `poe test` then `poe test-ha`
54
+ ```
55
+
56
+ - Run lint, then tests, then format. Do not run tests a second time if the format changes anything. We trust that ruff does not change behaviour.
57
+
58
+ ## Root vs HA test separation
59
+
60
+ - The root library code and the Home Assistant integration remain separate code areas.
61
+ - The shared `.venv` includes both the root dev tools and the HA test stack.
62
+ - Keep the test entrypoints separate: `poe test` for `tests/mielelogic_cli` and `tests/mielelogic_api`, `poe test-ha` for `tests/custom_components/mielelogic`.
63
+
64
+ ## Networked tests
65
+
66
+ - Tests marked with `@pytest.mark.network` are real live API checks and should remain marked.
67
+ - Do not remove the marker.
68
+ - It is acceptable for these tests to be skipped, it only validates that the external API still acts as we encode into the DTO objects and factories.
69
+ - If live verification is needed, ask the user to run the command outside the sandbox.
70
+
71
+ ## Ruff / formatting
72
+
73
+ Linting and formatting are minor cleanup steps. Run them once at the end, during verification, after the relevant tests pass and you are done applying changes.
74
+
75
+ - Prefer Poe wrappers:
76
+
77
+ ```bash
78
+ poe lint # ruff check .
79
+ poe lint-fix # ruff check --fix .
80
+ poe format # ruff format .
81
+ ```
82
+
83
+ - Do not run lint or format repeatedly while still implementing changes unless there is a concrete need.
84
+
85
+ ## What not to do
86
+
87
+ - Do not use `PYTEST_DISABLE_PLUGIN_AUTOLOAD`.
88
+ - Do not change DTO definitions or factory logic. These need to stay EXACTLY equivalent to the live API. This is important.
89
+ - Do not remove or replace the existing `pydantic_settings` `.env` handling for unless the user explicitly asks for that exact change.
90
+ - Do not change `poe` commands unless asked to do so.