m-hass-api 0.1.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.
@@ -0,0 +1,343 @@
1
+ Metadata-Version: 2.4
2
+ Name: m-hass-api
3
+ Version: 0.1.0
4
+ Summary: Provide access to Home Assistant API
5
+ Home-page: https://github.com/maxim75/m-hass-api
6
+ Author: Maksym Kozlenko
7
+ Author-email: max@kozlenko.info
8
+ Project-URL: Bug Tracker, https://github.com/yourusername/m-hass-api/issues
9
+ Project-URL: Documentation, https://github.com/yourusername/m-hass-api/blob/main/README.md
10
+ Project-URL: Source Code, https://github.com/yourusername/m-hass-api
11
+ Keywords: api client template sample
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Operating System :: OS Independent
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ Requires-Dist: requests>=2.25.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
28
+ Requires-Dist: pytest-cov>=3.0.0; extra == "dev"
29
+ Requires-Dist: black>=21.0.0; extra == "dev"
30
+ Requires-Dist: flake8>=4.0.0; extra == "dev"
31
+ Requires-Dist: mypy>=0.950; extra == "dev"
32
+ Dynamic: author
33
+ Dynamic: author-email
34
+ Dynamic: classifier
35
+ Dynamic: description
36
+ Dynamic: description-content-type
37
+ Dynamic: home-page
38
+ Dynamic: keywords
39
+ Dynamic: project-url
40
+ Dynamic: provides-extra
41
+ Dynamic: requires-dist
42
+ Dynamic: requires-python
43
+ Dynamic: summary
44
+
45
+ # m-hass-api
46
+
47
+ A Python package for interacting with Home Assistant API, complete with sample code, unit tests, and deployment documentation.
48
+
49
+ ## Project Structure
50
+
51
+ ```
52
+ m-hass-api/
53
+ ├── README.md
54
+ ├── setup.py
55
+ ├── requirements.txt
56
+ ├── .gitignore
57
+ ├── m_hass_api/
58
+ │ ├── __init__.py
59
+ │ └── sample.py
60
+ └── tests/
61
+ ├── __init__.py
62
+ └── test_sample.py
63
+ ```
64
+
65
+ ## Installation
66
+
67
+ ### From Source (Development)
68
+
69
+ ```bash
70
+ # Clone the repository
71
+ git clone <repository-url>
72
+ cd m-hass-api
73
+
74
+ # Create a virtual environment
75
+ python -m venv venv
76
+
77
+ # Activate the virtual environment
78
+ # On macOS/Linux:
79
+ source venv/bin/activate
80
+ # On Windows:
81
+ # venv\Scripts\activate
82
+
83
+ # Install the package in development mode
84
+ pip install -e .
85
+ ```
86
+
87
+ ### From PyPI (Production)
88
+
89
+ ```bash
90
+ pip install m-hass-api
91
+ ```
92
+
93
+ ## Usage
94
+
95
+ ### Basic Example
96
+
97
+ ```python
98
+ from m_hass_api import HassApiClient
99
+
100
+ # Create a client instance
101
+ client = HassApiClient(base_url="https://api.example.com")
102
+
103
+ # Make a sample API call
104
+ result = client.get_data()
105
+ print(f"Result: {result}")
106
+
107
+ # Get data with parameters
108
+ filtered_result = client.get_data(param1="value1", param2="value2")
109
+ print(f"Filtered Result: {filtered_result}")
110
+ ```
111
+
112
+ ### Running the Sample Script
113
+
114
+ ```bash
115
+ # Activate your virtual environment first
116
+ source venv/bin/activate # On macOS/Linux
117
+ # venv\Scripts\activate # On Windows
118
+
119
+ # Run the sample
120
+ python -m m_hass_api.hass_api_client
121
+ ```
122
+
123
+ ## Testing
124
+
125
+ ### Running All Tests
126
+
127
+ ```bash
128
+ # Activate your virtual environment
129
+ source venv/bin/activate # On macOS/Linux
130
+
131
+ # Install test dependencies
132
+ pip install -r requirements.txt
133
+
134
+ # Run all tests
135
+ pytest tests/
136
+
137
+ # Run with coverage
138
+ pytest tests/ --cov=m_hass_api --cov-report=html
139
+
140
+ # Open coverage report (macOS)
141
+ open htmlcov/index.html
142
+ ```
143
+
144
+ ### Running Specific Test Files
145
+
146
+ ```bash
147
+ pytest tests/test_hass_api_client.py
148
+ ```
149
+
150
+ ### Running Specific Tests
151
+
152
+ ```bash
153
+ # Run a specific test
154
+ pytest tests/test_sample.py::test_sample_client_initialization
155
+
156
+ # Run tests matching a pattern
157
+ pytest tests/ -k "test_get_data"
158
+ ```
159
+
160
+ ### Viewing Test Output
161
+
162
+ ```bash
163
+ # Verbose output
164
+ pytest tests/ -v
165
+
166
+ # Show print statements
167
+ pytest tests/ -v -s
168
+ ```
169
+
170
+ ## Development
171
+
172
+ ### Project Setup
173
+
174
+ ```bash
175
+ # Install development dependencies
176
+ pip install -r requirements.txt
177
+
178
+ # Install package in editable mode
179
+ pip install -e .
180
+ ```
181
+
182
+ ### Code Quality
183
+
184
+ ```bash
185
+ # Format code with black
186
+ black m_hass_api/ tests/
187
+
188
+ # Check code style with flake8
189
+ flake8 m_hass_api/ tests/
190
+
191
+ # Type checking with mypy (optional)
192
+ mypy m_hass_api/
193
+ ```
194
+
195
+ ## Deployment
196
+
197
+ ### Building the Package
198
+
199
+ ```bash
200
+ # Install build tools
201
+ pip install build twine
202
+
203
+ # Build the package
204
+ python -m build
205
+
206
+ # This will create:
207
+ # - dist/m_hass_api-0.1.0.tar.gz (source distribution)
208
+ # - dist/m_hass_api-0.1.0-py3-none-any.whl (wheel)
209
+ ```
210
+
211
+ ### Testing the Package Locally
212
+
213
+ ```bash
214
+ # Upload to TestPyPI
215
+ pip install twine
216
+ twine upload --repository testpypi dist/*
217
+
218
+ # Install from TestPyPI
219
+ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple m-hass-api
220
+ ```
221
+
222
+ ### Publishing to PyPI
223
+
224
+ **Prerequisites:**
225
+ 1. Create an account at https://pypi.org/account/register/
226
+ 2. Enable 2-Factor Authentication
227
+ 3. Generate an API token at https://pypi.org/manage/account/token/
228
+
229
+ ```bash
230
+ # Upload to PyPI
231
+ twine upload dist/*
232
+
233
+ # Your package will be available at:
234
+ # https://pypi.org/project/m-hass-api/
235
+ ```
236
+
237
+ ### Deployment Checklist
238
+
239
+ Before deploying, ensure:
240
+ - [ ] Update version number in `setup.py`
241
+ - [ ] Update `README.md` with latest changes
242
+ - [ ] All tests pass: `pytest tests/`
243
+ - [ ] Code is formatted: `black m_hass_api/ tests/`
244
+ - [ ] No linting errors: `flake8 m_hass_api/ tests/`
245
+ - [ ] Changelog is updated (if applicable)
246
+ - [ ] Documentation is complete
247
+
248
+ ### Version Management
249
+
250
+ Update the version in `setup.py` following semantic versioning:
251
+ - **MAJOR**: Incompatible API changes
252
+ - **MINOR**: Backwards-compatible functionality additions
253
+ - **PATCH**: Backwards-compatible bug fixes
254
+
255
+ Example: `0.1.0` → `0.1.1` (patch) → `0.2.0` (minor) → `1.0.0` (major)
256
+
257
+ ### GitHub Actions CI/CD (Optional)
258
+
259
+ You can automate testing and deployment with GitHub Actions. Create `.github/workflows/ci.yml`:
260
+
261
+ ```yaml
262
+ name: CI/CD
263
+
264
+ on: [push, pull_request]
265
+
266
+ jobs:
267
+ test:
268
+ runs-on: ubuntu-latest
269
+ steps:
270
+ - uses: actions/checkout@v3
271
+ - name: Set up Python
272
+ uses: actions/setup-python@v4
273
+ with:
274
+ python-version: '3.9'
275
+ - name: Install dependencies
276
+ run: |
277
+ pip install -r requirements.txt
278
+ pip install -e .
279
+ - name: Run tests
280
+ run: pytest tests/ --cov=m_hass_api
281
+
282
+ deploy:
283
+ needs: test
284
+ runs-on: ubuntu-latest
285
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
286
+ steps:
287
+ - uses: actions/checkout@v3
288
+ - name: Set up Python
289
+ uses: actions/setup-python@v4
290
+ with:
291
+ python-version: '3.9'
292
+ - name: Install build dependencies
293
+ run: pip install build twine
294
+ - name: Build package
295
+ run: python -m build
296
+ - name: Publish to PyPI
297
+ env:
298
+ TWINE_USERNAME: __token__
299
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
300
+ run: twine upload dist/*
301
+ ```
302
+
303
+ ## Troubleshooting
304
+
305
+ ### Common Issues
306
+
307
+ **Import Error:**
308
+ ```bash
309
+ # Make sure you've installed the package
310
+ pip install -e .
311
+ ```
312
+
313
+ **Tests Failing:**
314
+ ```bash
315
+ # Ensure all dependencies are installed
316
+ pip install -r requirements.txt
317
+ ```
318
+
319
+ **Build Failing:**
320
+ ```bash
321
+ # Clean and rebuild
322
+ rm -rf build/ dist/ *.egg-info
323
+ python -m build
324
+ ```
325
+
326
+ ## Contributing
327
+
328
+ 1. Fork the repository
329
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
330
+ 3. Make your changes
331
+ 4. Add tests for new functionality
332
+ 5. Ensure all tests pass (`pytest tests/`)
333
+ 6. Commit your changes (`git commit -m 'Add amazing feature'`)
334
+ 7. Push to the branch (`git push origin feature/amazing-feature`)
335
+ 8. Open a Pull Request
336
+
337
+ ## License
338
+
339
+ MIT License - feel free to use this template for your own projects.
340
+
341
+ ## Support
342
+
343
+ For issues, questions, or contributions, please open an issue on GitHub.
@@ -0,0 +1,299 @@
1
+ # m-hass-api
2
+
3
+ A Python package for interacting with Home Assistant API, complete with sample code, unit tests, and deployment documentation.
4
+
5
+ ## Project Structure
6
+
7
+ ```
8
+ m-hass-api/
9
+ ├── README.md
10
+ ├── setup.py
11
+ ├── requirements.txt
12
+ ├── .gitignore
13
+ ├── m_hass_api/
14
+ │ ├── __init__.py
15
+ │ └── sample.py
16
+ └── tests/
17
+ ├── __init__.py
18
+ └── test_sample.py
19
+ ```
20
+
21
+ ## Installation
22
+
23
+ ### From Source (Development)
24
+
25
+ ```bash
26
+ # Clone the repository
27
+ git clone <repository-url>
28
+ cd m-hass-api
29
+
30
+ # Create a virtual environment
31
+ python -m venv venv
32
+
33
+ # Activate the virtual environment
34
+ # On macOS/Linux:
35
+ source venv/bin/activate
36
+ # On Windows:
37
+ # venv\Scripts\activate
38
+
39
+ # Install the package in development mode
40
+ pip install -e .
41
+ ```
42
+
43
+ ### From PyPI (Production)
44
+
45
+ ```bash
46
+ pip install m-hass-api
47
+ ```
48
+
49
+ ## Usage
50
+
51
+ ### Basic Example
52
+
53
+ ```python
54
+ from m_hass_api import HassApiClient
55
+
56
+ # Create a client instance
57
+ client = HassApiClient(base_url="https://api.example.com")
58
+
59
+ # Make a sample API call
60
+ result = client.get_data()
61
+ print(f"Result: {result}")
62
+
63
+ # Get data with parameters
64
+ filtered_result = client.get_data(param1="value1", param2="value2")
65
+ print(f"Filtered Result: {filtered_result}")
66
+ ```
67
+
68
+ ### Running the Sample Script
69
+
70
+ ```bash
71
+ # Activate your virtual environment first
72
+ source venv/bin/activate # On macOS/Linux
73
+ # venv\Scripts\activate # On Windows
74
+
75
+ # Run the sample
76
+ python -m m_hass_api.hass_api_client
77
+ ```
78
+
79
+ ## Testing
80
+
81
+ ### Running All Tests
82
+
83
+ ```bash
84
+ # Activate your virtual environment
85
+ source venv/bin/activate # On macOS/Linux
86
+
87
+ # Install test dependencies
88
+ pip install -r requirements.txt
89
+
90
+ # Run all tests
91
+ pytest tests/
92
+
93
+ # Run with coverage
94
+ pytest tests/ --cov=m_hass_api --cov-report=html
95
+
96
+ # Open coverage report (macOS)
97
+ open htmlcov/index.html
98
+ ```
99
+
100
+ ### Running Specific Test Files
101
+
102
+ ```bash
103
+ pytest tests/test_hass_api_client.py
104
+ ```
105
+
106
+ ### Running Specific Tests
107
+
108
+ ```bash
109
+ # Run a specific test
110
+ pytest tests/test_sample.py::test_sample_client_initialization
111
+
112
+ # Run tests matching a pattern
113
+ pytest tests/ -k "test_get_data"
114
+ ```
115
+
116
+ ### Viewing Test Output
117
+
118
+ ```bash
119
+ # Verbose output
120
+ pytest tests/ -v
121
+
122
+ # Show print statements
123
+ pytest tests/ -v -s
124
+ ```
125
+
126
+ ## Development
127
+
128
+ ### Project Setup
129
+
130
+ ```bash
131
+ # Install development dependencies
132
+ pip install -r requirements.txt
133
+
134
+ # Install package in editable mode
135
+ pip install -e .
136
+ ```
137
+
138
+ ### Code Quality
139
+
140
+ ```bash
141
+ # Format code with black
142
+ black m_hass_api/ tests/
143
+
144
+ # Check code style with flake8
145
+ flake8 m_hass_api/ tests/
146
+
147
+ # Type checking with mypy (optional)
148
+ mypy m_hass_api/
149
+ ```
150
+
151
+ ## Deployment
152
+
153
+ ### Building the Package
154
+
155
+ ```bash
156
+ # Install build tools
157
+ pip install build twine
158
+
159
+ # Build the package
160
+ python -m build
161
+
162
+ # This will create:
163
+ # - dist/m_hass_api-0.1.0.tar.gz (source distribution)
164
+ # - dist/m_hass_api-0.1.0-py3-none-any.whl (wheel)
165
+ ```
166
+
167
+ ### Testing the Package Locally
168
+
169
+ ```bash
170
+ # Upload to TestPyPI
171
+ pip install twine
172
+ twine upload --repository testpypi dist/*
173
+
174
+ # Install from TestPyPI
175
+ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple m-hass-api
176
+ ```
177
+
178
+ ### Publishing to PyPI
179
+
180
+ **Prerequisites:**
181
+ 1. Create an account at https://pypi.org/account/register/
182
+ 2. Enable 2-Factor Authentication
183
+ 3. Generate an API token at https://pypi.org/manage/account/token/
184
+
185
+ ```bash
186
+ # Upload to PyPI
187
+ twine upload dist/*
188
+
189
+ # Your package will be available at:
190
+ # https://pypi.org/project/m-hass-api/
191
+ ```
192
+
193
+ ### Deployment Checklist
194
+
195
+ Before deploying, ensure:
196
+ - [ ] Update version number in `setup.py`
197
+ - [ ] Update `README.md` with latest changes
198
+ - [ ] All tests pass: `pytest tests/`
199
+ - [ ] Code is formatted: `black m_hass_api/ tests/`
200
+ - [ ] No linting errors: `flake8 m_hass_api/ tests/`
201
+ - [ ] Changelog is updated (if applicable)
202
+ - [ ] Documentation is complete
203
+
204
+ ### Version Management
205
+
206
+ Update the version in `setup.py` following semantic versioning:
207
+ - **MAJOR**: Incompatible API changes
208
+ - **MINOR**: Backwards-compatible functionality additions
209
+ - **PATCH**: Backwards-compatible bug fixes
210
+
211
+ Example: `0.1.0` → `0.1.1` (patch) → `0.2.0` (minor) → `1.0.0` (major)
212
+
213
+ ### GitHub Actions CI/CD (Optional)
214
+
215
+ You can automate testing and deployment with GitHub Actions. Create `.github/workflows/ci.yml`:
216
+
217
+ ```yaml
218
+ name: CI/CD
219
+
220
+ on: [push, pull_request]
221
+
222
+ jobs:
223
+ test:
224
+ runs-on: ubuntu-latest
225
+ steps:
226
+ - uses: actions/checkout@v3
227
+ - name: Set up Python
228
+ uses: actions/setup-python@v4
229
+ with:
230
+ python-version: '3.9'
231
+ - name: Install dependencies
232
+ run: |
233
+ pip install -r requirements.txt
234
+ pip install -e .
235
+ - name: Run tests
236
+ run: pytest tests/ --cov=m_hass_api
237
+
238
+ deploy:
239
+ needs: test
240
+ runs-on: ubuntu-latest
241
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
242
+ steps:
243
+ - uses: actions/checkout@v3
244
+ - name: Set up Python
245
+ uses: actions/setup-python@v4
246
+ with:
247
+ python-version: '3.9'
248
+ - name: Install build dependencies
249
+ run: pip install build twine
250
+ - name: Build package
251
+ run: python -m build
252
+ - name: Publish to PyPI
253
+ env:
254
+ TWINE_USERNAME: __token__
255
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
256
+ run: twine upload dist/*
257
+ ```
258
+
259
+ ## Troubleshooting
260
+
261
+ ### Common Issues
262
+
263
+ **Import Error:**
264
+ ```bash
265
+ # Make sure you've installed the package
266
+ pip install -e .
267
+ ```
268
+
269
+ **Tests Failing:**
270
+ ```bash
271
+ # Ensure all dependencies are installed
272
+ pip install -r requirements.txt
273
+ ```
274
+
275
+ **Build Failing:**
276
+ ```bash
277
+ # Clean and rebuild
278
+ rm -rf build/ dist/ *.egg-info
279
+ python -m build
280
+ ```
281
+
282
+ ## Contributing
283
+
284
+ 1. Fork the repository
285
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
286
+ 3. Make your changes
287
+ 4. Add tests for new functionality
288
+ 5. Ensure all tests pass (`pytest tests/`)
289
+ 6. Commit your changes (`git commit -m 'Add amazing feature'`)
290
+ 7. Push to the branch (`git push origin feature/amazing-feature`)
291
+ 8. Open a Pull Request
292
+
293
+ ## License
294
+
295
+ MIT License - feel free to use this template for your own projects.
296
+
297
+ ## Support
298
+
299
+ For issues, questions, or contributions, please open an issue on GitHub.
@@ -0,0 +1,18 @@
1
+ """
2
+ m-hass-api: A Python package for interacting with Home Assistant API.
3
+
4
+ This package provides a HassApiClient that demonstrates best practices for:
5
+ - Package structure
6
+ - Error handling
7
+ - Unit testing
8
+ - Documentation
9
+ - Deployment
10
+ """
11
+
12
+ __version__ = "0.1.0"
13
+ __author__ = "Maksym Kozlenko"
14
+ __email__ = "max@kozlenko.info"
15
+
16
+ from m_hass_api.hass_api_client import HassApiClient
17
+
18
+ __all__ = ["HassApiClient", "__version__"]
@@ -0,0 +1,11 @@
1
+ """
2
+ Main entry point for running the m-hass-api package as a module.
3
+
4
+ This file allows the package to be executed with:
5
+ python -m m_hass_api
6
+ """
7
+
8
+ from m_hass_api.hass_api_client import main
9
+
10
+ if __name__ == "__main__":
11
+ main()