Skip to content

Commit a8ae690

Browse files
authored
Merge pull request #530 from legrego/legrego/issue378
Remove deprecated locked/unlocked constants
2 parents 5338352 + 8b09c52 commit a8ae690

File tree

18 files changed

+3446
-2174
lines changed

18 files changed

+3446
-2174
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/vscode/devcontainers/python:3.12-bookworm
1+
FROM mcr.microsoft.com/vscode/devcontainers/python:3.13-bookworm
22

33
RUN apt-get update && apt-get install -y apt-transport-https gnupg2 procps less curl
44

@@ -7,7 +7,7 @@ COPY ".devcontainer/install-docker-cli.sh" install-docker-cli.sh
77
RUN /bin/bash install-docker-cli.sh
88

99
# Install Poetry for dependency management
10-
RUN pip install poetry~=1.8
10+
RUN pip install poetry~=2.2.1
1111

1212
# Install peek utility
1313
RUN pip install es-peek

.github/workflows/combined.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
- name: Install dependencies
2222
run: |
23-
python3 -m pip install poetry~=1.8
23+
python3 -m pip install poetry~=2.2.1
2424
poetry install
2525
- uses: "actions/checkout@v5"
2626
- name: HACS validation

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
1717
- uses: actions/setup-python@v6
1818
with:
19-
python-version: 3.12
19+
python-version: 3.13
2020
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
2121
- uses: actions/cache@v4
2222
with:

.github/workflows/pull.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
- uses: "actions/checkout@v5"
2626
- uses: "actions/setup-python@v6"
2727
with:
28-
python-version: "3.12"
29-
- run: python3 -m pip install poetry~=1.8
28+
python-version: "3.13"
29+
- run: python3 -m pip install poetry~=2.2.1
3030
- run: poetry install
3131
- run: poetry run ./scripts/lint --no-fix
3232

@@ -39,9 +39,9 @@ jobs:
3939
- name: Setup Python
4040
uses: "actions/setup-python@v6"
4141
with:
42-
python-version: "3.12"
42+
python-version: "3.13"
4343
- name: Install requirements
44-
run: python3 -m pip install poetry~=1.8 && poetry install
44+
run: python3 -m pip install poetry~=2.2.1 && poetry install
4545
- name: Run tests
4646
run: |
4747
poetry run pytest --cov=./custom_components --cov-report=xml --cov-report=html

.ruff.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ lint.select = [
6464
"S317", # suspicious-xml-sax-usage
6565
"S318", # suspicious-xml-mini-dom-usage
6666
"S319", # suspicious-xml-pull-dom-usage
67-
"S320", # suspicious-xmle-tree-usage
6867
"S601", # paramiko-call
6968
"S602", # subprocess-popen-with-shell-equals-true
7069
"S604", # call-with-shell-equals-true
@@ -111,8 +110,6 @@ lint.ignore = [
111110
"SIM115", # Use context handler for opening files
112111
"TRY003", # Avoid specifying long messages outside the exception class
113112
"TRY400", # Use `logging.exception` instead of `logging.error`
114-
# Ignored due to performance: https://github.com/charliermarsh/ruff/issues/2923
115-
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`
116113

117114
# May conflict with the formatter, https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
118115
"W191",

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,7 @@
5151
"python.analysis.autoFormatStrings": true,
5252
"python.analysis.inlayHints.functionReturnTypes": true,
5353
"python.analysis.inlayHints.variableTypes": true,
54+
"python-envs.defaultEnvManager": "ms-python.python:poetry",
55+
"python-envs.defaultPackageManager": "ms-python.python:poetry",
56+
"python-envs.pythonProjects": [],
5457
}

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Report a bug by [opening a new issue](../../issues/new/choose); it's that easy!
4141
- What actually happens
4242
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
4343

44-
People *love* thorough bug reports. I'm not even kidding.
44+
People _love_ thorough bug reports. I'm not even kidding.
4545

4646
## Use a Consistent Coding Style
4747

@@ -53,14 +53,16 @@ Visual Studio Code is the recommended code editor for this project.
5353
This project includes a [devcontainer](./.devcontainer) configuration for an easy to use and consistent development environment. With this container you will have a stand alone Home Assistant instance running and already configured with the included [`configuration.yaml`](./config/configuration.yaml) file.
5454

5555
### Dependency management
56+
5657
Dependencies are managed via [Poetry](https://python-poetry.org). This will be managed for you automatically if using the dev container. If you wish to run outside of a dev container, you will need to install your dependencies manually:
5758

5859
```sh
59-
pip install poetry~=1.8
60+
pip install poetry~=2.2.1
6061
poetry install
6162
```
6263

6364
### Running tests
65+
6466
Use `./scripts/test` to invoke the test runner.
6567

6668
You must be within the virtual environment where project dependencies are installed:
@@ -78,11 +80,13 @@ poetry shell
7880
```
7981

8082
### Updating snapshots
83+
8184
If you've made a change to code that impacts a snapshot, your test will fail and the snapshot needs to be updated. To update snapshots run /bin/bash ./scripts/update_snapshots
8285

8386
Or in vscode you can run one of the two update snapshot tasks by opening the command pallete with cmd + p (or ctrl + p), and type `task Update` to see the tasks related to updating snapshots.
8487

8588
### Linting
89+
8690
In the devcontainer, linting and formatting runs on save and linting errors are showed as PROBLEMS in vscode.
8791

8892
To invoke a full lint/format, in vscode open the command pallete with cmd + p (or ctrl + p), and type `task Lint`.

custom_components/elasticsearch/es_publish_pipeline.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,32 @@
1212
from math import isinf, isnan
1313
from typing import TYPE_CHECKING, Any
1414

15+
from homeassistant.components.lock.const import LockState
1516
from homeassistant.components.sun.const import STATE_ABOVE_HORIZON, STATE_BELOW_HORIZON
1617
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
1718
from homeassistant.const import (
1819
EVENT_STATE_CHANGED,
1920
STATE_CLOSED,
2021
STATE_HOME,
21-
STATE_LOCKED,
2222
STATE_NOT_HOME,
2323
STATE_OFF,
2424
STATE_ON,
2525
STATE_OPEN,
2626
STATE_UNKNOWN,
27-
STATE_UNLOCKED,
2827
)
29-
from homeassistant.core import Event, EventStateChangedData, HomeAssistant, State, callback
30-
from homeassistant.helpers import area_registry, device_registry, entity_registry, label_registry
28+
from homeassistant.core import (
29+
Event,
30+
EventStateChangedData,
31+
HomeAssistant,
32+
State,
33+
callback,
34+
)
35+
from homeassistant.helpers import (
36+
area_registry,
37+
device_registry,
38+
entity_registry,
39+
label_registry,
40+
)
3141
from homeassistant.helpers import state as state_helper
3242
from homeassistant.util import dt as dt_util
3343
from homeassistant.util.logging import async_create_catching_coro
@@ -504,7 +514,10 @@ class Formatter:
504514
"""Formats state changes into documents."""
505515

506516
def __init__(
507-
self, hass: HomeAssistant, settings: PipelineSettings, log: Logger = BASE_LOGGER
517+
self,
518+
hass: HomeAssistant,
519+
settings: PipelineSettings,
520+
log: Logger = BASE_LOGGER,
508521
) -> None:
509522
"""Initialize the formatter."""
510523
self._logger = log if log else BASE_LOGGER
@@ -547,7 +560,10 @@ def _state_to_extended_details(self, state: State) -> dict:
547560
document["friendly_name"] = state.name
548561

549562
if state.attributes.get("longitude") and state.attributes.get("latitude"):
550-
document["location"] = [state.attributes.get("longitude"), state.attributes.get("latitude")]
563+
document["location"] = [
564+
state.attributes.get("longitude"),
565+
state.attributes.get("latitude"),
566+
]
551567

552568
return document
553569

@@ -692,7 +708,7 @@ def state_as_boolean(cls, state: State) -> bool:
692708
if state.state in (
693709
"true",
694710
STATE_ON,
695-
STATE_LOCKED,
711+
LockState.LOCKED,
696712
STATE_ABOVE_HORIZON,
697713
STATE_OPEN,
698714
STATE_HOME,
@@ -701,7 +717,7 @@ def state_as_boolean(cls, state: State) -> bool:
701717
if state.state in (
702718
"false",
703719
STATE_OFF,
704-
STATE_UNLOCKED,
720+
LockState.UNLOCKED,
705721
STATE_UNKNOWN,
706722
STATE_BELOW_HORIZON,
707723
STATE_CLOSED,

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Introduction
33
---
4+
45
# Elasticsearch Component for Home-Assistant
56

67
Publish Home Assistant events to your [Elasticsearch](https://elastic.co) cluster!
@@ -17,7 +18,7 @@ Publish Home Assistant events to your [Elasticsearch](https://elastic.co) cluste
1718
- Elasticsearch 8.14+ (Self, [Cloud](https://www.elastic.co/cloud), or [Serverless](https://www.elastic.co/docs/current/serverless)).
1819
- [Elastic Common Schema version 1.0.0](https://github.com/elastic/ecs/releases/tag/v1.0.0)
1920
- [Home Assistant Community Store](https://github.com/custom-components/hacs)
20-
- Home Assistant >= 2024.6
21+
- Home Assistant >= 2025.6
2122

2223
## Older versions
2324

hacs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "Elasticsearch",
33
"render_readme": true,
4-
"homeassistant": "2024.6.0"
4+
"homeassistant": "2025.6.0"
55
}

0 commit comments

Comments
 (0)