briis / smartweather

WeatherFlow Smart Weather Component for Home Assistant
MIT License
108 stars 11 forks source link

Precipitation Accumulations differ from Tempest App #89

Closed robchandhok closed 2 years ago

robchandhok commented 2 years ago

Thank you for all the work building this @briis !

Since it actually rained in California this week, I was able to observe for the first time a difference between the precipitation numbers in Home Assistant and in the Tempest app. They were different, but really only got more different as the day went on (or perhaps the accumulation increased).

I poked at the raw weatherflow API, and saw this (as an example value returned from https://swd.weatherflow.com/swd/rest/observations/station/{{WeatherflowStationID}}?token={{WeatherflowAPIToken}})

            "precip_accum_last_1hr": 1.048692,
            "precip_accum_local_day": 4.545355,
            "precip_accum_local_day_final": 5.03573,
            "precip_accum_local_yesterday": 22.987024,
            "precip_accum_local_yesterday_final": 39.915551,
            "precip_minutes_local_day": 128,
            "precip_minutes_local_yesterday": 911,
            "precip_minutes_local_yesterday_final": 911,

The sensor for sensor.weatherflow_precipitation_yesterday reflects the value precip_accum_local_yesterday from the API, while the Tempest app uses precip_accum_local_yesterday_final. Same for the values for the current day (Tempest ios app shows the _final value).

I expect this was a concious choice, but perhaps the integration should expose both values and let the caller decide? If not, I would make it match the Tempest app. I can't find any documentation that describe the difference between the value and _valuefinal on the API doc website (https://weatherflow.github.io/Tempest/api/swagger/)

briis commented 2 years ago

You are welcome👍🏻 I will look in to this. The goal is to show the same values as the Tempest App, and I have not been observant on these numbers.

The SmartWeather Integration is being deprecated and is being replaced by a new Integration I wrote, that conforms much better to the current Home Assistant standards and is much easier to maintain going forward. The only reason I have not made an announcement yet, is that I wait for it to be merged in to HACS as a Default Integration.

But the changes I will make to fix the above (If they are also present in the new Integration) will be done here. So can I convince you to install the new Integration? You can find it here: WeatherFlow Weather. Just follow the instructions on how to add it to HACS, and install from there. Both versions can co-exist.

I will then run some tests on the numbers you show above, and make the necessary adjustments tomorrow.

robchandhok commented 2 years ago

Ah. I am already using hass-weatherflow (switch a couple days ago). The behavior exists there. I just updated to v0.1.14. Sorry for filing the issue in the wrong place...let me know if I can help test. I'm @theotherrobc in Discord.

briis commented 2 years ago

Ok, now it gets strange. I don't see the _final data points when I use the Swagger with my station id. Below are the data points I see. And I also not recall ever having seen these data points. Not sure what the difference is between your setup and mine? What is the FW version of your HUB and Tempest device?

    "outdoor_keys": [
        "timestamp",
        "air_temperature",
        "barometric_pressure",
        "station_pressure",
        "pressure_trend",
        "sea_level_pressure",
        "relative_humidity",
        "precip",
        "precip_accum_last_1hr",
        "precip_accum_local_day",
        "precip_accum_local_yesterday",
        "precip_minutes_local_day",
        "precip_minutes_local_yesterday",
        "wind_avg",
        "wind_direction",
        "wind_gust",
        "wind_lull",
        "solar_radiation",
        "uv",
        "brightness",
        "lightning_strike_last_epoch",
        "lightning_strike_last_distance",
        "lightning_strike_count",
        "lightning_strike_count_last_1hr",
        "lightning_strike_count_last_3hr",
        "feels_like",
        "heat_index",
        "wind_chill",
        "dew_point",
        "wet_bulb_temperature",
        "delta_t",
        "air_density"
    ],
    "obs": [
        {
            "timestamp": 1639553390,
            "air_temperature": 7.6,
            "barometric_pressure": 1015.2,
            "station_pressure": 1015.2,
            "sea_level_pressure": 1021.6,
            "relative_humidity": 95,
            "precip": 0.0,
            "precip_accum_last_1hr": 0.0,
            "precip_accum_local_day": 0.0,
            "precip_accum_local_yesterday": 0.817704,
            "precip_minutes_local_day": 0,
            "precip_minutes_local_yesterday": 99,
            "wind_avg": 2.4,
            "wind_direction": 261,
            "wind_gust": 3.6,
            "wind_lull": 1.7,
            "solar_radiation": 1,
            "uv": 0.0,
            "brightness": 130,
            "lightning_strike_last_epoch": 1635258810,
            "lightning_strike_last_distance": 33,
            "lightning_strike_count": 0,
            "lightning_strike_count_last_1hr": 0,
            "lightning_strike_count_last_3hr": 0,
            "feels_like": 6.1,
            "heat_index": 7.6,
            "wind_chill": 6.1,
            "dew_point": 6.9,
            "wet_bulb_temperature": 7.2,
            "delta_t": 0.4,
            "air_density": 1.25969,
            "pressure_trend": "steady"
        }
    ]
}
robchandhok commented 2 years ago

My hub firmware is 171 My Tempest firmware is 156

I dug around a bit. I think there is a user setting called "Rain Check" which I have enabled. If you look here: https://weatherflow.github.io/Tempest/api/swagger/#!/observations/getObservationsByDeviceId

You will note 21 - Precipitation Aanalysis Type (0 = none, 1 = Rain Check with user display on, 2 = Rain Check with user display off)

I wonder if that setting is OFF for your device, and ON for mine, hence the difference. This feature is discussed here: https://community.weatherflow.com/t/rain-check-and-tempest-question/15744

My suggestion for your integration is to include both values, and if you don't see _final values, leave it zero. Not sure how easy that would be to code?

briis commented 2 years ago

Rain check is actually on, in the App, but still shows 0 in the Swagger Data. Tried to switch it off and on, but it stays zero. I can still do the change, just not test it then. I will work on something the next few days.

briis commented 2 years ago

I found the reason I am not seeing these values. You are right that it has something to do with Rain Check, but I found that Rain Check only works for stations located in the US. Read more here: https://community.weatherflow.com/t/what-exactly-are-the-rain-accumulated-final-fields/6809

So I will add them as datapoints, and sensors will then only be created if these data points contain a value.

briis commented 2 years ago

Released V0.1.15, which should now give you these 3 sensors. Could you test and report back?

robchandhok commented 2 years ago

Tested V0.1.15, works as designed! Nice.

Using https://github.com/thomasloven/lovelace-template-entity-row, I displayed using this template, if you want to include something like that in your documentation.

          {% if states('sensor.weatherflow_precipitation_today_rain_checked') !=
          "unknown" %}
            {{'{:.2f}'.format(states('sensor.weatherflow_precipitation_today')
            |float) +
            ' ({:.2f} ✓)'.format(states('sensor.weatherflow_precipitation_today_rain_checked')
            |float) +
            ' inches'
            }}
          {% else %}
            {{'{:.2f} inches'.format(states('sensor.weatherflow_precipitation_today')
            |float)
            }}
          {% endif %}
briis commented 2 years ago

Could I ask you to create the example as an Item in the Discussion area. That makes it easy to point to how to use this.