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

Add option to thermal plugin to show first decimal place #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Gordin508
Copy link

The major point of this PR is to add an option to show a single decimal place in the temperature display. While most sensors only yield integer values, there are some which at least can supply 0.5 increments.

Current Behavior

  • Temperatures are processed as in integer steps. unit: 1 degree celcius

Updated Behavior

  • Temperatures are still technically stored as integers, but the new unit is a tenth of a degree. This allows to support higher precision sensors while still using integer arithmetics
  • A checkbox is added to control whether the first decimal position is shown
  • The UI still uses full degrees as unit and also stores the configured values as such. Therefore existing config values should still work as expected.

Minor Addition: Support for OTHER input files

This PR also adds logic to use an arbitrary file as sensor (called raw in the code), which works the same as reading a temperature from a file under /sys/class/thermal. Reading from arbitrary locations was already possible before by exploiting the logic, as the checks would treat a folder at an unexpected path as if it were under /proc/. You could previously e.g. create a file under /home/alice/mysensors/temperature with this content:

temperature: 80 C

and point the plugin to /home/alice/mysensors to read this 80 C value. The new behavior is to first check for the /sys/ and /proc prefixes explicitly, and if none applies, treat the passed path as a filepath with a format as used in /sys/class/thermal. You can e.g. create the file /home/alice/outside_temp with the content

25300

and pass the full path /home/alice/outside_temp to read this as 25.3 C. This can be paired with a background script to e.g. query non-internal sensors, web-APIs etc.

Minor Addition: Disambiguate temperatures from error code

Currently, temperature-returning functions return -1 upon error. While internal sensors will usually not encounter negative temperatures, this may be ambiguous now that we support OTHER files. Therefore the new error code is set to a number below absolute zero.

Some sensors can also supply the first decimal place instead of just
whole numbers. This commit adds support to use this additional precision
for display.
This necessitates changing the internal representation of temperatures from
degree celcius to a tenth of a degree.

This commit also adds logic to use an arbitrary file as sensor, which
works the same as reading a temperature from a file under /sys/class/thermal.
This was already possible before by exploiting the logic, as the checks would
treat a folder at an unexptected position as if it were under /proc/.
Now the support is explicit.
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

Successfully merging this pull request may close these issues.

None yet

1 participant