termperature_store: use klippy_apis module
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
4a57dba586
commit
6fb4cdca62
|
@ -35,10 +35,10 @@ class TemperatureStore:
|
||||||
if state != "ready":
|
if state != "ready":
|
||||||
return
|
return
|
||||||
|
|
||||||
|
klippy_apis = self.server.lookup_plugin('klippy_apis')
|
||||||
# Fetch sensors
|
# Fetch sensors
|
||||||
try:
|
try:
|
||||||
result = await self.server.make_request(
|
result = await klippy_apis.query_objects({'heaters': None})
|
||||||
"objects/status", {'heaters': []})
|
|
||||||
except self.server.error as e:
|
except self.server.error as e:
|
||||||
logging.info(f"Error Configuring Sensors: {e}")
|
logging.info(f"Error Configuring Sensors: {e}")
|
||||||
return
|
return
|
||||||
|
@ -46,10 +46,9 @@ class TemperatureStore:
|
||||||
|
|
||||||
if sensors:
|
if sensors:
|
||||||
# Add Subscription
|
# Add Subscription
|
||||||
sub = {s: [] for s in sensors}
|
sub = {s: None for s in sensors}
|
||||||
try:
|
try:
|
||||||
result = await self.server.make_request(
|
status = await klippy_apis.subscribe_objects(sub)
|
||||||
"objects/subscription", sub)
|
|
||||||
except self.server.error as e:
|
except self.server.error as e:
|
||||||
logging.info(f"Error subscribing to sensors: {e}")
|
logging.info(f"Error subscribing to sensors: {e}")
|
||||||
return
|
return
|
||||||
|
@ -67,6 +66,8 @@ class TemperatureStore:
|
||||||
for sensor in list(self.last_temps.keys()):
|
for sensor in list(self.last_temps.keys()):
|
||||||
if sensor not in self.temperature_store:
|
if sensor not in self.temperature_store:
|
||||||
del self.last_temps[sensor]
|
del self.last_temps[sensor]
|
||||||
|
# Update initial temperatures
|
||||||
|
self._set_current_temps(status)
|
||||||
self.temp_update_cb.start()
|
self.temp_update_cb.start()
|
||||||
else:
|
else:
|
||||||
logging.info("No sensors found")
|
logging.info("No sensors found")
|
||||||
|
|
Loading…
Reference in New Issue