66import logging
77from typing import Any , Final
88
9- from ..api import NodeEvent , NodeFeature , Temperature , Humidity
9+ from ..api import NodeEvent , NodeFeature , SenseStatistics
1010from ..connection import StickController
1111from ..exceptions import MessageError , NodeError
1212from ..messages .responses import SENSE_REPORT_ID , PlugwiseResponse , SenseReportResponse
@@ -43,8 +43,7 @@ def __init__(
4343 """Initialize Scan Device."""
4444 super ().__init__ (mac , address , controller , loaded_callback )
4545
46- self ._humidity = Humidity ()
47- self ._temperature = Temperature ()
46+ self ._sense_statistics = SenseStatistics ()
4847
4948 self ._sense_subscription : Callable [[], None ] | None = None
5049
@@ -94,26 +93,18 @@ async def unload(self) -> None:
9493 def _load_defaults (self ) -> None :
9594 """Load default configuration settings."""
9695 super ()._load_defaults ()
97- self ._temperature = Temperature (
98- temperature = 0.0 ,
96+ self ._sense_statistics = SenseStatistics (
97+ temperature = 0.0 ,
98+ humidity = 0.0 ,
9999 )
100- self ._humidity = Humidity (
101- humidity = 0.0 ,
102- )
103- # region properties
104-
105- @property
106- @raise_not_loaded
107- def temperature (self ) -> Temperature :
108- """Temperature."""
109- return self ._temperature
110-
111100
101+ # region properties
102+
112103 @property
113104 @raise_not_loaded
114- def humidity (self ) -> Humidity :
115- """Humidity ."""
116- return self ._humidity
105+ def sense_statistics (self ) -> SenseStatistics :
106+ """Sense Statistics ."""
107+ return self ._sense_statistics
117108
118109# end region
119110
@@ -126,22 +117,22 @@ async def _sense_report(self, response: PlugwiseResponse) -> bool:
126117 report_received = False
127118 await self ._available_update_state (True , response .timestamp )
128119 if response .temperature .value != 65535 :
129- self ._temperature .temperature = float (
120+ self ._sense_statistics .temperature = float (
130121 SENSE_TEMPERATURE_MULTIPLIER * (response .temperature .value / 65536 )
131122 - SENSE_TEMPERATURE_OFFSET
132123 )
133124 await self .publish_feature_update_to_subscribers (
134- NodeFeature .TEMPERATURE , self ._temperature
125+ NodeFeature .TEMPERATURE , self ._sense_statistics
135126 )
136127 report_received = True
137128
138129 if response .humidity .value != 65535 :
139- self ._humidity .humidity = float (
130+ self ._sense_statistics .humidity = float (
140131 SENSE_HUMIDITY_MULTIPLIER * (response .humidity .value / 65536 )
141132 - SENSE_HUMIDITY_OFFSET
142133 )
143134 await self .publish_feature_update_to_subscribers (
144- NodeFeature .HUMIDITY , self ._humidity
135+ NodeFeature .HUMIDITY , self ._sense_statistics
145136 )
146137 report_received = True
147138
@@ -164,9 +155,9 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
164155
165156 match feature :
166157 case NodeFeature .TEMPERATURE :
167- states [NodeFeature .TEMPERATURE ] = self ._temperature
158+ states [NodeFeature .TEMPERATURE ] = self ._sense_statistics
168159 case NodeFeature .HUMIDITY :
169- states [NodeFeature .HUMIDITY ] = self ._humidity
160+ states [NodeFeature .HUMIDITY ] = self ._sense_statistics
170161 case NodeFeature .PING :
171162 states [NodeFeature .PING ] = await self .ping_update ()
172163 case _:
0 commit comments