mirror of
https://github.com/esphome/esphome.git
synced 2024-12-20 16:18:49 +01:00
Fix parsing of multiple values in EZO sensor (#2814)
Co-authored-by: Lydia Sevelt <LydiaSevelt@gmail.com>
This commit is contained in:
parent
10a2a7e0fc
commit
2b50406856
@ -74,6 +74,11 @@ void EZOSensor::loop() {
|
|||||||
if (buf[0] != 1)
|
if (buf[0] != 1)
|
||||||
return;
|
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);
|
float val = parse_number<float>((char *) &buf[1], sizeof(buf) - 2).value_or(0);
|
||||||
this->publish_state(val);
|
this->publish_state(val);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user