issue-51-telegram make Telegram completely backwards compatible for now
This commit is contained in:
parent
64787130bc
commit
0a6316e155
@ -27,9 +27,6 @@ class Telegram(dict):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def add(self, obis_reference, dsmr_object):
|
def add(self, obis_reference, dsmr_object):
|
||||||
if obis_reference not in self:
|
|
||||||
self[obis_reference] = dsmr_object
|
|
||||||
|
|
||||||
# Update name mapping used to get value by attribute. Example: telegram.P1_MESSAGE_HEADER
|
# Update name mapping used to get value by attribute. Example: telegram.P1_MESSAGE_HEADER
|
||||||
# Also keep track of the added names internally
|
# Also keep track of the added names internally
|
||||||
obis_name = obis_name_mapping.EN[obis_reference]
|
obis_name = obis_name_mapping.EN[obis_reference]
|
||||||
@ -42,6 +39,10 @@ class Telegram(dict):
|
|||||||
if isinstance(dsmr_object, DSMRObject) and dsmr_object.is_mbus_reading:
|
if isinstance(dsmr_object, DSMRObject) and dsmr_object.is_mbus_reading:
|
||||||
self._add_mbus(obis_reference, dsmr_object)
|
self._add_mbus(obis_reference, dsmr_object)
|
||||||
|
|
||||||
|
# Fill dict which is only used for backwards compatibility
|
||||||
|
if obis_reference not in self:
|
||||||
|
self[obis_reference] = dsmr_object
|
||||||
|
|
||||||
def _add_mbus(self, obis_reference, dsmr_object):
|
def _add_mbus(self, obis_reference, dsmr_object):
|
||||||
"""
|
"""
|
||||||
The given DsmrObject is assumed to be Mbus related and will be grouped into a MbusDevice.
|
The given DsmrObject is assumed to be Mbus related and will be grouped into a MbusDevice.
|
||||||
@ -68,7 +69,6 @@ class Telegram(dict):
|
|||||||
def get_mbus_device_by_channel(self, channel_id):
|
def get_mbus_device_by_channel(self, channel_id):
|
||||||
return self._mbus_channel_devices.get(channel_id)
|
return self._mbus_channel_devices.get(channel_id)
|
||||||
|
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self._item_names)
|
return len(self._item_names)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user