KurtSanders / STAmbientWeather

Hubitat Integration for Ambient Weather Station
Apache License 2.0
40 stars 79 forks source link

Why does the App convert numbers < 0.1 to 0.1? #9

Closed tedpearson closed 5 years ago

tedpearson commented 5 years ago

https://github.com/KurtSanders/STAmbientWeather/blob/4630618c3fa29f45175dc60e5e6e8184b99ed382/smartapps/kurtsanders/ambient-weather-station.src/ambient-weather-station.groovy#L632

This just bit me; my PWS has 0.01 daily rain right now so it's reporting 0.1 as the dailyrainin state. Does this try block fix some other weird issue you were having?

Example: 177392ce-eae3-41e7-a490-6ac495f0e0a0 9:17:54 PM: debug dailyrainin: Converting number '0.01'<0.1 -> 0.1}

tedpearson commented 5 years ago

For the moment, i've simply removed the whole try block from my local smartapp.

KurtSanders commented 5 years ago

All SmartThings devices force a 'round down' on ALL displayed numeric values in the devices' Tile less than 0.1 to 0. Therefore, when an Ambient sensor reports a sensor that is below 0.1, I choose to round the numeric value up to .1 do it would report a value greater than zero.

The groovy 'Try block' insures that in the numeric round up conversion, the application does not cause an unhandled exception.

If you wish a different result, you can eliminate that block. You are the first to notice the rounding up behavior, I could, in a future release, make a SmartApp preference option to allow one to select the rounding behavior (up/down) they desire.

tedpearson commented 5 years ago

Interesting, Kurt.

I'm using this primarily to export metrics to influxdb, which I would prefer to be accurate even if it screws up the ST tile displays. So I removed the whole block locally so as to not ever round up.

It's disappointing that ST forces the round down on numbers. I'd love it if this could support both the ST tiles and also accurate metrics, but the only obvious way I can think of is exposing multiple states (one for ST and one for a more accurate version). That becomes a too long list very quickly. So maybe just forking it without that block is best for me?

Thanks for your work on this whole integration. It's awesome.

KurtSanders commented 5 years ago

Dear Ted,

How are you doing the import, perhaps I can assist in a more efficient manner than using SmartThings as a go between!

tedpearson commented 5 years ago

I'm using a modified version of the InfluxDB Logger: https://github.com/tedpearson/SmartThings/tree/master/smartapps/influxdb-logger (forked from https://github.com/codersaur/SmartThings)

I certainly could write or find something (haven't searched hard yet) to go directly from ambient weather to influx, though i'm already scraping my ecobee thermostat information the same way so keeping everything in one place makes things a bit easier.

KurtSanders commented 5 years ago

OK... I get it....I could add the real Ambient Weather values in next minor update, but leave the displayed Tile values as is as to not change what existing users are expecting.

Are these the numeric fields that you import that I am rounding up. I would add '_real' as a suffix to the existing variables but these would not be displayed, but accessible from the Influxdb-logger APP.

For example,

windspeedmph_real, windgustmph_real, maxdailygust_real, tempf_real, hourlyrainin_real, eventrainin_real, dailyrainin_real, weeklyrainin_real, monthlyrainin_real, totalrainin_real, baromrelin_real, baromabsin_real, humidity_real, tempinf_real, humidityin_real, solarradiation_real, feelsLike_real, dewPoint_real,

tedpearson commented 5 years ago

I'm currently pulling in these (I picked the ones I was most interested in):

['temperature', 'dewPoint', 'feelsLike', 'monthlyrainin', 'dailyrainin', 'winddir', 'windspeedmph', 'windgustmph', 'baromrelin', 'solarradiation']

If you feel like adding the _real versions I would be happy to use them.

Thanks!

KurtSanders commented 5 years ago

I might have something for you to test shortly. These new "_real" variables are available from SmartApps, like I show below from WebCore. You will need to update your Ambient Weather Station SmartApp and DTH to expose these _real attributes.

image

KurtSanders commented 5 years ago

Ok, new files have been loaded in the github for you. The new version creates those _real variables for App access. The displayed value in the device will stay rounded since the device is incapable of showing the real data when the value is less then 0.1 and GT 0. So, hopefully your APP can access these _real variables and execute as you desire.

Please let me know if this works for you! You need to update SmartApp and DTH.

tedpearson commented 5 years ago

Updated and working just perfectly. Thanks Kurt!

KurtSanders commented 5 years ago

Glad to hear and happy to help!