Skip to content

Commit 7f11af4

Browse files
committed
Fix HCA output
1 parent 53a1a3f commit 7f11af4

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/devices/m_bus.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -773,18 +773,20 @@ static int parse_block2(const m_bus_data_t *in, m_bus_block1_t *block1)
773773
}
774774

775775
/* Q-walk_by */
776-
/* based on leaked infos */
777776
/* 000: CI:120 */
778777
/* 000: 0x780dff5f Magic for QUNDIS walk_by */
779778
/* 004: 0x35 L:53 Length of walk_by field (under investigation) */
780779
/* 005: 0x00 ST:0 Status 0= No Error */
781780
/* 006: 0x82 unknown */
782781
/* 007: AC AccessNumber */
783782
/* 008: 0x0000 CW:0 no encryption */
783+
/* 015: 0xffff V:total key */
784784
/* 017: 0x00000000 V:total - BCD LSB first */
785+
/* 021: 0xff2c V:lastyear key */
785786
/* 023: 0x00000000 V:lastyear - BCD LSB first */
787+
/* 027: 0x1e36 V:lastmonth key */
786788
/* 029: 0x00000000 V:lastmonth - BCD LSB first */
787-
/* timestamps following */
789+
/* timestamps follow */
788790
uint32_t ci_magic = ((uint32_t)b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3]);
789791
if (ci_magic == 0x780dff5f) {
790792
b2->AC = b[7];
@@ -798,14 +800,14 @@ static int parse_block2(const m_bus_data_t *in, m_bus_block1_t *block1)
798800
if (block1->A_DevType == 6) {
799801
/* WarmWater */
800802
// Value factor is 0.001, e.g. 123.456 m3
801-
b2->q_total_m3 = b2->q_total / 1000.0f;
802-
b2->q_lastyear_m3 = b2->q_lastyear / 1000.0f;
803-
b2->q_lastmonth_m3 = b2->q_lastmonth / 1000.0f;
803+
b2->q_total_m3 = b2->q_total * 0.001f;
804+
b2->q_lastyear_m3 = b2->q_lastyear * 0.001f;
805+
b2->q_lastmonth_m3 = b2->q_lastmonth * 0.001f;
804806
b2->q_mode = QDS_WW;
805807
}
806808
if (block1->A_DevType == 8) {
807809
/* Heat Cost Allocator */
808-
// Value factor is 1, e.g. 123456 m3
810+
// Value factor is K (from an invoice), e.g. 123456*K kW/h
809811
b2->q_mode = QDS_HCA;
810812
}
811813
}
@@ -952,9 +954,9 @@ static int m_bus_output_data(r_device *decoder, bitbuffer_t *bitbuffer, const m_
952954
"Q_total_m3", "Q_total_m3", DATA_COND, block1->block2.q_mode == QDS_WW, DATA_FORMAT, "%.3f m3", DATA_DOUBLE, block1->block2.q_total_m3,
953955
"Q_lastyear_m3", "Q_lastyear_m3", DATA_COND, block1->block2.q_mode == QDS_WW, DATA_FORMAT, "%.3f m3", DATA_DOUBLE, block1->block2.q_lastyear_m3,
954956
"Q_lastmonth_m3", "Q_lastmonth_m3", DATA_COND, block1->block2.q_mode == QDS_WW, DATA_FORMAT, "%.3f m3", DATA_DOUBLE, block1->block2.q_lastmonth_m3,
955-
"Q_total", "Q_total", DATA_COND, block1->block2.q_mode == QDS_HCA, DATA_DOUBLE, block1->block2.q_total,
956-
"Q_lastyear", "Q_lastyear", DATA_COND, block1->block2.q_mode == QDS_HCA, DATA_DOUBLE, block1->block2.q_lastyear,
957-
"Q_lastmonth", "Q_lastmonth", DATA_COND, block1->block2.q_mode == QDS_HCA, DATA_DOUBLE, block1->block2.q_lastmonth,
957+
"Q_total", "Q_total", DATA_COND, block1->block2.q_mode == QDS_HCA, DATA_INT, block1->block2.q_total,
958+
"Q_lastyear", "Q_lastyear", DATA_COND, block1->block2.q_mode == QDS_HCA, DATA_INT, block1->block2.q_lastyear,
959+
"Q_lastmonth", "Q_lastmonth", DATA_COND, block1->block2.q_mode == QDS_HCA, DATA_INT, block1->block2.q_lastmonth,
958960
"mic", "Integrity", DATA_STRING, "CRC",
959961
NULL);
960962
/* clang-format on */
@@ -963,7 +965,7 @@ static int m_bus_output_data(r_device *decoder, bitbuffer_t *bitbuffer, const m_
963965
/* clang-format off */
964966
data = data_int(data, "CI", "Control Info", "0x%02X", block1->block2.CI);
965967
data = data_int(data, "AC", "Access number", "0x%02X", block1->block2.AC);
966-
data = data_int(data, "ST", "Device Type", "0x%02X", block1->block2.ST);
968+
data = data_int(data, "ST", "Status", "0x%02X", block1->block2.ST);
967969
data = data_int(data, "CW", "Configuration Word", "0x%04X", block1->block2.CW);
968970
/* clang-format on */
969971
}

0 commit comments

Comments
 (0)