]> mj.ucw.cz Git - home-hw.git/commitdiff
BSB Daemon: Query hot water temperature
authorMartin Mares <mj@ucw.cz>
Sat, 15 Feb 2025 20:24:23 +0000 (21:24 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 15 Feb 2025 20:24:23 +0000 (21:24 +0100)
bsb/daemon/burrow-bsbd.c

index ca9e66d8102b3d00f92a8aa6d827dbcdff2719ac..60fc17a8a6a47f20fca1ffec83a9f83011826432 100644 (file)
@@ -283,6 +283,13 @@ static void process_answer(time_t t, byte *p, uint len)
        len -= 4;
 
        switch (addr) {
+               case 0x313d052f:
+                       // Hot water temperature
+                       if (len >= 3) {
+                               int temp = get_s16_be(p + 1);
+                               mqtt_publish("burrow/heating/water/temp", "%.2f %lld", temp / 64., (long long) t);
+                       }
+                       break;
        }
 }
 
@@ -358,7 +365,7 @@ int main(int argc UNUSED, char **argv)
 
        time_t now = time(NULL);
        time_t last_stats = 0;
-       // time_t last_query = now;
+       time_t last_query = now;
        int err, received;
        byte resp[64];
 
@@ -382,9 +389,16 @@ int main(int argc UNUSED, char **argv)
                        last_stats = now;
                }
 
-#if 0
-               if (last_query + 10 < now) {
-                       byte pkt[] = { 0xdc, 0xc2, 0x00, 0x0b, 0x06, 0x3d, 0x2e, 0x11, 0x25, 0x00, 0x00 };
+               if (last_query + 30 < now) {
+                       byte pkt[] = {
+                               0xdc,                   // start of frame
+                               0x00,                   // source address (filled by firmware)
+                               BSB_ADDR_BOILER,        // destination address
+                               0x0b,                   // length
+                               BSB_OP_QUERY,           // operation
+                               0x3d, 0x31, 0x05, 0x2f, // address: hot water temperature (first 2 bytes swapped!)
+                               0x00, 0x00,             // CRC (filled by firmware)
+                       };
                        if (err = libusb_bulk_transfer(devh, 0x01, pkt, sizeof(pkt), &received, 2000)) {
                                usb_error("Send failed: error %d", err);
                                continue;
@@ -393,7 +407,6 @@ int main(int argc UNUSED, char **argv)
                        }
                        last_query = now;
                }
-#endif
 
                if (err = libusb_interrupt_transfer(devh, 0x82, resp, 64, &received, 1000)) {
                        if (err != LIBUSB_ERROR_TIMEOUT)