def _convert_legacy_dsmr_gas_line(parsed_reading, current_line, next_line):
""" Legacy support for DSMR 2.x gas. """
legacy_gas_line = current_line
if next_line.startswith('('): # pragma: no cover
legacy_gas_line = current_line + next_line
legacy_gas_result = re.search(
r'[^(]+\((\d+)\)\(\d+\)\(\d+\)\(\d+\)\([0-9-.:]+\)\(m3\)\(([0-9.]+)\)',
legacy_gas_line
)
gas_timestamp = legacy_gas_result.group(1)
if timezone.now().dst() != timezone.timedelta(0):
gas_timestamp += 'S'
else:
gas_timestamp += 'W'
parsed_reading['extra_device_timestamp'] = reading_timestamp_to_datetime(
string=gas_timestamp
)
parsed_reading['extra_device_delivered'] = legacy_gas_result.group(2)
return parsed_reading
评论列表
文章目录