Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ committed Jan 23, 2024
1 parent 3b7205b commit fb0f800
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 25 deletions.
12 changes: 6 additions & 6 deletions hahomematic/platforms/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,12 @@ def __str__(self) -> str:

InputParameterT = TypeVar(
"InputParameterT",
bool | None,
int | None,
float | None,
str | None,
int | str | None,
float | str | None,
bool,
int,
float,
str,
int | str,
float | str,
None,
)
ParameterT = TypeVar(
Expand Down
2 changes: 1 addition & 1 deletion hahomematic/platforms/generic/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from hahomematic.platforms.generic.entity import GenericEntity


class HmBinarySensor(GenericEntity[bool | None, bool | None]):
class HmBinarySensor(GenericEntity[bool | None, bool]):
"""
Implementation of a binary_sensor.
Expand Down
2 changes: 1 addition & 1 deletion hahomematic/platforms/generic/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from hahomematic.platforms.generic.entity import GenericEntity


class HmButton(GenericEntity[None, bool | None]):
class HmButton(GenericEntity[None, bool]):
"""
Implementation of a button.
Expand Down
21 changes: 8 additions & 13 deletions hahomematic/platforms/generic/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,19 @@ class BaseNumber(GenericEntity[ParameterT, InputParameterT]):
_platform = HmPlatform.NUMBER


class HmFloat(BaseNumber[float | None, float | str | None]):
class HmFloat(BaseNumber[float | None, float | str]):
"""
Implementation of a Float.
This is a default platform that gets automatically generated.
"""

def _prepare_value_for_sending(
self, value: float | str | None, do_validate: bool = True
self, value: float | str, do_validate: bool = True
) -> float | None:
"""Prepare value before sending."""
if (value is not None and not do_validate) or (
value is not None
and isinstance(value, float)
if not do_validate or (
isinstance(value, float)
and cast(float, self._min) <= float(value) <= cast(float, self._max)
):
return float(value)
Expand All @@ -47,21 +46,17 @@ def _prepare_value_for_sending(
)


class HmInteger(BaseNumber[int | None, int | str | None]):
class HmInteger(BaseNumber[int | None, int | str]):
"""
Implementation of an Integer.
This is a default platform that gets automatically generated.
"""

def _prepare_value_for_sending(
self, value: int | str | None, do_validate: bool = True
) -> int | None:
def _prepare_value_for_sending(self, value: int | str, do_validate: bool = True) -> int | None:
"""Prepare value before sending."""
if (value is not None and not do_validate) or (
value is not None
and isinstance(value, int)
and cast(int, self._min) <= int(value) <= cast(int, self._max)
if not do_validate or (
isinstance(value, int) and cast(int, self._min) <= int(value) <= cast(int, self._max)
):
return int(value)
if self._special and isinstance(value, str) and value in self._special:
Expand Down
4 changes: 2 additions & 2 deletions hahomematic/platforms/generic/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from hahomematic.platforms.support import get_value_from_value_list


class HmSelect(GenericEntity[int | str | None, int | str | None]):
class HmSelect(GenericEntity[int | str | None, int | str]):
"""
Implementation of a select entity.
Expand All @@ -30,7 +30,7 @@ def value(self) -> str | None: # type: ignore[override]
return str(self._default)

def _prepare_value_for_sending(
self, value: int | str | None, do_validate: bool = True
self, value: int | str, do_validate: bool = True
) -> int | str | None:
"""Prepare value before sending."""
# We allow setting the value via index as well, just in case.
Expand Down
2 changes: 1 addition & 1 deletion hahomematic/platforms/generic/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
_PARAM_ON_TIME: Final = "ON_TIME"


class HmSwitch(GenericEntity[bool | None, bool | None]):
class HmSwitch(GenericEntity[bool | None, bool]):
"""
Implementation of a switch.
Expand Down
2 changes: 1 addition & 1 deletion hahomematic/platforms/generic/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from hahomematic.platforms.generic.entity import GenericEntity


class HmText(GenericEntity[str | None, str | None]):
class HmText(GenericEntity[str | None, str]):
"""
Implementation of a text.
Expand Down

0 comments on commit fb0f800

Please sign in to comment.