termperature_store: use klippy_apis module

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2020-08-14 12:48:06 -04:00
parent 4a57dba586
commit 6fb4cdca62
1 changed files with 6 additions and 5 deletions

View File

@ -35,10 +35,10 @@ class TemperatureStore:
if state != "ready":
return
klippy_apis = self.server.lookup_plugin('klippy_apis')
# Fetch sensors
try:
result = await self.server.make_request(
"objects/status", {'heaters': []})
result = await klippy_apis.query_objects({'heaters': None})
except self.server.error as e:
logging.info(f"Error Configuring Sensors: {e}")
return
@ -46,10 +46,9 @@ class TemperatureStore:
if sensors:
# Add Subscription
sub = {s: [] for s in sensors}
sub = {s: None for s in sensors}
try:
result = await self.server.make_request(
"objects/subscription", sub)
status = await klippy_apis.subscribe_objects(sub)
except self.server.error as e:
logging.info(f"Error subscribing to sensors: {e}")
return
@ -67,6 +66,8 @@ class TemperatureStore:
for sensor in list(self.last_temps.keys()):
if sensor not in self.temperature_store:
del self.last_temps[sensor]
# Update initial temperatures
self._set_current_temps(status)
self.temp_update_cb.start()
else:
logging.info("No sensors found")