data_store: Add heater PWM value to /server/temperature_store

Signed-off-by: Bryan Mayland <bmayland@capnbry.net>
This commit is contained in:
Bryan Mayland 2021-01-12 16:19:46 +00:00 committed by Eric Callahan
parent 6f4a72fe2e
commit 8c365c62cb
1 changed files with 8 additions and 5 deletions

View File

@ -66,9 +66,10 @@ class DataStore:
else:
new_store[sensor] = {
'temperatures': deque(maxlen=TEMPERATURE_STORE_SIZE),
'targets': deque(maxlen=TEMPERATURE_STORE_SIZE)}
'targets': deque(maxlen=TEMPERATURE_STORE_SIZE),
'powers': deque(maxlen=TEMPERATURE_STORE_SIZE)}
if sensor not in self.last_temps:
self.last_temps[sensor] = (0., 0.)
self.last_temps[sensor] = (0., 0., 0.)
self.temperature_store = new_store
# Prune unconfigured sensors in self.last_temps
for sensor in list(self.last_temps.keys()):
@ -86,17 +87,19 @@ class DataStore:
def _set_current_temps(self, data):
for sensor in self.temperature_store:
if sensor in data:
last_temp, last_target = self.last_temps[sensor]
last_temp, last_target, last_power = self.last_temps[sensor]
self.last_temps[sensor] = (
round(data[sensor].get('temperature', last_temp), 2),
data[sensor].get('target', last_target))
data[sensor].get('target', last_target),
data[sensor].get('power', last_power))
def _update_temperature_store(self):
# XXX - If klippy is not connected, set values to zero
# as they are unknown?
for sensor, (temp, target) in self.last_temps.items():
for sensor, (temp, target, power) in self.last_temps.items():
self.temperature_store[sensor]['temperatures'].append(temp)
self.temperature_store[sensor]['targets'].append(target)
self.temperature_store[sensor]['powers'].append(power)
async def _handle_temp_store_request(self, web_request):
store = {}