mirror of
https://github.com/xcat2/confluent.git
synced 2026-10-20 06:35:33 +00:00
Stop printing a sensor unit that has no reading
A discrete sensor reports no value, and the unit was appended regardless, so a watchdog came out as "Watchdog:% " and an event log sensor as "SEL:". The unit belongs to a reading, so only print it when there is one. On the platform this was seen on the units field is itself meaningless for such a sensor, carrying a percent sign and a trailing space from the sdr.
This commit is contained in:
@@ -144,7 +144,10 @@ def sensorpass(showout=True, appendtime=False):
|
||||
showval = u' {0} '.format(floatformat(sensedata['value']))
|
||||
else:
|
||||
showval = u' {0} '.format(sensedata.get('value', ''))
|
||||
if sensedata.get('units', None) not in (None, u''):
|
||||
# A discrete sensor has no reading for a unit to apply
|
||||
# to, and printing the unit on its own says nothing
|
||||
if (showval
|
||||
and sensedata.get('units', None) not in (None, u'')):
|
||||
showval += sensedata['units']
|
||||
if sensedata.get('health', 'ok') != 'ok':
|
||||
datadescription = [sensedata['health']]
|
||||
|
||||
Reference in New Issue
Block a user