From 10105dc9f00f8d783b0dab22cad16d3f1fde226d Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 26 Oct 2024 17:27:36 +0200 Subject: [PATCH] Friendly Model Names --- components/tc_bus/__init__.py | 24 ++++++++--------- components/tc_bus/protocol.cpp | 48 ++++++++++++++++------------------ 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/components/tc_bus/__init__.py b/components/tc_bus/__init__.py index bc56313..74078dc 100644 --- a/components/tc_bus/__init__.py +++ b/components/tc_bus/__init__.py @@ -80,18 +80,18 @@ MODEL = tc_bus_ns.enum("Model") MODELS = { - "NONE": MODEL.MODEL_NONE, - "TCS_ISH1030": MODEL.MODEL_TCS_ISH1030, - "TCS_ISH3030": MODEL.MODEL_TCS_ISH3030, - "TCS_ISH3230": MODEL.MODEL_TCS_ISH3230, - "TCS_ISH3340": MODEL.MODEL_TCS_ISH3340, - "TCS_ISW3030": MODEL.MODEL_TCS_ISW3030, - "TCS_ISW3230": MODEL.MODEL_TCS_ISW3230, - "TCS_ISW3340": MODEL.MODEL_TCS_ISW3340, - "TCS_IVH3222": MODEL.MODEL_TCS_IVH3222, - "KOCH_TC50": MODEL.MODEL_KOCH_TC50, - "KOCH_TCH50": MODEL.MODEL_KOCH_TCH50, - "KOCH_TCH50P": MODEL.MODEL_KOCH_TCH50P + "None": MODEL.MODEL_NONE, + "TCS ISH1030": MODEL.MODEL_TCS_ISH1030, + "TCS ISH3030": MODEL.MODEL_TCS_ISH3030, + "TCS ISH3230": MODEL.MODEL_TCS_ISH3230, + "TCS ISH3340": MODEL.MODEL_TCS_ISH3340, + "TCS ISW3030": MODEL.MODEL_TCS_ISW3030, + "TCS ISW3230": MODEL.MODEL_TCS_ISW3230, + "TCS ISW3340": MODEL.MODEL_TCS_ISW3340, + "TCS IVH3222": MODEL.MODEL_TCS_IVH3222, + "Koch TC50": MODEL.MODEL_KOCH_TC50, + "Koch TCH50": MODEL.MODEL_KOCH_TCH50, + "Koch TCH50P": MODEL.MODEL_KOCH_TCH50P } CONF_TC_ID = "tc_bus" diff --git a/components/tc_bus/protocol.cpp b/components/tc_bus/protocol.cpp index 1f24ffb..ea79406 100644 --- a/components/tc_bus/protocol.cpp +++ b/components/tc_bus/protocol.cpp @@ -478,19 +478,17 @@ namespace esphome Model string_to_model(std::string str) { - std::transform(str.begin(), str.end(), str.begin(), ::toupper); - - if (str == "TCS_ISH1030") return MODEL_TCS_ISH1030; - if (str == "TCS_ISH3030") return MODEL_TCS_ISH3030; - if (str == "TCS_ISH3230") return MODEL_TCS_ISH3230; - if (str == "TCS_ISH3340") return MODEL_TCS_ISH3340; - if (str == "TCS_ISW3030") return MODEL_TCS_ISW3030; - if (str == "TCS_ISW3230") return MODEL_TCS_ISW3230; - if (str == "TCS_ISW3340") return MODEL_TCS_ISW3340; - if (str == "TCS_IVH3222") return MODEL_TCS_IVH3222; - if (str == "KOCH_TC50") return MODEL_KOCH_TC50; - if (str == "KOCH_TCH50") return MODEL_KOCH_TCH50; - if (str == "KOCH_TCH50P") return MODEL_KOCH_TCH50P; + if (str == "TCS ISH1030") return MODEL_TCS_ISH1030; + if (str == "TCS ISH3030") return MODEL_TCS_ISH3030; + if (str == "TCS ISH3230") return MODEL_TCS_ISH3230; + if (str == "TCS ISH3340") return MODEL_TCS_ISH3340; + if (str == "TCS ISW3030") return MODEL_TCS_ISW3030; + if (str == "TCS ISW3230") return MODEL_TCS_ISW3230; + if (str == "TCS ISW3340") return MODEL_TCS_ISW3340; + if (str == "TCS IVH3222") return MODEL_TCS_IVH3222; + if (str == "Koch TC50") return MODEL_KOCH_TC50; + if (str == "Koch TCH50") return MODEL_KOCH_TCH50; + if (str == "Koch TCH50P") return MODEL_KOCH_TCH50P; return MODEL_NONE; } @@ -499,18 +497,18 @@ namespace esphome { switch (model) { - case MODEL_TCS_ISH1030: return "TCS_ISH1030"; - case MODEL_TCS_ISH3030: return "TCS_ISH3030"; - case MODEL_TCS_ISH3230: return "TCS_ISH3230"; - case MODEL_TCS_ISH3340: return "TCS_ISH3340"; - case MODEL_TCS_ISW3030: return "TCS_ISW3030"; - case MODEL_TCS_ISW3230: return "TCS_ISW3230"; - case MODEL_TCS_ISW3340: return "TCS_ISW3340"; - case MODEL_TCS_IVH3222: return "TCS_IVH3222"; - case MODEL_KOCH_TC50: return "KOCH_TC50"; - case MODEL_KOCH_TCH50: return "KOCH_TCH50"; - case MODEL_KOCH_TCH50P: return "KOCH_TCH50P"; - default: return "NONE"; + case MODEL_TCS_ISH1030: return "TCS ISH1030"; + case MODEL_TCS_ISH3030: return "TCS ISH3030"; + case MODEL_TCS_ISH3230: return "TCS ISH3230"; + case MODEL_TCS_ISH3340: return "TCS ISH3340"; + case MODEL_TCS_ISW3030: return "TCS ISW3030"; + case MODEL_TCS_ISW3230: return "TCS ISW3230"; + case MODEL_TCS_ISW3340: return "TCS ISW3340"; + case MODEL_TCS_IVH3222: return "TCS IVH3222"; + case MODEL_KOCH_TC50: return "Koch TC50"; + case MODEL_KOCH_TCH50: return "Koch TCH50"; + case MODEL_KOCH_TCH50P: return "Koch TCH50P"; + default: return "None"; } } } // namespace tc_bus