pyebus.icon module

MDI Icon Utility.

pyebus.icon.get_icon(fielddef, state=None)[source]

Return Appropriate mdi-icon for fielddef at state.

>>> from pyebus import FieldDef, types
>>> get_icon(FieldDef(0, 'name', types.FloatType(), unit='°C'))
'mdi:thermometer'
>>> get_icon(FieldDef(0, 'name', types.TimeType()))
'mdi:timer'
>>> get_icon(FieldDef(0, 'name', types.EnumType(('on', 'off'))))
'mdi:toggle-switch'
>>> get_icon(FieldDef(0, 'name', types.EnumType(('on', 'off'))), 'off')
'mdi:toggle-switch-off'
>>> get_icon(FieldDef(0, 'name', types.EnumType(('on', 'off'))), 'on')
'mdi:toggle-switch'