Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data_store: allow users to specify extra fields to track #839

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]`
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions moonraker/components/data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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")
Expand Down Expand Up @@ -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}")
Expand Down
Loading