forked from M-Labs/thermostat
Add proper set_fan and get_fan coroutine methods
This commit is contained in:
parent
f6dc882d9b
commit
a54773d3ae
|
@ -160,6 +160,10 @@ class Client:
|
|||
"""
|
||||
return await self._get_conf("postfilter")
|
||||
|
||||
async def get_fan(self):
|
||||
"""Get Thermostat current fan settings"""
|
||||
return await self._command("fan")
|
||||
|
||||
async def report(self):
|
||||
"""Obtain one-time report on measurement values"""
|
||||
return await self._command("report")
|
||||
|
@ -219,6 +223,10 @@ class Client:
|
|||
value = str(value)
|
||||
await self._command(topic, str(channel), field, value)
|
||||
|
||||
async def set_fan(self, power="auto"):
|
||||
"""Set fan power"""
|
||||
await self._command("fan", str(power))
|
||||
|
||||
async def power_up(self, channel, target):
|
||||
"""Start closed-loop mode"""
|
||||
await self.set_param("pid", channel, "target", value=target)
|
||||
|
@ -236,10 +244,6 @@ class Client:
|
|||
"""Get Thermostat hardware revision"""
|
||||
return await self._command("hwrev")
|
||||
|
||||
async def fan(self):
|
||||
"""Get Thermostat current fan settings"""
|
||||
return await self._command("fan")
|
||||
|
||||
async def reset(self):
|
||||
"""Reset the Thermostat
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ class ClientWatcher(QObject):
|
|||
await asyncio.sleep(self.update_s - (loop.time() - time))
|
||||
|
||||
async def update_params(self):
|
||||
self.fan_update.emit(await self.client.fan())
|
||||
self.fan_update.emit(await self.client.get_fan())
|
||||
self.pwm_update.emit(await self.client.get_pwm())
|
||||
if self.poll_for_report:
|
||||
self.report_update.emit(await self.client.report())
|
||||
|
@ -486,7 +486,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||
self.hw_rev_data = await self.client.hw_rev()
|
||||
self._status(self.hw_rev_data)
|
||||
self.client_watcher.start_watching()
|
||||
self.fan_update(await self.client.fan())
|
||||
self.fan_update(await self.client.get_fan())
|
||||
# await self.client.set_param("fan", 1)
|
||||
else:
|
||||
self.status_lbl.setText("Disconnected")
|
||||
|
@ -532,7 +532,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||
if self.fan_auto_box.isChecked():
|
||||
with QSignalBlocker(self.fan_auto_box):
|
||||
self.fan_auto_box.setChecked(False)
|
||||
await self.client.set_param("fan", value)
|
||||
await self.client.set_fan(value)
|
||||
if not self.hw_rev_data["settings"]["fan_pwm_recommended"]:
|
||||
self._set_fan_pwm_warning()
|
||||
|
||||
|
@ -541,10 +541,10 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||
if not self.client.connected():
|
||||
return
|
||||
if enabled:
|
||||
await self.client.set_param("fan", "auto")
|
||||
self.fan_update(await self.client.fan())
|
||||
await self.client.set_fan("auto")
|
||||
self.fan_update(await self.client.get_fan())
|
||||
else:
|
||||
await self.client.set_param("fan", self.fan_power_slider.value())
|
||||
await self.client.set_fan(self.fan_power_slider.value())
|
||||
|
||||
@asyncSlot(int)
|
||||
async def on_report_box_stateChanged(self, enabled):
|
||||
|
|
Loading…
Reference in New Issue