From 240af58b4cd634b5be80d08c6772d0cf7b1c3542 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 18 Dec 2022 09:21:42 +0100 Subject: [PATCH] tolerate missing parts in type_switch key (fix for #562) --- src/ebusd/mqtthandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ebusd/mqtthandler.cpp b/src/ebusd/mqtthandler.cpp index 96727fd8..d8a5f7b5 100755 --- a/src/ebusd/mqtthandler.cpp +++ b/src/ebusd/mqtthandler.cpp @@ -1132,8 +1132,8 @@ void MqttHandler::run() { if (!typeSwitchNames.empty()) { vector strs; splitFields(typeSwitch, &strs); - for (size_t pos = 0; pos < strs.size() && pos < typeSwitchNames.size(); pos++) { - values.set(typeSwitchNames[pos], strs[pos]); + for (size_t pos = 0; pos < typeSwitchNames.size(); pos++) { + values.set(typeSwitchNames[pos], pos < strs.size() ? strs[pos] : ""); } } }