Bug - Smartthings SmartWeather Station

Hi,
There’s a bug in the SmartWeather Sation device handler:

The wrong estimated lux is returned, it works if the code is modified so the case statements don’t use arrays. See below…

Niall
Hub v2 / Firmware 000.024.00020

Current Code:
private estimateLux(obs, sunriseDate, sunsetDate) {
def lux = 0
if (obs.dayOrNight == ‘N’) {
lux = 10
}
else {
//day
switch(obs.iconCode) {
case ‘04’:
lux = 200
break
case [‘05’, ‘06’, ‘07’, ‘08’, ‘09’, ‘10’,
‘11’, ‘12’, ‘13’,‘14’, ‘15’,‘17’,‘18’,‘19’,‘20’,
‘21’,‘22’,‘23’,‘24’,‘25’,‘26’]:
lux = 1000
break
case [‘27’, ‘28’]:
lux = 2500
break
case [‘29’, ‘30’]:
lux = 7500
break
default:
//sunny, clear
lux = 10000
}

    //adjust for dusk/dawn
    def now = new Date().time
    def afterSunrise = now - sunriseDate.time
    def beforeSunset = sunsetDate.time - now
    def oneHour = 1000 * 60 * 60

    if(afterSunrise < oneHour) {
        //dawn
        lux = (long)(lux * (afterSunrise/oneHour))
    } else if (beforeSunset < oneHour) {
        //dusk
        lux = (long)(lux * (beforeSunset/oneHour))
    }
}
lux

}

Fixed Code
private estimateLux(obs, sunriseDate, sunsetDate) {
def lux = 0
if (obs.dayOrNight == ‘N’) {
lux = 10
}
else {
//day
switch(obs.iconCode) {
case ‘04’:
lux = 200
break
case ‘05’:
case ‘06’:
case ‘07’:
case ‘08’:
case ‘09’:
case ‘10’:
case ‘11’:
case ‘12’:
case ‘13’:
case ‘14’:
case ‘15’:
case ‘16’:
case ‘17’:
case ‘18’:
case ‘19’:
case ‘20’:
case ‘21’:
case ‘22’:
case ‘23’:
case ‘24’:
case ‘25’:
case ‘26’:
lux = 1000
break
case ‘27’:
case ‘28’:
lux = 2500
break
case ‘29’:
case ‘30’:
lux = 7500
break
default:
//sunny, clear
lux = 10000
}

    //adjust for dusk/dawn
    def now = new Date().time
    def afterSunrise = now - sunriseDate.time
    def beforeSunset = sunsetDate.time - now
    def oneHour = 1000 * 60 * 60

    if(afterSunrise < oneHour) {
        //dawn
        lux = (long)(lux * (afterSunrise/oneHour))
    } else if (beforeSunset < oneHour) {
        //dusk
        lux = (long)(lux * (beforeSunset/oneHour))
    }
}
return lux

}

1 Like

Your best bet would be to file an Issue or Pull request to the GitHub.

3 Likes

I’ve now filed an issue #4098

Thanks!

1 Like

A fix for this is being commited:

3 Likes

It’s been patched here:

This is regarding the Smartweather station tile. I have a PWS and have started using this because I am trying to get as much as possible into the new app while I migrate to a V3 hub. It looks like wind speed is not displayed though when I look at the log is is collecting the information. Also the illuminance is not displaying in the tile. I am using my PWS ID and not the zip code. Any ideas?

Let me know if this discussion should be moved to another string.

Thanks,

Did you ever figure this out? Looking at getting a PWS as well, and really want wind chill visible on the tile.

Look here:

Thanks for the reply. Going to go with an Ambient Weather 2902c once I find a decent price for it.

1 Like

There used to be an Ambient Weather integration as well:

But it is used to be, as the Developer ditched SmartThings for good.

1 Like

I never could get it working in ST. I’ve since migrated my weather station to Hubitat and there is a custom driver that works. I now use node-red to tie ST and HE together.