pyebus.circuitmap module

Mapping Of EBUS Circuit Names To Human-readable Names.

class pyebus.circuitmap.CircuitMap[source]

Bases: dict

Mapping of EBUS-circuit names To human-readable Names.

>>> c = CircuitMap({
...     'broadcast': '*',
...     'bai': 'Heater',
...     'mc': 'Mixer',
...     'hwc': 'Water',
... })
>>> for circuitname, humanname in c.items():
...     print(circuitname, '=', humanname)
broadcast = *
bai = Heater
mc = Mixer
hwc = Water
>>> tuple(c)
('broadcast', 'bai', 'mc', 'hwc')

Custom mappigns are added dictionary-like.

>>> c = CircuitMap()
>>> c['bai'] = 'Heater'
>>> c['boo'] = 'My Boo'
>>> c['mc.4'] = 'Mixer Unit 2'
get_humanname(circuitname)[source]

Return human-readable name for circuitname.

The .X suffix distinguishes multiple instances of the same unit, this is handled gracefully.

Returns:

human-readable name

Return type:

str

>>> c = CircuitMap({
...     'broadcast': '*',
...     'bai': 'Heater',
...     'mc': 'Mixer',
...     'hwc': 'Water',
... })
>>> c.get_humanname('bai')
'Heater'
>>> c.get_humanname('bai.3')
'Heater#3'
>>> c.get_humanname('mc.4')
'Mixer#4'
>>> c.get_humanname('unknown')
'unknown'
>>> c.get_humanname('unknown.4')
'unknown.4'