@@ -131,9 +131,15 @@ async def set_temperature(self, celsius: float) -> None:
131
131
"""
132
132
await self .wait_for_is_running ()
133
133
await self ._driver .set_temperature (celsius = celsius )
134
- # Wait until we reach the target temperature.
135
- while self .status != TemperatureStatus .HOLDING :
136
- await self .wait_next_poll ()
134
+
135
+ async def _wait ():
136
+ # Wait until we reach the target temperature.
137
+ while self .status != TemperatureStatus .HOLDING :
138
+ await self .wait_next_poll ()
139
+
140
+ task = self ._loop .create_task (_wait ())
141
+ await self .make_cancellable (task )
142
+ await task
137
143
138
144
async def start_set_temperature (self , celsius ) -> None :
139
145
"""
@@ -146,7 +152,7 @@ async def start_set_temperature(self, celsius) -> None:
146
152
await self .wait_for_is_running ()
147
153
await self ._driver .set_temperature (celsius )
148
154
149
- async def await_temperature (self , awaiting_temperature : float ):
155
+ async def await_temperature (self , awaiting_temperature : float ) -> None :
150
156
"""
151
157
Await temperature in degree Celsius
152
158
Polls temperature module's temperature until
@@ -157,14 +163,17 @@ async def await_temperature(self, awaiting_temperature: float):
157
163
158
164
await self .wait_for_is_running ()
159
165
160
- if self .status == TemperatureStatus .HEATING :
161
- while self .temperature < awaiting_temperature :
162
- await self .wait_next_poll ()
163
- elif self .status == TemperatureStatus .COOLING :
164
- while self .temperature > awaiting_temperature :
165
- await self .wait_next_poll ()
166
-
167
- return
166
+ async def _await_temperature ():
167
+ if self .status == TemperatureStatus .HEATING :
168
+ while self .temperature < awaiting_temperature :
169
+ await self .wait_next_poll ()
170
+ elif self .status == TemperatureStatus .COOLING :
171
+ while self .temperature > awaiting_temperature :
172
+ await self .wait_next_poll ()
173
+
174
+ t = self ._loop .create_task (_await_temperature ())
175
+ await self .make_cancellable (t )
176
+ await t
168
177
169
178
async def deactivate (self ):
170
179
"""Stop heating/cooling and turn off the fan"""
0 commit comments