From 5f0bb00ff057ce3fc2d5d189b5b67cf282c6de76 Mon Sep 17 00:00:00 2001 From: Sanaa Hamel Date: Mon, 8 Apr 2024 09:28:59 -0400 Subject: [PATCH 1/2] data_store: allow users to specify extra fields to track Signed-off-by: Sanaa Hamel --- moonraker/components/data_store.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/moonraker/components/data_store.py b/moonraker/components/data_store.py index 739cf38ad..d6685a683 100644 --- a/moonraker/components/data_store.py +++ b/moonraker/components/data_store.py @@ -28,6 +28,7 @@ TempStore = Dict[str, Dict[str, Deque[Optional[float]]]] TEMP_UPDATE_TIME = 1. +STANDARD_FIELDS = {"temperature", "target", "power", "speed"} def _round_null(val: Optional[float], ndigits: int) -> Optional[float]: if val is None: @@ -39,6 +40,7 @@ def __init__(self, config: ConfigHelper) -> None: self.server = config.get_server() self.temp_store_size = config.getint('temperature_store_size', 1200) self.gcode_store_size = config.getint('gcode_store_size', 1000) + self.fields = STANDARD_FIELDS.union(config.getlist("fields", [])) # Temperature Store Tracking kconn: KlippyConnection = self.server.lookup_component("klippy_connection") @@ -93,10 +95,9 @@ async def _init_sensors(self) -> None: return logging.info(f"Configuring available sensors: {sensors}") new_store: TempStore = {} - valid_fields = ("temperature", "target", "power", "speed") for sensor in sensors: reported_fields = [ - f for f in list(status.get(sensor, {}).keys()) if f in valid_fields + f for f in list(status.get(sensor, {}).keys()) if f in self.fields ] if not reported_fields: logging.info(f"No valid fields reported for sensor: {sensor}") From da1e2c46445c778e69cb15d04a88838b9d4aca36 Mon Sep 17 00:00:00 2001 From: Sanaa Hamel Date: Mon, 8 Apr 2024 09:48:11 -0400 Subject: [PATCH 2/2] docs: describe `data_store:fields` config Signed-off-by: Sanaa Hamel --- docs/configuration.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index a035caa4a..dd5fa9fb5 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -292,6 +292,10 @@ temperature_store_size: 1200 # store approximately 20 minutes of data at one value per second. gcode_store_size: 1000 # The maximum number "gcode lines" to store. The default is 1000. +fields: +# Case-sensitive newline separated list of sensor fields to store. +# The following fields are implicitly added: temperature, target, power, speed +# The default is no additional fields. ``` ### `[job_queue]` @@ -1324,9 +1328,9 @@ address: # A valid ip address or hostname of the Philips Hue Bridge. This # parameter must be provided. port: -# A port number if an alternative Zigbee bridge is used on a HTTP port +# A port number if an alternative Zigbee bridge is used on a HTTP port # different from the default 80/443 -# +# user: # The api key used for request authorization. This option accepts # Jinja2 Templates, see the [secrets] section for details.