From 2b504068569f599b0297536f7c7e287368c83f8d Mon Sep 17 00:00:00 2001 From: Oxan van Leeuwen Date: Sun, 28 Nov 2021 20:02:10 +0100 Subject: [PATCH] Fix parsing of multiple values in EZO sensor (#2814) Co-authored-by: Lydia Sevelt --- esphome/components/ezo/ezo.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/esphome/components/ezo/ezo.cpp b/esphome/components/ezo/ezo.cpp index 426f2807c1..ca6f121dbb 100644 --- a/esphome/components/ezo/ezo.cpp +++ b/esphome/components/ezo/ezo.cpp @@ -74,6 +74,11 @@ void EZOSensor::loop() { if (buf[0] != 1) return; + // some sensors return multiple comma-separated values, terminate string after first one + for (int i = 1; i < sizeof(buf) - 1; i++) + if (buf[i] == ',') + buf[i] = '\0'; + float val = parse_number((char *) &buf[1], sizeof(buf) - 2).value_or(0); this->publish_state(val); }