Updated hw-sensors
* Filter out non-temp sensors * Adjusted formatting * Partially addresses issue #9
This commit is contained in:
parent
41b818ad99
commit
10cf7a1575
1 changed files with 11 additions and 11 deletions
|
|
@ -61,12 +61,9 @@ def get_feature_string(chip, feature):
|
||||||
skipname = len(feature.name)+1 # skip common prefix
|
skipname = len(feature.name)+1 # skip common prefix
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
if feature.type == sensors.feature.INTRUSION:
|
if feature.type != sensors.feature.TEMP:
|
||||||
vals = [sensors.get_value(chip, sf.number) for sf in sfs]
|
# Skip non-temperature sensors
|
||||||
# short path for INTRUSION to demonstrate type usage
|
return None
|
||||||
status = "alarm" if int(vals[0]) == 1 else "normal"
|
|
||||||
print_standard(' {:18} {}'.format(label, status))
|
|
||||||
return
|
|
||||||
|
|
||||||
for sf in sfs:
|
for sf in sfs:
|
||||||
name = sf.name[skipname:].decode("utf-8").strip()
|
name = sf.name[skipname:].decode("utf-8").strip()
|
||||||
|
|
@ -94,7 +91,7 @@ def get_feature_string(chip, feature):
|
||||||
list_data.append('{}: {}'.format(item, data.pop(item)))
|
list_data.append('{}: {}'.format(item, data.pop(item)))
|
||||||
list_data.extend(
|
list_data.extend(
|
||||||
['{}: {}'.format(k, v) for k, v in sorted(data.items())])
|
['{}: {}'.format(k, v) for k, v in sorted(data.items())])
|
||||||
data_str = '{:18} {} ({})'.format(
|
data_str = '{:18} {} {}'.format(
|
||||||
label, main_temp, ', '.join(list_data))
|
label, main_temp, ', '.join(list_data))
|
||||||
else:
|
else:
|
||||||
list_data.extend(sorted(data.items()))
|
list_data.extend(sorted(data.items()))
|
||||||
|
|
@ -119,10 +116,13 @@ if __name__ == '__main__':
|
||||||
chip_name = '{} ({})'.format(
|
chip_name = '{} ({})'.format(
|
||||||
sensors.chip_snprintf_name(chip),
|
sensors.chip_snprintf_name(chip),
|
||||||
sensors.get_adapter_name(chip.bus))
|
sensors.get_adapter_name(chip.bus))
|
||||||
chip_temps[chip_name] = [chip_name]
|
chip_feats = [get_feature_string(chip, feature)
|
||||||
for feature in sensors.FeatureIterator(chip):
|
for feature in sensors.FeatureIterator(chip)]
|
||||||
chip_temps[chip_name].append(get_feature_string(chip, feature))
|
# Strip empty/None items
|
||||||
chip_temps[chip_name].append('')
|
chip_feats = [f for f in chip_feats if f]
|
||||||
|
|
||||||
|
if chip_feats:
|
||||||
|
chip_temps[chip_name] = [chip_name, *chip_feats, '']
|
||||||
|
|
||||||
# Sort chips
|
# Sort chips
|
||||||
sensor_temps = []
|
sensor_temps = []
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue