Fix parsing of multiple values in EZO sensor (#2814)

Co-authored-by: Lydia Sevelt <LydiaSevelt@gmail.com>
This commit is contained in:
Oxan van Leeuwen 2021-11-28 20:02:10 +01:00 committed by GitHub
parent 10a2a7e0fc
commit 2b50406856
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<float>((char *) &buf[1], sizeof(buf) - 2).value_or(0);
this->publish_state(val);
}