-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temperature Baseline cooldown in client.py (#643)
* Temperature Baseline cooldown in client.py * Changed cooldown calculations [skip ci] * using -n flag [skip ci] * using -n flag als in temperate [skip ci] * Other checking mechanism for lm_sensors temp [skip ci]
- Loading branch information
Showing
8 changed files
with
92 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE "machines" ADD COLUMN "base_temperature" integer; | ||
ALTER TABLE "machines" ADD COLUMN "current_temperature" integer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import os | ||
import subprocess | ||
from lib.global_config import GlobalConfig | ||
|
||
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
def get_temperature(chip, feature): | ||
if not feature or not chip: | ||
raise RuntimeError('You must set "base_temperature_chip" and "base_temperature_feature" in the config file. Please use calibration script to determine value.') | ||
|
||
try: | ||
output = subprocess.check_output( | ||
[f"{CURRENT_DIR}/../metric_providers/lm_sensors/metric-provider-binary", '-c', chip, '-f', feature, '-n', '1'], | ||
encoding='UTF-8', | ||
) | ||
except (FileNotFoundError, subprocess.CalledProcessError) as exc: | ||
raise RuntimeError('Could not get system temperature. Did you install lm_sensors and the corresponding metric provider correctly?') from exc | ||
|
||
return int(output.split(' ')[1])/100 | ||
|
||
if __name__ == '__main__': | ||
cur = get_temperature( | ||
GlobalConfig().config['machine']['base_temperature_chip'], | ||
GlobalConfig().config['machine']['base_temperature_feature'] | ||
) | ||
print('Current temperature is', cur) | ||
print('Base temperature is', GlobalConfig().config['machine']['base_temperature_value']) |