Fix temperature values not being accessible due to NaN values (#650)
* Fix NaN values making JSON not accessible * Explain NaN replacement * Report fix in changelog
This commit is contained in:
parent
3ae34602eb
commit
29bfe4129f
2 changed files with 8 additions and 1 deletions
|
@ -26,6 +26,7 @@ All notable changes to eww will be listed here, starting at changes since versio
|
|||
- Fix deflisten scripts not always getting cleaned up properly
|
||||
- Add `:round-digits` to scale widget (By: gavynriebau)
|
||||
- Fix cirular-progress not properly displaying 100% values when clockwise is false
|
||||
- Fix temperatures inside `EWW_TEMPS` not being accessible if at least one value is `NaN`
|
||||
|
||||
|
||||
## 0.3.0 (26.05.2022)
|
||||
|
|
|
@ -60,7 +60,13 @@ pub fn get_temperatures() -> String {
|
|||
"{{ {} }}",
|
||||
c.components()
|
||||
.iter()
|
||||
.map(|c| format!(r#""{}": {}"#, c.label().to_uppercase().replace(' ', "_"), c.temperature()))
|
||||
.map(|c| format!(
|
||||
r#""{}": {}"#,
|
||||
c.label().to_uppercase().replace(' ', "_"),
|
||||
// It is common for temperatures to report a non-numeric value.
|
||||
// Tolerate it by serializing it as the string "null"
|
||||
c.temperature().to_string().replace("NaN", "\"null\"")
|
||||
))
|
||||
.join(",")
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue