mirror of
https://github.com/esphome/esphome.git
synced 2024-12-24 14:34:54 +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
db2128a344
commit
3d5e1d8d91
1 changed files with 5 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue