Description
The FYTA API provides two values for sensor readings: current and currentFormatted. For the salinity measurement, it appears that the current value is a rounded integer, while currentFormatted seems to be the unrounded float.
The fyta_cli package currently uses the current value, which results in unsuitably coarse data.
See also this related homeassistant Github issue: home-assistant/core#146027
Likely Source of the Issue
Here is a snippet from the API response showing the difference between the two values for salinity:
{
"salinity": {
"type": "salinity",
"status": 5,
"values": {
"min_good": "0.6",
"max_good": "1",
"min_acceptable": "0.4",
"max_acceptable": "1.2",
"current": "3",
"currentFormatted": "2.50"
},
"unit": "mS/cm/h",
"absolute_values": {
"min": "0",
"max": "2.8",
"minText": "0",
"maxText": "2.8"
}
}
}
As you can see, current is "3" while currentFormatted is "2.50".
The issue seems to be caused by /src/fyta_cli/fyta_models.py#L137
d |= {"salinity": d["measurements"]
["salinity"]["values"]["current"]}
This line explicitly selects the current field.
Suggested Fix
The simple fix would be to just use the currentFormatted value instead of current when parsing the salinity measurement.
But maybe the current value is intended to be the unrounded float, and it's an API bug? It's unclear what the two values are meant to represent, as except for salinity they are always the exact same value anyway. Would be nice to get some clarification :)
Description
The FYTA API provides two values for sensor readings:
currentandcurrentFormatted. For the salinity measurement, it appears that thecurrentvalue is a rounded integer, whilecurrentFormattedseems to be the unrounded float.The
fyta_clipackage currently uses thecurrentvalue, which results in unsuitably coarse data.See also this related homeassistant Github issue: home-assistant/core#146027
Likely Source of the Issue
Here is a snippet from the API response showing the difference between the two values for salinity:
{ "salinity": { "type": "salinity", "status": 5, "values": { "min_good": "0.6", "max_good": "1", "min_acceptable": "0.4", "max_acceptable": "1.2", "current": "3", "currentFormatted": "2.50" }, "unit": "mS/cm/h", "absolute_values": { "min": "0", "max": "2.8", "minText": "0", "maxText": "2.8" } } }As you can see,
currentis "3" whilecurrentFormattedis "2.50".The issue seems to be caused by /src/fyta_cli/fyta_models.py#L137
This line explicitly selects the current field.
Suggested Fix
The simple fix would be to just use the
currentFormattedvalue instead ofcurrentwhen parsing the salinity measurement.But maybe the
currentvalue is intended to be the unrounded float, and it's an API bug? It's unclear what the two values are meant to represent, as except for salinity they are always the exact same value anyway. Would be nice to get some clarification :)