Skip to content

Commit 06ae206

Browse files
committed
expand sense with hysteresis configuration and switch action
1 parent d8393ac commit 06ae206

File tree

4 files changed

+645
-17
lines changed

4 files changed

+645
-17
lines changed

plugwise_usb/api.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class NodeFeature(str, Enum):
5555
RELAY_LOCK = "relay_lock"
5656
SWITCH = "switch"
5757
SENSE = "sense"
58+
SENSE_HYSTERESIS = "sense_hysteresis"
5859
TEMPERATURE = "temperature"
5960

6061

@@ -260,14 +261,6 @@ class EnergyStatistics:
260261
day_production_reset: datetime | None = None
261262

262263

263-
@dataclass
264-
class SenseStatistics:
265-
"""Sense statistics collection."""
266-
267-
temperature: float | None = None
268-
humidity: float | None = None
269-
270-
271264
@dataclass(frozen=True)
272265
class SenseHysteresisConfig:
273266
"""Configuration of sense hysteresis switch.
@@ -289,16 +282,27 @@ class SenseHysteresisConfig:
289282
"""
290283

291284
humidity_enabled: bool | None = None
292-
humidity_upper_bound: int | None = None
293-
humidity_lower_bound: int | None = None
285+
humidity_upper_bound: float | None = None
286+
humidity_lower_bound: float | None = None
294287
humidity_direction: bool | None = None
295288
temperature_enabled: bool | None = None
296-
temperature_upper_bound: int | None = None
297-
temperature_lower_bound: int | None = None
289+
temperature_upper_bound: float | None = None
290+
temperature_lower_bound: float | None = None
298291
temperature_direction: bool | None = None
299292
dirty: bool = False
300293

301294

295+
@dataclass
296+
class SenseStatistics:
297+
"""Sense statistics collection."""
298+
299+
temperature: float | None = None
300+
humidity: float | None = None
301+
temperature_state: bool | None = None
302+
temperature_state: bool | None = None
303+
humidity_state: bool | None = None
304+
305+
302306
class PlugwiseNode(Protocol):
303307
"""Protocol definition of a Plugwise device node."""
304308

plugwise_usb/messages/requests.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,12 +1433,14 @@ def __init__( # noqa: PLR0913
14331433
temp_hum_value = 1 if temp_hum else 0
14341434
lower_bound_value = Int(lower_bound, length=4)
14351435
upper_bound_value = Int(upper_bound, length=4)
1436-
direction_value = 1 if direction else 0
1436+
direction_value_1 = 0 if direction else 1
1437+
direction_value_2 = 1 if direction else 0
14371438
self._args += [
14381439
temp_hum_value,
14391440
lower_bound_value,
1441+
direction_value_1,
14401442
upper_bound_value,
1441-
direction_value,
1443+
direction_value_2,
14421444
]
14431445

14441446
async def send(self) -> NodeAckResponse | None:

plugwise_usb/nodes/helpers/firmware.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class SupportedVersions(NamedTuple):
159159
NodeFeature.CIRCLEPLUS: 2.0,
160160
NodeFeature.INFO: 2.0,
161161
NodeFeature.SENSE: 2.0,
162+
NodeFeature.SENSE_HYSTERESIS: 2.0,
162163
NodeFeature.TEMPERATURE: 2.0,
163164
NodeFeature.HUMIDITY: 2.0,
164165
NodeFeature.ENERGY: 2.0,

0 commit comments

Comments
 (0)