From ef158dcab4ace976265a17f6f1cdef91d602b3c9 Mon Sep 17 00:00:00 2001 From: Niels Date: Mon, 16 Nov 2026 17:18:42 +0100 Subject: [PATCH] Read mixer outputs from the web interface A mixer uses two outputs, opening and closing, which the outputs page shows with one common mode: 3: Misch.Hzkr AUTO PAR? auf: AUS 4: zu: AUS The output regex expects MODE/STATE on one line and skipped both. Report them as two outputs named after the mixer with auf/zu appended. Both saved outputs pages, from different devices, contain such a mixer; the test expectations encoded that it was missing. --- pyblnet/blnet_web.py | 19 +++++++++++++++++++ tests/test_structure/580600.mixer.htm | Bin 0 -> 7955 bytes tests/test_web_pages.py | 16 ++++++++++++++++ tests/web_raw/web_state.py | 6 ++++++ 4 files changed, 41 insertions(+) create mode 100644 tests/test_structure/580600.mixer.htm diff --git a/pyblnet/blnet_web.py b/pyblnet/blnet_web.py index 596ce2b..c794d43 100644 --- a/pyblnet/blnet_web.py +++ b/pyblnet/blnet_web.py @@ -25,6 +25,14 @@ ) DIGITAL_INPUT_STATES = {"AUS": "0", "OFF": "0", "EIN": "1", "ON": "1"} +# A mixer on the outputs page: its mode, then the state of the opening output +# and of the closing output, which has the next id +MIXER_OUTPUT_PATTERN = re.compile( + r"(?P\d+): (?P.+)\n( )+(?PAUTO|HAND) .*PAR\?.*\n" + r"( )+auf:( )+(?PAUS|EIN)\n" + r"( )*(?P\d+): zu:( )+(?PAUS|EIN)" +) + class _ElementTextParser(HTMLParser): """ @@ -326,6 +334,17 @@ def read_digital_values(self): match_dict[key] = html.unescape(value) # and append formatted dict data.append(match_dict) + # a mixer uses two outputs (open, close) with a common mode + for match in MIXER_OUTPUT_PATTERN.finditer(data_raw): + name = html.unescape(match["name"].replace(" ", " ")) + for id, direction, value in [ + (match["id"], "auf", match["open"]), + (match["id_close"], "zu", match["close"]), + ]: + data.append( + {"id": id, "name": f"{name} {direction}", "mode": match["mode"], "value": value} + ) + data.sort(key=lambda entry: int(entry["id"])) return data def set_digital_value(self, digital_id, value): diff --git a/tests/test_structure/580600.mixer.htm b/tests/test_structure/580600.mixer.htm new file mode 100644 index 0000000000000000000000000000000000000000..5f62a3319481a37d2fdc07d7c98732c5e4adbd32 GIT binary patch literal 7955 zcmd5>X>;PZ7JWZO&&*3;Iyg3jEEt#~TPHQ0bXRvWGxffCkwFt7`^j=PivRwu7K2&B zq^W$sRUshj>YjV<;%lih6eHT}46z^eIwLH6G!!DO8?z&7%8 zk(4=-KJ$?F&4IFiV!z@Q7N4oB@S@}V$Ai%05#~k2NlL(7W>7_I8v=tw#gJAahJ;Q1 z-;^xdVCQ(5I}VzOCTNDMg%!i8KK-NJU|U!-Rv8ke7OGRRK)GfX5(XbkHJIBF@gh zjf=$tRYG+c$F-3QfumfB0t%B0hsxM7-bYVE0u`VL35d%18#7DV!{iZjV~_rU#&eNm z)-q#dC0hFmCHjUjtbnp?)`_|x;&Mt?M1`tfb(I7rC=R6WkfKnP7`Gt<7TLkLOsisb zk$vUZi5(<`aVFtMI3oE7Rdl*&S^-gzEzFa7vNS7=k*`ywI>sj^6)7xG zq@vEgsvo^h7IKn`a$E4X|LE&cs~6`il(hg2u(*Oo>N_-2I1^P8)y9uLN6#ZF`zzE% zpqqLmM%5?6qU6c`>*h;IpjMiQpV0ixYR$tm!>AE(Rhn$H1-9-nr zUnFZbVGQ%DyPGc{x4Tn$ZZzG~T@P$uCD#Qxw6jy#Z%eg#hG4kiI4c&Msm{`bW%v$y z84pdSbYz%CRq3gkHz`0Pg$s>27CC1qO2Qm6M%du-3yS5})0gW=V)rHxH7Zsq!-6dJ+_wJz#gA}m|M{ma73iVm z&;I@0*L{GZxg+47z6)XGI`E2vIzbMdHZyfV|FBTPLQ2AiuCbx)pHzW&(_CIm8%$^>R@wO0a z&5ij3$?f2;`40Y;8S(Sja4HjUnxqG2@HIDI3g$|4T7@8s?Ng5B<72kKvZgn(ytOg& zAh{jPx8A}0;T(^eow~f%QI@j+vs}E2GMgV>qz>N!|7d&RAH4(q@%F+$eh2)M?S+4` z7QX8k6)efFVVaQ6;Qe%1@HoxQ=kp!9;2 z+-fhl&RQ?1$H3ypEQI^Fch{$1zMlPleewOr+135se|7YH+*@qp)LD zJ&PME6b>%uwieu$+N>@P2neHu;kw@ZM9ar37V352bXC5ETksYRCnl0%3ki9OCe&6B z9DT(cc7?2-{~&TWQ_JA=5VOv{Uu+J{5x9&<9ipIjBZ6&=5+c~?T!ZN5;&$ggha=x5 zGz+Y(!LW)Hv(W{%l+et!RNF&1yGi(qEe}nqwKwQ`&G}9)!G#ZHcyjj${)(+59Sd`x Qaw877)w^=)NV|vr4;r+M;Q#;t literal 0 HcmV?d00001 diff --git a/tests/test_web_pages.py b/tests/test_web_pages.py index b3051f7..9093d5c 100644 --- a/tests/test_web_pages.py +++ b/tests/test_web_pages.py @@ -108,6 +108,22 @@ def test_fetch_keeps_web_value_of_digital_input_missing_in_direct_data(self): self.assertEqual(data["analog"][13]["value"], "1") self.assertEqual(data["analog"][1]["value"], 14.3) + def test_read_digital_values_with_mixer(self): + # outputs 3 and 4 open and close a mixer, 15 and 16 are analog outputs + with serve("580600.mixer.htm"): + values = self.web.read_digital_values() + self.assertEqual( + values, + [ + {"id": "1", "name": "Ladep.WW.", "mode": "AUTO", "value": "AUS"}, + {"id": "2", "name": "Pumpe-Hzkr", "mode": "HAND", "value": "AUS"}, + {"id": "3", "name": "Misch.Hzkr auf", "mode": "AUTO", "value": "AUS"}, + {"id": "4", "name": "Misch.Hzkr zu", "mode": "AUTO", "value": "AUS"}, + {"id": "5", "name": "Anf.Brenner", "mode": "AUTO", "value": "AUS"}, + {"id": "10", "name": "Notheizer", "mode": "HAND", "value": "AUS"}, + ], + ) + def test_read_analog_values_access_denied(self): with serve(".error.html"): self.assertIsNone(self.web.read_analog_values()) diff --git a/tests/web_raw/web_state.py b/tests/web_raw/web_state.py index ea1b382..2f299de 100644 --- a/tests/web_raw/web_state.py +++ b/tests/web_raw/web_state.py @@ -60,6 +60,8 @@ "digital": { 1: {"id": "1", "mode": "AUTO", "name": "Pumpe-Solar", "value": "AUS"}, 2: {"id": "2", "mode": "AUTO", "name": "Pumpe-Hzkr", "value": "EIN"}, + 3: {"id": "3", "mode": "AUTO", "name": "Misch.Hzkr auf", "value": "AUS"}, + 4: {"id": "4", "mode": "AUTO", "name": "Misch.Hzkr zu", "value": "AUS"}, 5: {"id": "5", "mode": "AUTO", "name": "Anf.Kessel", "value": "AUS"}, 6: {"id": "6", "mode": "HAND", "name": "Vent.Solar", "value": "AUS"}, 7: {"id": "7", "mode": "AUTO", "name": "P Kaminofen", "value": "EIN"}, @@ -125,6 +127,8 @@ "digital": { 1: {"id": "1", "name": "Pumpe-Solar", "mode": "AUTO", "value": "AUS"}, 2: {"id": "2", "name": "Pumpe-Hzkr", "mode": "AUTO", "value": "EIN"}, + 3: {"id": "3", "name": "Misch.Hzkr auf", "mode": "AUTO", "value": "AUS"}, + 4: {"id": "4", "name": "Misch.Hzkr zu", "mode": "AUTO", "value": "AUS"}, 5: {"id": "5", "name": "Anf.Kessel", "mode": "AUTO", "value": "AUS"}, 6: {"id": "6", "name": "Vent.Solar", "mode": "HAND", "value": "AUS"}, 7: {"id": "7", "name": "P Kaminofen", "mode": "AUTO", "value": "EIN"}, @@ -159,6 +163,8 @@ STATE_DIGITAL = [ {"id": "1", "mode": "AUTO", "name": "Pumpe-Solar", "value": "AUS"}, {"id": "2", "mode": "AUTO", "name": "Pumpe-Hzkr", "value": "EIN"}, + {"id": "3", "mode": "AUTO", "name": "Misch.Hzkr auf", "value": "AUS"}, + {"id": "4", "mode": "AUTO", "name": "Misch.Hzkr zu", "value": "AUS"}, {"id": "5", "mode": "AUTO", "name": "Anf.Kessel", "value": "AUS"}, {"id": "6", "mode": "HAND", "name": "Vent.Solar", "value": "AUS"}, {"id": "7", "mode": "AUTO", "name": "P Kaminofen", "value": "EIN"},