WeatherFlow Widget for iOS/iPadOS 14

The vast majority of credit goes to @wxkeith
I just tweaked a few lines to add some improvements.

2 Likes

Thank you to Keith and Baff for this helpful little widget, it works a great and I have 2 stations now on my iPad and iPhone.

Awesome

Hi all,

is there a possibility to get the current condition string? Actually I am trying to change the background picture related to a def. value. For testing I took e.g solar radiation that works fine. But at the end I would like to have the condition (clear, partly cloudy…) as reference to the background picture.

else if(data.obs[0].solar_radiation >= 20)
{
let fm = FileManager.iCloud()
let path = fm.documentsDirectory() + “/Pictures/image.jpg”;
w.backgroundImage = fm.readImage(path);
}

Ive tested like this in several ways but no success (data.current_conditions == “Partly Cloudy”)
How can you call for “current conditions->conditions”?

image

Greetings Chris

I haven’t tried, but perhaps:
(data.current_conditions.conditions == “Partly Cloudy”)

1 Like

The observations API doesn’t return current conditions, so you’d need a separate call to the forecast API to pull in the current conditions and forecast. It looks like the forecast API isn’t quite fully baked yet, so you may want to hold off on that for now.

I’ve made a few updates to my local copy of the widget that I’m going to push up to GitHub after I clean it up. I added a local cache of the observation data, so the widget will still have data to display, even if you don’t have internet access.

3 Likes

thx a lot for your response @wxkeith and @baff …the good thing is as soon as the API is available/accessable the ‘else if’ condition for background would work. For now I relate the changing background to brightness or solar_radiation as 1st approach.

I wish you and your families a Happy New Year

Greetings Christian

Some screenshots 4 different scenarios 0lx, <7k, 7-10k and >10k lx

2 Likes

I was wondering if dew point could be added. Either next to or in place of humidity.

Love the widget.

Again, I haven’t tried this, but I think this will work for adding Dew Point.
Find this line:

let humidityLine = w.addText(data.obs[0].relative_humidity + "%")

and change it to this:

let dewpoint = convertTemperature(data.obs[0].dew_point, data.station_units.units_temp)
let humidityLine = w.addText(data.obs[0].relative_humidity + "%  " + dewpoint["display"] + dewpoint["unit"])

I wound up doing something very similar to what you suggested. Instead of using the convertTemperature function, I wound up creating a new function for converting the dewpoint. Thanks for your reply.

Are there parameters for wind chill, heat index, daily high temperature, and daily low temperature?

wind_chill
heat_index

Here are a few others:
precip
precip_accum_last_1hr
solar_radiation
uv
brightness
feels_like
dew_point
wet_bulb_temperature
delta_t
air_density

As Keith says, you would have to do a separate API call for the forecast data. If you do, here are the variable names:
air_temp_hi
air_temp_low

So, I am finished actually until Forecast API is in place/possible.
Here the way I decided to go at the moment for changing background.

if(CONFIG_DYNAMIC_BACKGROUND) {
let bgColor = new LinearGradient()
bgColor.colors = [new Color("#000055"), new Color(temperature[“color”])]
bgColor.locations = [0.0, 2.0]
w.backgroundGradient = bgColor
}
//----------------Changing Background related to xxx(brightness)--------------------------------

else if(data.obs[0].brightness >= 15000)
{
let fm = FileManager.iCloud()
let path = fm.documentsDirectory() + “/Pictures/image_day_15000lx.jpg”;
w.backgroundImage = fm.readImage(path);
}
else if(data.obs[0].brightness >= 10000 & data.obs[0].brightness <= 15000)
{
let fm = FileManager.iCloud()
let path = fm.documentsDirectory() + “/Pictures/image_day_10000_15000lx.jpg”;
w.backgroundImage = fm.readImage(path);
}
else if(data.obs[0].brightness >= 7000 & data.obs[0].brightness < 10000)
{
let fm = FileManager.iCloud()
let path = fm.documentsDirectory() + “/Pictures/image_day_7000_10000lx.jpg”;
w.backgroundImage = fm.readImage(path);
}
else if(data.obs[0].brightness > 5000 & data.obs[0].brightness <= 7000)
{
let fm = FileManager.iCloud()
let path = fm.documentsDirectory() + “/Pictures/image_day_5000_7500lx.jpg”;
w.backgroundImage = fm.readImage(path);
}
else if(data.obs[0].brightness > 2000 & data.obs[0].brightness <= 5000)
{
let fm = FileManager.iCloud()
let path = fm.documentsDirectory() + “/Pictures/image_day_2000_5000lx.jpg”;
w.backgroundImage = fm.readImage(path);
}
else if(data.obs[0].brightness > 500 & data.obs[0].brightness <= 2000)
{
let fm = FileManager.iCloud()
let path = fm.documentsDirectory() + “/Pictures/image_day_500_2000lx.jpg”;
w.backgroundImage = fm.readImage(path);
}
else if(data.obs[0].brightness > 1 & data.obs[0].brightness <= 500)
{
let fm = FileManager.iCloud()
let path = fm.documentsDirectory() + “/Pictures/image_day_0_500lx.jpg”;
w.backgroundImage = fm.readImage(path);
}
else if(data.obs[0].brightness == 0)
{
let fm = FileManager.iCloud()
let path = fm.documentsDirectory() + “/Pictures/image_night_0lx.jpg”;
w.backgroundImage = fm.readImage(path);
}
//----------------End of changing Background------------------------------------------------------Final_version

3 Likes

I was able to install this widget, and have data flowing into it successfully. However, I do not have pictures next to any of the weather data (only the lightning bolt next to the lightning strike counter). no other icons are appearing.

Any thoughts?

Lightning is the only icon in the base code. To have others, you’ll need to insert them in the code

You can see that in here

I’m trying to add a line for UV. It does not seem to like uvLine. If I use the “lightning” routine and replace data.obs[0]. then all is fine. If I replace lightningLine I an error. Can somebody explain why?

let uvLine = w.addText(“UV: “ + data.obs[0].uv)
uvLine.font = Font.regularSystemFont(12)
uvLine.textColor = Color.white()

/Added STring Condiution
//let Condition = w.addText (":sunny: " + data.BetterForecast.BetterForecastCurrentConditions)
//UVLine.font = Font.regularSystemFont(12)
//UVLine.textColor = Color.white()

//Added Solar Radiation
// let SRLine = w.addText (":radioactive: " + data.obs[0].solar_radiation + " W/m2 ")
// SRLine.font = Font.regularSystemFont(12)
//SRLine.textColor = Color.white()

this is UV and Solar Radiation in W/m2

Should this still work the same under iOS 15? I seem to be having an issue since updating where Scriptable seems to open, then crash, but it will never open the Tempest app

It was a bug in Scriptable. Today’s Scriptable update fixed it.