It is currently April 19th, 2024, 11:19 am

"Refreshing Skin" every minute appearing in Logfile

Get help with creating, editing & fixing problems with skins
emp00
Posts: 83
Joined: October 7th, 2022, 8:08 pm

"Refreshing Skin" every minute appearing in Logfile

Post by emp00 »

Dear Team, I'm using a skin/meter beginning code as seen below.

Problem: In the rainmeter logfile I get a notification every minute saying "Refreshing Skin". That's not needed/desired. Can I switch off logging these refresh events? Thanks for helping!

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=5,5,5,200
DynamicWindowSize=1

[cUpdate]
Measure=Calc
Formula= (cUpdate+1) % 61
IfEqualValue=60
IfEqualAction=!Refresh
User avatar
SilverAzide
Rainmeter Sage
Posts: 2603
Joined: March 23rd, 2015, 5:26 pm

Re: "Refreshing Skin" every minute appearing in Logfile

Post by SilverAzide »

emp00 wrote: October 8th, 2022, 5:16 pm Dear Team, I'm using a skin/meter beginning code as seen below.

Problem: In the rainmeter logfile I get a notification every minute saying "Refreshing Skin". That's not needed/desired. Can I switch off logging these refresh events? Thanks for helping!
Why in the world are you refreshing the skin every minute in the first place? The whole point of using the modulus operator in your formula is you don't have to do that.
Gadgets Wiki GitHub More Gadgets...
emp00
Posts: 83
Joined: October 7th, 2022, 8:08 pm

Re: "Refreshing Skin" every minute appearing in Logfile

Post by emp00 »

SilverAzide wrote: October 8th, 2022, 6:53 pm Why in the world are you refreshing the skin every minute in the first place? The whole point of using the modulus operator in your formula is you don't have to do that.
Sorry, but this code is not from myself - I'm only modifying an existing skin to my needs. The whole posted section was created by the original author.

What's your suggestion, shall I delete the whole [cUpdate] section? This Skin pulls data via an api call (Webparser). The pulled data changes every 5 minutes but since the skin does not know the start of the 5 minute intervals the original author chose to update = refresh the meter every minute. Can this be achieved in a better way?

This is the WebParser section - this should only be done max once per minute (in order to avoid uneccesaary network traffic)

Code: Select all

[MeasureSite]
Measure=WebParser
UpdateRate=600
URL=#NightScoutURL#pebble#NightScoutToken#
RegExp=(?siU)now":(.*)}],.*sgv":"(.*)",.*trend":(.*),.*direction":"(.*)",.*datetime":(.*),.*bgdelta":(.*),
; Output StringIndex
;	1 - Current Time
;	2 - Glucose
;	3 - Delta [Not used]
;	4 - Direction (Text)
;	5 - Glucose Timestamp
;	6 - BG Delta
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: "Refreshing Skin" every minute appearing in Logfile

Post by balala »

emp00 wrote: October 8th, 2022, 7:11 pm What's your suggestion, shall I delete the whole [cUpdate] section? This Skin pulls data via an api call (Webparser). The pulled data changes every 5 minutes but since the skin does not know the start of the 5 minute intervals the original author chose to update = refresh the meter every minute. Can this be achieved in a better way?
First of all, SilverAzide is perfectly right when he asks:
SilverAzide wrote: October 8th, 2022, 6:53 pm Why in the world are you refreshing the skin every minute in the first place?
The refresh should be avoided as much as possible, especially on a skin using WebParser measures (well, in fact, there are less than extremely few cases when such a frequent refresh is needed, no matter if the skin uses or not WebParser measures).
However since you say that:
emp00 wrote: October 8th, 2022, 7:11 pm the original author chose to update = refresh the meter every minute.
I'm not entirely sure you realize the difference between the update and the refresh. Please let us know if you need explanation about these terms.
Now to answer your original question:
emp00 wrote: October 8th, 2022, 5:16 pm Can I switch off logging these refresh events?
Yep, you can, even if it's not entirely what is recommended. To do this, you have to uncheck the Notice checkbox in the log:
Log.png
emp00 wrote: October 8th, 2022, 7:11 pm This is the WebParser section - this should only be done max once per minute (in order to avoid uneccesaary network traffic)
I let SilverAzide to answer, but I think you should use the UpdateRate option on the [MeasureSite] measure.
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2603
Joined: March 23rd, 2015, 5:26 pm

Re: "Refreshing Skin" every minute appearing in Logfile

Post by SilverAzide »

emp00 wrote: October 8th, 2022, 7:11 pm Sorry, but this code is not from myself - I'm only modifying an existing skin to my needs. The whole posted section was created by the original author.

What's your suggestion, shall I delete the whole [cUpdate] section? This Skin pulls data via an api call (Webparser). The pulled data changes every 5 minutes but since the skin does not know the start of the 5 minute intervals the original author chose to update = refresh the meter every minute. Can this be achieved in a better way?

This is the WebParser section - this should only be done max once per minute (in order to avoid uneccesaary network traffic)

Code: Select all

[MeasureSite]
Measure=WebParser
UpdateRate=600
URL=#NightScoutURL#pebble#NightScoutToken#
RegExp=(?siU)now":(.*)}],.*sgv":"(.*)",.*trend":(.*),.*direction":"(.*)",.*datetime":(.*),.*bgdelta":(.*),
; Output StringIndex
;	1 - Current Time
;	2 - Glucose
;	3 - Delta [Not used]
;	4 - Direction (Text)
;	5 - Glucose Timestamp
;	6 - BG Delta
The WebParser measure already has its own built-in timer. That's what UpdateRate is for. So this measure as you have it is going to hit the website every 600 seconds (assuming the skin's update rate is set to Update=1000 in the [Rainmeter] section), so that means once every 10 minutes. If you want it to call the website every 5 minutes, just set UpdateRate=300. Adjust the value as needed.

So, Yes, definitely get rid of that [cUpdate] stuff. If you just want a loop, just use a Loop measure to count from some start to some end value, that's exactly what it is for. And avoid [!Refresh] bangs; they should only be used if you actually need the entire skin reloaded from scratch, not for something like restarting a loop or timer.
Gadgets Wiki GitHub More Gadgets...
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: "Refreshing Skin" every minute appearing in Logfile

Post by balala »

SilverAzide wrote: October 8th, 2022, 7:41 pm The WebParser measure already has its own built-in timer. That's what UpdateRate is for. So this measure as you have it is going to hit the website every 600 seconds (assuming the skin's update rate is set to Update=1000 in the [Rainmeter] section), so that means once every 10 minutes. If you want it to call the website every 5 minutes, just set UpdateRate=300. Adjust the value as needed.
To add something for emp00: here are some details about how the WebParser measures can and must be updated.
emp00, recommend to read carefully the above description, as well as this one, to properly understand the details.
emp00
Posts: 83
Joined: October 7th, 2022, 8:08 pm

Re: "Refreshing Skin" every minute appearing in Logfile

Post by emp00 »

Thanks to both of you for the explanation and guiding me.

I have corrected the code according to your recommendation @SilverAzide and now it works as desired. However, I set the Webparser to "UpdateRate=60" (with default Update=1000) thus calling the api every 1 minute.

As mentioned, it would theoretically be sufficient to call the api every 5 minutes (since the update interval is 5 minutes) BUT the skin has an independent invterval since it's started "anytime" and if I'm unlucky I see the data with a 5 minute delay which is not preferred. Therefore I chose calling the api every minute.

If there's any solution to synchronize the skin with the server update interval in order to increase the Webparser interval to 5 minutes, I'd be happy to learn + implement. Actually the "Glucose Timestamp" returns the last data update timestamp (server timestamp). This can probably be used to synchronize my skin ... but how? Is there an example I could have a glimpse at?

The server timestamp returns the "datetime" (=Glucose Timestamp) in the following format:
"datetime":1665259833834
User avatar
SilverAzide
Rainmeter Sage
Posts: 2603
Joined: March 23rd, 2015, 5:26 pm

Re: "Refreshing Skin" every minute appearing in Logfile

Post by SilverAzide »

emp00 wrote: October 8th, 2022, 8:09 pm Thanks to both of you for the explanation and guiding me.

I have corrected the code according to your recommendation @SilverAzide and now it works as desired. However, I set the Webparser to "UpdateRate=60" (with default Update=1000) thus calling the api every 1 minute.

As mentioned, it would theoretically be sufficient to call the api every 5 minutes (since the update interval is 5 minutes) BUT the skin has an independent invterval since it's started "anytime" and if I'm unlucky I see the data with a 5 minute delay which is not preferred. Therefore I chose calling the api every minute.

If there's any solution to synchronize the skin with the server update interval, I'd be happy to learn + implement. Actually the "Glucose Timestamp" returns the last data update timestamp (server timestamp). This can probably be used to synchronize my skin ... but how? Is there an example I could have a glimpse at?
In theory, you could call the API one time (the first time the skin loads). Once you have the website glucose timestamp, you would use a Time measure to convert that into a timestamp that you could use (i.e., seconds). The difference between "now" (a timestamp you'd have from another Time measure) and the glucose timestamp is your delta. When the delta interval gets to ~5 minutes or so, you'd use an IfCondition to manually force the WebParser to call the website again, and the loop would continue... You'd probably need to add some code to handle failures and the like, but hopefully you get the idea.

Since you are dealing with something important like glucose monitoring instead of trivia like weather, I'd just call the website every minute like you are doing. That way you don't have to worry about calling the site too early or too late, and you'll never be more than 60 seconds off at the max.
Gadgets Wiki GitHub More Gadgets...
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: "Refreshing Skin" every minute appearing in Logfile

Post by balala »

SilverAzide wrote: October 8th, 2022, 8:16 pm Since you are dealing with something important like glucose monitoring instead of trivia like weather, I'd just call the website every minute like you are doing. That way you don't have to worry about calling the site too early or too late, and you'll never be more than 60 seconds off at the max.
Just have to be sure the user isn't banned. This might be a problem when the site is called so frequently.
emp00
Posts: 83
Joined: October 7th, 2022, 8:08 pm

Re: "Refreshing Skin" every minute appearing in Logfile

Post by emp00 »

Banning is not a problem since it's my own server (running in the cloud) and I'm using this skin already for a few years calling every 1 minute without issues. However, still I'd like to improve the code to save some network traffic, just for the sake of improvement and avoiding the five times too frequent = unnecessary api calls.

Actually the skin already has the following measures implemented:
Image

Both [MeasureCurrentTime] and and [MeasureGlucoseTime] are server timestamps and [MeasureTimeDifference] is the calculated time difference in milliseconds. However, this is all "server time".

How could I use the [MeasureGlucoseTime] which is the server timestamp of the latest value updated on server-side to accordingly synchronize the skin update interval of the Webparser? Of course I would add e.g. +10 extra seconds in order to be sure to call slightly after the next update. This could enable the skin calling the api every 5 instead of every 1 minute... Many thanks for your concrete coding ideas or reference code examples!