It is currently April 27th, 2024, 10:08 am

Edit weather condition text?

Get help with creating, editing & fixing problems with skins
paul1965
Posts: 11
Joined: March 7th, 2024, 4:44 pm

Edit weather condition text?

Post by paul1965 »

Hello. Is it possible to edit the weather condition(s) value returned by the API? For instance, if it returns "Snow", change that to "snowing". Same for "Rain", change that to "raining"? I tried using Substitute, but that had no effect.

If the returned value can't be edited, I'd need to figure out how to edit some other static text to better match the current conditions, like "Currently, it's sunny" or "Currently, there's snow/wind" etc. Any suggestions are greatly appreciated!

Code: Select all

[MeterDisplayWeatherInfo]
Meter=String
MeasureName=MeasureCondition
MeasureName2=MeasureTemp
X=(#size#*245)
Y=(#size#*50)
W=(#size#*300)
H=(#size#*150)
FontColor=#FontColor#
FontSize=(#size#*12)
StringStyle=normal
StringEffect=SHADOW
FontFace=#FontFace#
StringAlign=left
FontEffectColor=0,0,0,50
AntiAlias=1
ClipString=1
Text=Currently, it's#CRLF#%1 and
Substitute="Snow":"Snowing","Rain":"Raining","Sunny":"test"
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Edit weather condition text?

Post by eclectic-tech »

paul1965 wrote: March 19th, 2024, 1:52 pm Hello. Is it possible to edit the weather condition(s) value returned by the API? For instance, if it returns "Snow", change that to "snowing". Same for "Rain", change that to "raining"? I tried using Substitute, but that had no effect.

If the returned value can't be edited, I'd need to figure out how to edit some other static text to better match the current conditions, like "Currently, it's sunny" or "Currently, there's snow/wind" etc. Any suggestions are greatly appreciated!

Code: Select all

[MeterDisplayWeatherInfo]
Meter=String
MeasureName=MeasureCondition
MeasureName2=MeasureTemp
X=(#size#*245)
Y=(#size#*50)
W=(#size#*300)
H=(#size#*150)
FontColor=#FontColor#
FontSize=(#size#*12)
StringStyle=normal
StringEffect=SHADOW
FontFace=#FontFace#
StringAlign=left
FontEffectColor=0,0,0,50
AntiAlias=1
ClipString=1
Text=Currently, it's#CRLF#%1 and
Substitute="Snow":"Snowing","Rain":"Raining","Sunny":"test"
Substitutions only work on the string values of Measures, so you need to add the Substitute line to the [MeasureCondition] measure in your code.
Then the meter should use the substituted values in your string text.
paul1965
Posts: 11
Joined: March 7th, 2024, 4:44 pm

Re: Edit weather condition text?

Post by paul1965 »

eclectic-tech wrote: March 19th, 2024, 4:04 pm Substitutions only work on the string values of Measures, so you need to add the Substitute line to the [MeasureCondition] measure in your code.
Then the meter should use the substituted values in your string text.
Ah, you are so right! I think the measures.inc file intimidated me a bit, but I've got it edited now and it's working as expected. Thanks!
paul1965
Posts: 11
Joined: March 7th, 2024, 4:44 pm

Re: Edit weather condition text?

Post by paul1965 »

I'm struggling to get some of the current condition substitutions to work correctly for me, especially when the condition uses a combined measurement. Single conditions like, "rain", "snow", "sunny", etc work great, but once I get to "partly cloudy" I get a display of "Partly Currently, it's cloudy and". What's the best way to get these types of conditions to display as "Currently, it's partly cloudy and" (temp is displayed on the next line)? I've tried altering the order of the substitutions, but that didn't help.

Code: Select all

Substitute="Snow Shower/Wind":"Currently, there's#CRLF#snow showers, it's windy and","Light Snow/Wind":"Currently there's#CRLF#light snow, it's windy and","Rain and Snow":"Currently it's a#CRLF#rain/snow mix and","Rain Shower":"Currently there's a#CRLF#rain shower and it's","Snow":"Currently, it's#CRLF#snowing and","Snow/Wind":"Currently there's#CRLF#snow, wind and it's","Cloudy/Wind":"Currently it's#CRLF#cloudy, windy and","Partly cloudy":"Currently, it's#CRLF#partly cloudy and","Cloudy":"Currently it's#CRLF#cloudy and","Fair":"Currently it's#CRLF#fair and ","Clear":"Currently it's#CRLF#clear and","Sunny":"Currently it's#CRLF#sunny and"
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Edit weather condition text?

Post by eclectic-tech »

Substitution will replace anything it finds that match the text inside quotation marks with the new text and will do it in the order of the substitutions. That can lead to undesirable results like you are seeing.

One solution is to use RegExpSubstitution and quantify what is to be substituted using PCRE coding. By specifying the beginning ^ and end $ of the string to substitute, single reoccurrences of a word will not be substituted.

It is always a good idea to simply your substitutions, so I suggest a few changes. Try something like this:

Code: Select all

[@CurrentCondition]
Measure=Webparser

... {Current Measure Code} ...

RegExpSubstitute=1
Substitute="^Snow$":"it's#CRLF#snowing,","^Cloudy$":"it's#CRLF#cloudy,","^Fair$":"it's#CRLF#fair,","^Clear$":"it's#CRLF#clear,","^Sunny$":"it's#CRLF#sunny,","^Snow Shower/Wind$":"there's#CRLF#snow showers, wind,","^Light Snow/Wind$":"there's#CRLF#light snow, wind,","^Rain and Snow$":"it's a#CRLF#rain/snow mix,","^Rain Shower$":"there's a#CRLF#rain shower,","^Snow/Wind$":"there's#CRLF#snow, wind,","^Cloudy/Wind$":"it's#CRLF#cloudy, windy,","^Partly cloudy$":"it's#CRLF#partly cloudy,"

[Meter]
Meter=String
MeasureName=@CurrentCondition
Text="Currently %1 and it's#CRLF#[@CurrentTemperature]°"
Didn't test, but this should get you close.

EDIT: Corrected Substitution into proper single-line format...
paul1965
Posts: 11
Joined: March 7th, 2024, 4:44 pm

Re: Edit weather condition text?

Post by paul1965 »

eclectic-tech wrote: March 28th, 2024, 2:10 pm Substitution will replace anything it finds that match the text inside quotation marks with the new text and will do it in the order of the substitutions. That can lead to undesirable results like you are seeing.

Didn't test, but this should get you close.
Thank you for this, I will give it a shot!