Skip to content

Commit 0abc159

Browse files
authored
Merge pull request #4232 from bramstroker/renovate/all-minor-patch
fix(deps): update all non-major dependencies
2 parents 8a8895f + 98a4d97 commit 0abc159

18 files changed

Lines changed: 492 additions & 405 deletions

File tree

.github/workflows/generate-plots.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323
persist-credentials: true
24-
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
24+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
2525
with:
2626
working-directory: './utils/visualize'
2727
enable-cache: true

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
fetch-depth: 0
1919
persist-credentials: false
2020
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
21-
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
21+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
2222
with:
2323
activate-environment: true
2424
enable-cache: "true"

.github/workflows/pr-comment-generate-plots.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
ref: ${{ github.event.pull_request.head.sha }}
1919
fetch-depth: 0
2020
persist-credentials: false
21-
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
21+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
2222
with:
2323
working-directory: './utils/visualize'
2424
enable-cache: true

.github/workflows/test-measure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
2222
with:
2323
persist-credentials: false
24-
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
24+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
2525
with:
2626
working-directory: './utils/measure'
2727
python-version: '3.14'

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
2323
with:
2424
persist-credentials: false
25-
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
25+
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
2626
with:
2727
enable-cache: true
2828
cache-dependency-glob: |

.github/workflows/zizmor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
persist-credentials: false
2424

2525
- name: Run zizmor 🌈
26-
uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6
26+
uses: zizmorcore/zizmor-action@192e21d79ab29983730a13d1382995c2307fbcaa # v0.5.7

custom_components/powercalc/strategy/composite.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from homeassistant.const import CONF_ATTRIBUTE, CONF_CONDITION, CONF_ENTITY_ID, STATE_OFF
1111
from homeassistant.core import HomeAssistant, State
12+
from homeassistant.exceptions import ConditionError
1213
from homeassistant.helpers.condition import ConditionCheckerType
1314
import homeassistant.helpers.config_validation as cv
1415
from homeassistant.helpers.event import TrackTemplate
@@ -152,7 +153,7 @@ async def calculate(self, entity_state: State) -> Decimal | None:
152153
for sub_strategy in self.strategies:
153154
strategy = sub_strategy.strategy
154155

155-
if sub_strategy.condition and not sub_strategy.condition(self.hass, {"state": entity_state}):
156+
if sub_strategy.condition and not self._condition_matches(sub_strategy.condition, entity_state):
156157
continue
157158

158159
if isinstance(strategy, PlaybookStrategy):
@@ -169,6 +170,13 @@ async def calculate(self, entity_state: State) -> Decimal | None:
169170

170171
return total if self.mode == CompositeMode.SUM_ALL else None
171172

173+
def _condition_matches(self, condition: ConditionCheckerType, entity_state: State) -> bool:
174+
try:
175+
return condition(self.hass, {"state": entity_state})
176+
except ConditionError:
177+
_LOGGER.debug("Skipping composite sub-strategy because condition evaluation failed", exc_info=True)
178+
return False
179+
172180
async def stop_active_playbooks(self) -> None:
173181
"""Stop any active playbooks from sub strategies."""
174182
for playbook in self.playbook_strategies:

custom_components/powercalc/strategy/wled.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,21 @@ async def calculate(self, entity_state: State) -> Decimal | None:
5454
if entity_state.entity_id == self._light_entity.entity_id
5555
else self._hass.states.get(self._light_entity.entity_id)
5656
)
57+
if light_state is None:
58+
return None
5759

5860
if light_state.state in OFF_STATES and self._standby_power:
5961
return self._standby_power
6062

61-
if entity_state.entity_id != self._estimated_current_entity:
62-
entity_state = self._hass.states.get(self._estimated_current_entity)
63+
current_state = (
64+
entity_state
65+
if entity_state.entity_id == self._estimated_current_entity
66+
else self._hass.states.get(self._estimated_current_entity)
67+
)
68+
if current_state is None:
69+
return None
6370

64-
if entity_state.state in [STATE_UNAVAILABLE, STATE_UNKNOWN]:
71+
if current_state.state in [STATE_UNAVAILABLE, STATE_UNKNOWN]:
6572
_LOGGER.warning(
6673
"%s: Estimated current entity %s is not available",
6774
self._light_entity.entity_id,
@@ -72,11 +79,11 @@ async def calculate(self, entity_state: State) -> Decimal | None:
7279
_LOGGER.debug(
7380
"%s: Estimated current %s (voltage=%d, power_factor=%.2f)",
7481
self._light_entity.entity_id,
75-
entity_state.state,
82+
current_state.state,
7683
self._voltage,
7784
self._power_factor,
7885
)
79-
power = float(entity_state.state) / 1000 * self._voltage * self._power_factor
86+
power = float(current_state.state) / 1000 * self._voltage * self._power_factor
8087
return evaluate_to_decimal(power)
8188

8289
async def find_estimated_current_entity(self) -> str:

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ docs = [
107107
dev = [
108108
"prek",
109109
"ruff>=0.15.0",
110-
"mypy==2.1.0",
110+
"mypy==2.2.0",
111111
"voluptuous-stubs>=0.1",
112112
"homeassistant-stubs",
113-
"pytest-homeassistant-custom-component==0.13.340",
113+
"pytest-homeassistant-custom-component==0.13.345",
114114
"types-pytz>=2024.1",
115115
"types-croniter>=2.0",
116116
"croniter>=6.0.0",

tests/conftest.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import asyncio
22
from collections.abc import Generator
33
from functools import lru_cache
4+
import inspect
45
import json
56
import logging
67
import os
78
import shutil
89
from typing import Any, Protocol, cast
9-
from unittest.mock import AsyncMock, patch
10+
from unittest.mock import AsyncMock, Mock, patch
1011
import uuid
1112

1213
from _pytest.fixtures import SubRequest
14+
import aiohttp
15+
import aioresponses.core
1316
from homeassistant import loader
1417
from homeassistant.const import CONF_ENTITY_ID
1518
from homeassistant.core import HomeAssistant
@@ -30,6 +33,23 @@
3033
from custom_components.powercalc.helpers import get_library_json_path, get_library_path
3134
from tests.common import get_test_config_dir, mock_device
3235

36+
# Remove this once aioresponses supports aiohttp 3.14+.
37+
# See https://github.com/pnuckowski/aioresponses/issues/289.
38+
_client_response_init = aiohttp.ClientResponse.__init__
39+
if "stream_writer" in inspect.signature(_client_response_init).parameters:
40+
_client_response_init_any = cast(Any, _client_response_init)
41+
42+
def _patched_client_response_init(self: aiohttp.ClientResponse, *args: object, **kwargs: object) -> None:
43+
kwargs.setdefault("stream_writer", Mock(output_size=0))
44+
_client_response_init_any(self, *args, **kwargs)
45+
46+
aiohttp.ClientResponse.__init__ = _patched_client_response_init # type: ignore[method-assign]
47+
48+
def _patched_stream_reader_factory(loop: asyncio.AbstractEventLoop | None = None) -> aiohttp.StreamReader:
49+
return aiohttp.StreamReader(Mock(), limit=2**16, loop=loop)
50+
51+
aioresponses.core.stream_reader_factory = _patched_stream_reader_factory
52+
3353

3454
@lru_cache(maxsize=1)
3555
def _load_test_library_json() -> dict[str, Any]:

0 commit comments

Comments
 (0)