Closed claudobahn closed 3 months ago
Hi @claudobahn , thank you for the contribution. Parts of it will lead to (at least for me) undesired behavior: on init, the gauges are intended to show the latest valid value, it will be updated when the next valid value will arrive. I agree it is a good idea to fix "NaN" to be shown, but the gauge shall still show the latest valid value (not the latest value). Why? Consider a situation, when the wind is calm. Zero wind has no direction. I don't want the wind direction needle to disappear. The wind vane of an anemometer doesn't disappear in calm winds, it stays at it's last position the wind turned it, the gauge shall simulate this. Also, with other obs_types, the latest value shall be shown, as this will match with it's representation in the corresponding chart (if there is such a chart). I'd merge a PR that conserves the current behavior but is hiding the needle and not showing "NaN", if there isn't any valid value for the displayed period.
@claudobahn do you plan to edit the PR to fulfill the requirements?
@mKainzbauer I've updated the pull request to maintain your desired stuck needle, but to still give viewers an easy visual indication that the value is not current. I think together with the heat map that provides them a good historical view of the gauge.
Here's an example of what this looks like:
The mentioned example of the vane in calm winds would result in a pale needle, but the "none" reading for the windDir could be very recent. Other than that, missing readings with an empty database aren't an issue - at least not for the gauges. I appreciate your efforts, but merging the PR would result in a behavior that doesn't meet the intention. Still, removing the the needle and suppressing NaN values when there are no values in the configured timespan is a good idea.
Seems like your only concern is windDir being none when windSpeed is 0 or missing? This is by design in the weewx system.
There is also an official way to override this behavior, which will give you your stuck value:
[StdWXCalculate]
[[WXXTypes]]
[[[windDir]]]
force_null = False
This value defaults to True
, but setting it to False
will give you your wind direction for zero wind..
Note this used to be called ignore_zero_wind
but was renamed in version 4.3
: https://www.weewx.com/docs/5.0/upgrade/#option-ignore_zero_wind-has-been-renamed-and-moved
The issue with doing this across the board is that when a sensor goes offline, the gauges make users think there are valid readings, they have to cross-check the chart and realize that some of the charts don't go up to current time, whereas others do. So it requires a high degree of attention to detail for somebody to realize the readings are invalid.
No, the windDir being "None", when windSpeed is 0 is not my concern, nor is it "by design" in the weewx system, it is a simple mathematical fact, that a vector with zero length has no direction. The point is: how do I want to present this to the user? The approach used here is to simulate a wind vane: the physical, real world wind vane doesn't disappear with zero wind speed, no, it is still there and points into the direction, the last bit of airflow pushed it to. I do not want to change anything with this.
If a sensor goes offline the gauge shows the latest valid value, which may not be recent. The charts (if any) show this over time. I don't see the benefit of adding more time dependent information to a gauge. Still, removing the the needle and suppressing NaN values when there are no values in the configured timespan is a good idea.
Ok, hopefully this reworked version is an acceptable solution.
Basically it maintains the existing behavior, except it deals w/ NaN.
But it also adds a new stuckNeedleEnabled
option which defaults to true
, when that is set to false
, it will only show the most recent value if available, otherwise no value is shown.
This allows users coming from older versions of fuzzy-archer to maintain desired behavior, while keeping your desired default behavior.
btw, here's the weewx write-up for why having no wind direction when windSpeed is zero is by design (their phrasing, not mine): https://weewx.com/docs/5.0/usersguide/troubleshooting/meteo/#there-is-no-wind-direction-when-wind-speed-is-zero
I've done a little change for a more clear method naming. How 'bout that? I'd merge that if you give it a go.
Sure, works for me.
There is still a Bug: the needle doesn't show up, when a loop value with windSpeed/windDir comes in. It needs an async reload for that. This needs to be checked every time, a MQTT message is received.
The latest commit should do the trick
will be part of 4.3 https://github.com/brewster76/fuzzy-archer/tree/4.3
This pull request hides the pointer and value display when no value is available in the latest archive record (or when the database is new / empty).
Here's an example of what this looks like:
This PR also avoids displaying NaN and misleading pointers on an empty database.