diff --git a/src/tag/opentag3d/processor.py b/src/tag/opentag3d/processor.py index 57f2610..53a9ce7 100644 --- a/src/tag/opentag3d/processor.py +++ b/src/tag/opentag3d/processor.py @@ -99,7 +99,7 @@ def __to_filament(self, scan_result: ScanResult, data: dict) -> GenericFilament: weight_grams=data["weight"], hotend_min_temp_c=hotend_min_temp_c, hotend_max_temp_c=hotend_max_temp_c, - bed_temp_c=data["bed_temp"], + bed_temp_c=data["bed_temp"] or data["min_bed_temp"] or data["max_bed_temp"], drying_temp_c=data["max_dry_temp"], drying_time_hours=data["dry_time"], # Reuse the other processors' unknown-date sentinel for absent dates. diff --git a/test/test_opentag3d.py b/test/test_opentag3d.py index 95565f6..d9dabe7 100644 --- a/test/test_opentag3d.py +++ b/test/test_opentag3d.py @@ -109,6 +109,19 @@ def test_short_payload_and_target_fallback(processor, scan, payload): assert decode_payload(payload[:145], SCHEMAS[2])["mfg_time"] is None +def test_bed_temp_falls_back_to_range(processor, scan, payload): + # The spec stores a bed target alongside a min/max pair. A tag that fills in + # only the range should still yield a bed temperature, mirroring the existing + # print-temperature fallback rather than reporting 0. + payload[148] = 0 + payload[149:151] = bytes([11, 13]) + assert processor.process_tag(scan, tag(record(payload))).bed_temp_c == 55 + payload[149] = 0 + assert processor.process_tag(scan, tag(record(payload))).bed_temp_c == 65 + payload[150] = 0 + assert processor.process_tag(scan, tag(record(payload))).bed_temp_c == 0 + + def test_primary_transparent_black_and_cf_modifier(processor, scan, payload): payload[60:76] = bytes(16) payload[7:12] = b"CF\x00\x00\x00"