Bump ohmepy to 1.5.1 (#141879)

* Bump ohmepy to 1.5.1

* Fix types for ohmepy version change
This commit is contained in:
Dan Raper 2025-03-31 10:44:01 +01:00 committed by GitHub
parent 560c719b0f
commit 778a2891ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 26 additions and 21 deletions

View File

@ -2,8 +2,9 @@
from __future__ import annotations
from collections.abc import Awaitable, Callable
from collections.abc import Callable, Coroutine
from dataclasses import dataclass
from typing import Any
from ohme import ApiException, ChargerStatus, OhmeApiClient
@ -23,7 +24,7 @@ PARALLEL_UPDATES = 1
class OhmeButtonDescription(OhmeEntityDescription, ButtonEntityDescription):
"""Class describing Ohme button entities."""
press_fn: Callable[[OhmeApiClient], Awaitable[None]]
press_fn: Callable[[OhmeApiClient], Coroutine[Any, Any, bool]]
BUTTON_DESCRIPTIONS = [

View File

@ -7,5 +7,5 @@
"integration_type": "device",
"iot_class": "cloud_polling",
"quality_scale": "silver",
"requirements": ["ohme==1.4.1"]
"requirements": ["ohme==1.5.1"]
}

View File

@ -1,7 +1,8 @@
"""Platform for number."""
from collections.abc import Awaitable, Callable
from collections.abc import Callable, Coroutine
from dataclasses import dataclass
from typing import Any
from ohme import ApiException, OhmeApiClient
@ -22,7 +23,7 @@ PARALLEL_UPDATES = 1
class OhmeNumberDescription(OhmeEntityDescription, NumberEntityDescription):
"""Class describing Ohme number entities."""
set_fn: Callable[[OhmeApiClient, float], Awaitable[None]]
set_fn: Callable[[OhmeApiClient, float], Coroutine[Any, Any, bool]]
value_fn: Callable[[OhmeApiClient], float]
@ -31,7 +32,7 @@ NUMBER_DESCRIPTION = [
key="target_percentage",
translation_key="target_percentage",
value_fn=lambda client: client.target_soc,
set_fn=lambda client, value: client.async_set_target(target_percent=value),
set_fn=lambda client, value: client.async_set_target(target_percent=int(value)),
native_min_value=0,
native_max_value=100,
native_step=1,
@ -42,7 +43,7 @@ NUMBER_DESCRIPTION = [
translation_key="preconditioning_duration",
value_fn=lambda client: client.preconditioning,
set_fn=lambda client, value: client.async_set_target(
pre_condition_length=value
pre_condition_length=int(value)
),
native_min_value=0,
native_max_value=60,

View File

@ -2,7 +2,7 @@
from __future__ import annotations
from collections.abc import Awaitable, Callable
from collections.abc import Callable, Coroutine
from dataclasses import dataclass
from typing import Any, Final
@ -24,7 +24,7 @@ PARALLEL_UPDATES = 1
class OhmeSelectDescription(OhmeEntityDescription, SelectEntityDescription):
"""Class to describe an Ohme select entity."""
select_fn: Callable[[OhmeApiClient, Any], Awaitable[None]]
select_fn: Callable[[OhmeApiClient, Any], Coroutine[Any, Any, bool | None]]
options: list[str] | None = None
options_fn: Callable[[OhmeApiClient], list[str]] | None = None
current_option_fn: Callable[[OhmeApiClient], str | None]

View File

@ -34,7 +34,7 @@ PARALLEL_UPDATES = 0
class OhmeSensorDescription(OhmeEntityDescription, SensorEntityDescription):
"""Class describing Ohme sensor entities."""
value_fn: Callable[[OhmeApiClient], str | int | float]
value_fn: Callable[[OhmeApiClient], str | int | float | None]
SENSOR_CHARGE_SESSION = [
@ -130,6 +130,6 @@ class OhmeSensor(OhmeEntity, SensorEntity):
entity_description: OhmeSensorDescription
@property
def native_value(self) -> str | int | float:
def native_value(self) -> str | int | float | None:
"""Return the state of the sensor."""
return self.entity_description.value_fn(self.coordinator.client)

View File

@ -78,7 +78,7 @@ def async_setup_services(hass: HomeAssistant) -> None:
"""List of charge slots."""
client = __get_client(service_call)
return {"slots": client.slots}
return {"slots": [slot.to_dict() for slot in client.slots]}
async def set_price_cap(
service_call: ServiceCall,

View File

@ -1,8 +1,9 @@
"""Platform for time."""
from collections.abc import Awaitable, Callable
from collections.abc import Callable, Coroutine
from dataclasses import dataclass
from datetime import time
from typing import Any
from ohme import ApiException, OhmeApiClient
@ -22,7 +23,7 @@ PARALLEL_UPDATES = 1
class OhmeTimeDescription(OhmeEntityDescription, TimeEntityDescription):
"""Class describing Ohme time entities."""
set_fn: Callable[[OhmeApiClient, time], Awaitable[None]]
set_fn: Callable[[OhmeApiClient, time], Coroutine[Any, Any, bool]]
value_fn: Callable[[OhmeApiClient], time]

2
requirements_all.txt generated
View File

@ -1559,7 +1559,7 @@ odp-amsterdam==6.0.2
oemthermostat==1.1.1
# homeassistant.components.ohme
ohme==1.4.1
ohme==1.5.1
# homeassistant.components.ollama
ollama==0.4.7

View File

@ -1305,7 +1305,7 @@ objgraph==3.5.0
odp-amsterdam==6.0.2
# homeassistant.components.ohme
ohme==1.4.1
ohme==1.5.1
# homeassistant.components.ollama
ollama==0.4.7

View File

@ -1,7 +1,9 @@
"""Tests for services."""
from datetime import datetime
from unittest.mock import AsyncMock, MagicMock
from ohme import ChargeSlot
import pytest
from syrupy.assertion import SnapshotAssertion
@ -30,11 +32,11 @@ async def test_list_charge_slots(
await setup_integration(hass, mock_config_entry)
mock_client.slots = [
{
"start": "2024-12-30T04:00:00+00:00",
"end": "2024-12-30T04:30:39+00:00",
"energy": 2.042,
}
ChargeSlot(
datetime.fromisoformat("2024-12-30T04:00:00+00:00"),
datetime.fromisoformat("2024-12-30T04:30:39+00:00"),
2.042,
)
]
assert snapshot == await hass.services.async_call(