It is currently July 4th, 2022, 7:00 am

WebParser - two urls that can switch, how to handle dynamically?

Get help with installing and using Rainmeter.
Posts: 1
Joined: February 11th, 2022, 12:05 am

WebParser - two urls that can switch, how to handle dynamically?

Post by krel »

I figure there's probably an easy way to handle this, I'm just new to rainmeter scripting so I could use a pointer or two. I am reading the battery status of a couple logitech devices using LGSTray - - and apparently the device info isn't in a consistent order. Here's my two webparser readers.

Code: Select all


And, here's the xml I'm parsing.

Code: Select all

<xml><device_id>dev00000000</device_id><device_name>G915 Wireless RGB Mechanical Gaming Keyboard</device_name><device_type>Keyboard</device_type><battery_percent>99.00</battery_percent><mileage>34.00</mileage><charging>False</charging></xml>

<device_id>dev00000001</device_id><device_name>G502 LIGHTSPEED Wireless Gaming Mouse</device_name><device_type>Mouse</device_type><battery_percent>68.00</battery_percent><mileage>17.00</mileage><charging>True</charging></xml>
The problem is that the device order can switch - my original order was with the mouse as dev0 and the kbd as dev1. How do I dynamically grab each of these and then use the correct one later in my script? Obviously I'll have to grab the device_name, not a big deal, but when I use it further along like this, I'm not sure how to do this correctly.

Code: Select all

User avatar
Posts: 858
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: WebParser - two urls that can switch, how to handle dynamically?

Post by CyberTheWorm »

I would make the webparser [Dev0Batt] and [Dev1Batt] and grab the device name, then do a IF statement on the device name to update your measure.

Give it a shot and post your skin to have use look at if it it's still not working.
The only source of knowledge is experience. Albert Einstein
Deviant Art Page