Skip to content

Commit 8438a02

Browse files
authored
Development environment (#307)
- Use `uv` for development environment - Fix some imports and types
1 parent c1204f0 commit 8438a02

File tree

12 files changed

+452
-6
lines changed

12 files changed

+452
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea/
22
.DS_Store
33
__pycache__/
4+
.venv/

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13.2

DEVELOPMENT.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Developing `connectlife-ha`
2+
3+
## Prerequisites
4+
5+
1. `uv`: https://docs.astral.sh/uv/getting-started/installation/
6+
2. Home Assistant development environment: https://developers.home-assistant.io/docs/development_environment
7+
8+
Install the custom component in your Home Assistant development environment
9+
(assuming your configuration directory is `config`):
10+
```bash
11+
home_assistant_repo=<local home-assistant repo>
12+
connectlife_ha_repo=<local connectlife-ha repo>
13+
cd ${home_assistant_repo}
14+
mkdir -p config/custom_components
15+
cd config/custom_components
16+
ln -s ${connectlife_ha_repo}>/custom_componnents/connectlife .
17+
```
18+
19+
Install dev dependencies (in `connectlife-ha` repo):
20+
```bash
21+
uv sync
22+
```
23+
24+
## Generate `strings.json`
25+
26+
This will add strings for new properties.
27+
28+
```bash
29+
uv run python -m scripts.gen_strings
30+
```
31+
32+
## Validate mapping files
33+
34+
```bash
35+
uv run python -m scripts.validate_mappings
36+
```
37+
38+
## Use a test server
39+
40+
Clone https://github.com/oyvindwe/connectlife/
41+
42+
In your local `connectlife` repo:
43+
```bash
44+
python -m connectlife.test_server -d dumps
45+
```
46+
47+
Configure the integration to access the test server:
48+
49+
![img.png](img.png)
50+
51+
![img_1.png](img_1.png)

DEVICES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
| WDSE1214-EVAJMW | Washing machine | 025 | 1wj120261v0w |
2929
| WFSE1214-MVW002 | Washing machine | 025 | 1wj120389v0b |
3030
| WF3S1114-LVW004 | Washing machine | 025 | 1wj105246v0w |
31-
| | Washing machine | 026 | 1b0610z0049j |
32-
| | Washing machine | 026 | 1b0628z0075j |
31+
| | Refrigerator | 026 | 1b0610z0049j |
32+
| | Refrigerator | 026 | 1b0628z0075j |
3333
| RS818N4TIE1 | Refrigerator | 026 | 1b0628z0146j |
3434
| WPNA84A2TSWIFI | Washing machine | 027 | washing-machine-wm22 |
3535
| DH3S802BW3 | Tumble dryer | 030 | 1wk080066v0w |

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,7 @@ To work around this issue, you can do the following:
109109

110110
Note that users at least in Russia and China can't log in using this integration. See discussion in
111111
https://github.com/bilan/connectlife-api-connector/issues/25
112+
113+
## Contributing
114+
115+
See [DEVELOPMENT.md](DEVELOPMENT.md).

custom_components/connectlife/config_flow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ class InvalidAuth(HomeAssistantError):
9595
class OptionsFlowHandler(OptionsFlow):
9696
"""Handles options flow for the component."""
9797

98-
async def async_step_init(self, user_input=None):
98+
_device_id: str | None = None
99+
100+
async def async_step_init(self, user_input=None) -> ConfigFlowResult:
99101
return self.async_show_menu(
100102
step_id="init",
101103
menu_options=["select_device", "development"],

custom_components/connectlife/sensor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
SensorEntityDescription,
1111
)
1212
from homeassistant.config_entries import ConfigEntry
13-
from homeassistant.const import Platform, EntityCategory
13+
from homeassistant.const import Platform
1414
from homeassistant.core import HomeAssistant, callback
1515
from homeassistant.exceptions import ServiceValidationError
1616
from homeassistant.helpers.entity_platform import AddEntitiesCallback
17-
from homeassistant.helpers import config_validation as cv, entity_platform, service
17+
from homeassistant.helpers import config_validation as cv, entity_platform
1818

1919
from .const import DOMAIN
2020
from .coordinator import ConnectLifeCoordinator

img.png

11.9 KB
Loading

img_1.png

22.7 KB
Loading

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[project]
2+
name = "connectlife-ha"
3+
version = "0.25.0"
4+
description = "Custom Home Assistant component for ConnectLife devices"
5+
readme = "README.md"
6+
requires-python = ">=3.13.2"
7+
dependencies = [
8+
"connectlife==0.5.4",
9+
]
10+
11+
[dependency-groups]
12+
dev = [
13+
"jschon==0.11.1",
14+
"pyyaml>=6.0.3",
15+
]

0 commit comments

Comments
 (0)