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

Figure out how to clamp JSON values #154

Closed
lbussy opened this issue Jul 6, 2019 · 2 comments
Closed

Figure out how to clamp JSON values #154

lbussy opened this issue Jul 6, 2019 · 2 comments
Assignees

Comments

@lbussy
Copy link
Member

lbussy commented Jul 6, 2019

Different events (opening fridge to check on things, dry hopping, etc) can result in an abnormal spike or dip in values which are brief but which skew the scale of the chart. Figure out a way to clamp those values.

This could be done at the source (script) for "sane" values to avoid sensor errors (85°/185°F), but it would be desirable to allow a configurable clamp after the fact for display purposes.

Have to decide if this is going to be a destructive clamp (edit the JSON) or inline to the dygraph.

@lbussy lbussy self-assigned this Jul 6, 2019
@lbussy
Copy link
Member Author

lbussy commented Jul 6, 2019

Possible path:

Use jq to clamp the values of a given column:

jq --arg col 'FridgeSet' --argjson mx 62 --argjson mn 60 'def clamp: if . > $mx then $mx elif . < - $mn then - $mn else . end;(.cols | map(.id) | index($col)) as $ix | .rows[].c[$ix].v |= clamp' input.json

If we do this like a sed -i (inline), need to use something like the GNU moreutils tool sponge along the lines of:

jq --arg col 'FridgeSet' --argjson mx 62 --argjson mn 60 'def clamp: if . > $mx then $mx elif . < - $mn then - $mn else . end;(.cols | map(.id) | index($col)) as $ix | .rows[].c[$ix].v |= clamp' input.json | sponge input.json

@lbussy lbussy transferred this issue from brewpi-remix/brewpi-www-rmx Dec 23, 2020
@lbussy
Copy link
Member Author

lbussy commented Dec 23, 2020

This is done in devel, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant