2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-15 20:27:45 +00:00

Expose sensor description data

Provide a function to enumerate available sensors
without actually reading them.  This paves the way
for management software to selectively query sensors
of interest depending on circumstance.

Change-Id: If63be5bc83996da10ee1fbb330395648340090bf
This commit is contained in:
Jarrod Johnon 2015-01-14 13:15:09 -05:00
parent d33d03f0cf
commit bc80931e59

View File

@ -364,3 +364,16 @@ class Command(object):
continue
raise Exception(rsp['error'])
yield self._sdr.sensors[sensor].decode_sensor_reading(rsp['data'])
def get_sensor_descriptions(self):
"""Get available sensor names
Iterates over the available sensor descriptions
:returns: Iterator of dicts describing each sensor
"""
if self._sdr is None:
self._sdr = sdr.SDR(self)
for sensor in self._sdr.get_sensor_numbers():
yield {'name': self._sdr.sensors[sensor].name,
'type': self._sdr.sensors[sensor].sensor_type}