It is currently March 28th, 2024, 4:33 pm

Creating Rainmeter Notification Application

Get help with creating, editing & fixing problems with skins
mobileqa
Posts: 32
Joined: March 26th, 2018, 1:09 pm

Re: Creating Rainmeter Notification Application

Post by mobileqa »

OKay , for the most part The "Title" would be the one that changes. So I need the app to react to new Title Entry and produce the pop-up notification.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Creating Rainmeter Notification Application

Post by jsmorley »

mobileqa wrote:OKay , for the most part The "Title" would be the one that changes. So I need the app to react to new Title Entry and produce the pop-up notification.

So we can't use the timestamp to drive this?

I'm a little confused, and I think we need to set clear groundrules first. Is what you mean to say is that if there is an entirely new "Title" at the top of the json file, we want to react to that as a "new item" and do something? Or is is that if ANY of the "Title" entries change (a bit more complicated) or what?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Creating Rainmeter Notification Application

Post by jsmorley »

What I'm saying is that I need to understand the underlying logic of the json file. If this is sorta like an RSS feed, where new "items" are added to the top, and that pushes all the rest down by one "id", so the file is added to in a chronological way and the latest "item" is "ID 1", then this won't be hard. We just have to "save" the title of the first "ID", much as I suggested we save the timestamp, and compare it to the saved variable. If they are different, then we fire off the alert.

If it is something else, where the "title" of any of the ID's can change, and a new one can "replace" an old one anywhere in the list of ID's, then this might be complicated indeed, since for any given ID, the title can be "different" without being "new". In that case, we simply MUST depend on a timestamp.

I would strongly recommend using the timestamp in any case to be honest. Who is to say you can't have an entirely new entry that uses the same "title", but has a different link, and is in fact an entirely new or updated "thing"?
mobileqa
Posts: 32
Joined: March 26th, 2018, 1:09 pm

Re: Creating Rainmeter Notification Application

Post by mobileqa »

Here We go:
This will work like a RSS feed where the new items will be added to the top; because we want to archive the entries and display the archived entries in a separate place . The latest entry will be on top , so we would definitely go the route of checking against the TimeStamp and if any changes occur fire off the notification. Does this make sense?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Creating Rainmeter Notification Application

Post by jsmorley »

Yeah, that'll work. Gimmie a bit to cobble up some stuff, and then we can talk about what kind of notification you want.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Creating Rainmeter Notification Application

Post by jsmorley »

Ok, so let's take a look first at the logic for detecting an updated item..

Test.json:

Code: Select all

[{
"id": 1,
"title": "Title 1",
"description": "description one",
"url": "",
"active": true,
"created_at": "03/22/2018 22:00",
"updated_at": "03/22/2018 22:00"
},
{
"id": 2,
"title": "Title 2",
"description": "description two",
"url": "",
"active": false,
"created_at": "03/22/2018 22:00",
"updated_at": "03/22/2018 22:00"
}
]
Skin:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
LatestTime=13166229600

[MeasureFile]
Measure=WebParser
URL=file://#CURRENTPATH#Test.json
RegExp=(?siU)"title": "(.*)".*"updated_at": "(.*)"
FinishAction=[!EnableMeasureGroup Times][!UpdateMeasureGroup Times]

[MeasureTile1]
Measure=WebParser
URL=[MeasureFile]
StringIndex=1

[MeasureTime1]
Measure=WebParser
URL=[MeasureFile]
StringIndex=2

[MeasureTestTime1]
Measure=Time
Group=Times
TimeStamp=[MeasureTime1]
TimeStampFormat=%m/%d/%Y %H:%M
Disabled=1
DynamicVariables=1
UpdateDivider=-1
IfCondition=[MeasureTestTime1:timestamp] > #LatestTime#
IfTrueAction=[!WriteKeyValue Variables LatestTime "[MeasureTestTime1:timestamp]"][!SetVariable LatestTime "[MeasureTestTime1:timestamp]"]

[MeterTitle1]
Meter=String
MeasureName=MeasureTile1
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
So what we are doing is parsing out that first updated_at: entry into the child WebParser measure [MeasureTime1] using StringIndex 2.

What we will end up with in that value is 03/22/2018 22:00.

Then we are using a Time measure, [MeasureTestTime1] to turn that date/time "string" into a timestamp.

https://docs.rainmeter.net/manual/measures/time/#TimeStampFormat

We end up with 03/22/2018 22:00 being turned into a timestamp value of 13166229600.

Then we use an IFCondition to test that value against the current value of the variable #LatestTime#. If it is "greater" then it is "newer", and we can take action.

Right now I'm just having it update the value of that #LatestTime# variable, making it reflect the current timestamp that we got from the json file. I am both setting the value of the variable, so we can use it if needed while the skin is running, and physically writing it to the skin .ini file, so it will survive a skin refresh or a restart of Rainmeter.

https://docs.rainmeter.net/manual/bangs/#SetVariable
https://docs.rainmeter.net/manual/bangs/#WriteKeyValue

Test this by changing the json file.

First, let me know if you see how this works, and what we are doing. If you have questions about this bit, let's get them out of the way first.

Then we can talk about what kind of notification you want, and I can see what alternatives work best. Be sure you tell me not only what the notification should do, but how the end-user should react to it.
mobileqa
Posts: 32
Joined: March 26th, 2018, 1:09 pm

Re: Creating Rainmeter Notification Application

Post by mobileqa »

What's the logic behind this line of code:
FinishAction=[!EnableMeasureGroup Times][!UpdateMeasureGroup Times]
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Creating Rainmeter Notification Application

Post by jsmorley »

mobileqa wrote:What's the logic behind this line of code:
FinishAction=[!EnableMeasureGroup Times][!UpdateMeasureGroup Times]
WebParser measures have a starting value of "" or an empty string. The measure is "threaded", so the skin is allowed to move on while the measure is out connecting to and retrieving data from the remote resource. We don't want to have the skin test against "" really, as it is pointless, and just generates an error in the log. So we have the WebParser measure "turn on" the test when it is done getting the information.

We also don't need it testing on each update of the skin, only when the WebParser measure has just finished getting information. So we set UpdateDivider=-1 on the test measure, and have the !FinishAction on the WebParser parent force an update.

So the net result is that the test measure is disabled until WebParser is finished the first time, and then only updated each time the WebParser measure goes out for data. How often that is should be driven by an UpdateRate option on the parent WebParser measure.
mobileqa
Posts: 32
Joined: March 26th, 2018, 1:09 pm

Re: Creating Rainmeter Notification Application

Post by mobileqa »

Thanks for the explanation I understand the sample code that you sent.

Notifications:
The user will receive the pop-up notification based on the logic we discussed with the TimeStamp (if new entry to JSON). The pop-up notification will only include the "Title" ("title": "Title 1",) element for that new entry. On the notification windows I would like a "close" button . If the user doesn't interact with the notification for about 5 sec (or whatever the min time is) then the notification will fade out.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Creating Rainmeter Notification Application

Post by jsmorley »

Ok, give me a little bit to knock something together that you can get started with.
Post Reply