obis.TEXT_MESSAGE_CODE: CosemParser(ValueParser(int)), obis.TEXT_MESSAGE: CosemParser(ValueParser(str)), obis.EQUIPMENT_IDENTIFIER_GAS: CosemParser(ValueParser(str)), obis.DEVICE_TYPE: CosemParser(ValueParser(str)), obis.VALVE_POSITION_GAS: CosemParser(ValueParser(str)), obis.GAS_METER_READING: MBusParser( ValueParser(timestamp), ValueParser(str), # changed to str see issue60 ValueParser(int), ValueParser(int), ValueParser(str), # obis ref ValueParser(str), # unit, position 5 ValueParser(Decimal), # meter reading, position 6 ), } } V3 = V2_2 V4 = { 'checksum_support': True, 'objects': { obis.P1_MESSAGE_HEADER: CosemParser(ValueParser(str)), obis.P1_MESSAGE_TIMESTAMP:
obis.TEXT_MESSAGE_CODE: CosemParser(ValueParser(int)), obis.TEXT_MESSAGE: CosemParser(ValueParser(str)), obis.EQUIPMENT_IDENTIFIER_GAS: CosemParser(ValueParser(str)), obis.DEVICE_TYPE: CosemParser(ValueParser(str)), obis.VALVE_POSITION_GAS: CosemParser(ValueParser(str)), obis.GAS_METER_READING: MBusParser( ValueParser(timestamp), ValueParser( str ), # DS: Changed from int to str due to failing example telegram. ValueParser(int), ValueParser(int), ValueParser(str), ValueParser(Decimal), ), } } V3 = V2_2 V4 = { 'checksum_support': True, 'objects': { obis.P1_MESSAGE_HEADER: CosemParser(ValueParser(str)), obis.P1_MESSAGE_TIMESTAMP:
obis.ELECTRICITY_DELIVERED_TARIFF_1: CosemParser(ValueParser(Decimal)), obis.ELECTRICITY_DELIVERED_TARIFF_2: CosemParser(ValueParser(Decimal)), obis.ELECTRICITY_ACTIVE_TARIFF: CosemParser(ValueParser(str)), obis.CURRENT_ELECTRICITY_USAGE: CosemParser(ValueParser(Decimal)), obis.CURRENT_ELECTRICITY_DELIVERY: CosemParser(ValueParser(Decimal)), obis.ACTUAL_TRESHOLD_ELECTRICITY: CosemParser(ValueParser(Decimal)), obis.ACTUAL_SWITCH_POSITION: CosemParser(ValueParser(str)), obis.TEXT_MESSAGE_CODE: CosemParser(ValueParser(int)), obis.TEXT_MESSAGE: CosemParser(ValueParser(str)), obis.EQUIPMENT_IDENTIFIER_GAS: CosemParser(ValueParser(str)), obis.DEVICE_TYPE: CosemParser(ValueParser(str)), obis.VALVE_POSITION_GAS: CosemParser(ValueParser(str)), obis.GAS_METER_READING: MBusParser( ValueParser(timestamp), ValueParser(int), ValueParser(int), ValueParser(int), ValueParser(str), ValueParser(Decimal), ), } } V3 = V2_2 V4 = { 'checksum_support': True, 'objects': { obis.P1_MESSAGE_HEADER: CosemParser(ValueParser(str)), obis.P1_MESSAGE_TIMESTAMP: CosemParser(ValueParser(timestamp)), obis.EQUIPMENT_IDENTIFIER: CosemParser(ValueParser(str)), obis.ELECTRICITY_USED_TARIFF_1: CosemParser(ValueParser(Decimal)),
TARIFF_DAY = 2 TARIFF_NIGHT = 1 SPECIFICATION = { P1_MESSAGE_HEADER: CosemParser(ValueParser(str)), P1_MESSAGE_TIMESTAMP: CosemParser(ValueParser(timestamp)), ELECTRICITY_USED_TARIFF_1: CosemParser(ValueParser(float)), ELECTRICITY_USED_TARIFF_2: CosemParser(ValueParser(float)), ELECTRICITY_DELIVERED_TARIFF_1: CosemParser(ValueParser(float)), ELECTRICITY_DELIVERED_TARIFF_2: CosemParser(ValueParser(float)), ELECTRICITY_ACTIVE_TARIFF: CosemParser(ValueParser(str)), EQUIPMENT_IDENTIFIER: CosemParser(ValueParser(str)), EQUIPMENT_IDENTIFIER_GAS: CosemParser(ValueParser(str)), HOURLY_GAS_METER_READING: MBusParser(ValueParser(timestamp), ValueParser(float)), CURRENT_ELECTRICITY_USAGE: CosemParser(ValueParser(Decimal)), CURRENT_ELECTRICITY_DELIVERY: CosemParser(ValueParser(Decimal)), } def parse(user, telegram): """ Parse a DSMR telegram and log the values in the appropriate places in the database. :param django.contrib.auth.models.User user: :param str telegram: """ parser = TelegramParser(SPECIFICATION) parsed_telegram = parser.parse(telegram.split("\r\n"))
obis.ELECTRICITY_DELIVERED_TARIFF_2: CosemParser(ValueParser(Decimal)), obis.ELECTRICITY_ACTIVE_TARIFF: CosemParser(ValueParser(str)), obis.CURRENT_ELECTRICITY_USAGE: CosemParser(ValueParser(Decimal)), obis.CURRENT_ELECTRICITY_DELIVERY: CosemParser(ValueParser(Decimal)), obis.ACTUAL_TRESHOLD_ELECTRICITY: CosemParser(ValueParser(Decimal)), obis.ACTUAL_SWITCH_POSITION: CosemParser(ValueParser(str)), obis.TEXT_MESSAGE_CODE: CosemParser(ValueParser(int)), obis.TEXT_MESSAGE: CosemParser(ValueParser(str)), obis.EQUIPMENT_IDENTIFIER_GAS: CosemParser(ValueParser(str)), obis.DEVICE_TYPE: CosemParser(ValueParser(str)), obis.VALVE_POSITION_GAS: CosemParser(ValueParser(str)), obis.GAS_METER_READING: MBusParser( ValueParser(timestamp), ValueParser(str), # changed to str see issue60 ValueParser(int), ValueParser(int), ValueParser(str), # obis ref ValueParser(str), # unit, position 5 ValueParser(Decimal), # meter reading, position 6 ), } } V3 = V2_2 V4 = { 'checksum_support': True, 'objects': { obis.P1_MESSAGE_HEADER: CosemParser(ValueParser(str)), obis.P1_MESSAGE_TIMESTAMP: CosemParser(ValueParser(timestamp)), obis.EQUIPMENT_IDENTIFIER: CosemParser(ValueParser(str)),