It is currently April 30th, 2024, 3:59 pm

RegExp Index Issues

Get help with creating, editing & fixing problems with skins
User avatar
spoonwzd
Posts: 17
Joined: November 29th, 2017, 6:24 pm

RegExp Index Issues

Post by spoonwzd »

It's official - RegExp is driving me mad. I cannot get the index to to work when parsing the string, even though RainRegExp says it's fine.

The debug log in Rainmeter never shows the WebParser fetching data for this skin.

The WebParser:

Code: Select all

[MeasurePowerwallStats]
Measure=WebParser
http://internal.site/aggregates
UpdateRate=1
RegExp="(?siU)"site".*instant_power": (.*),.*"battery".*instant_power": (.*),.*"load".*instant_power": (.*),.*"solar".*instant_power": (.*),"
The output from the /aggregates URL:

Code: Select all

{"site": {"last_communication_time": "2024-04-14T20:33:26.622161278+01:00", "instant_power": 2323.889892578125, "instant_reactive_power": -1914.050048828125, "instant_apparent_power": 3010.6563773113858, "frequency": 49.95000076293945, "energy_exported": 510477.76861479547, "energy_imported": 61261928.262598604, "instant_average_voltage": 249.6699981689453, "instant_average_current": 0, "i_a_current": 0, "i_b_current": 0, "i_c_current": 0, "last_phase_voltage_communication_time": "0001-01-01T00:00:00Z", "last_phase_power_communication_time": "0001-01-01T00:00:00Z", "last_phase_energy_communication_time": "0001-01-01T00:00:00Z", "timeout": 1500000000, "num_meters_aggregated": 1, "instant_total_current": 0}, "battery": {"last_communication_time": "2024-04-14T20:33:26.686884+01:00", "instant_power": 0, "instant_reactive_power": 350.00000000000006, "instant_apparent_power": 350.00000000000006, "frequency": 49.976, "energy_exported": 8441345, "energy_imported": 9591727, "instant_average_voltage": 249.5, "instant_average_current": -0.30000000000000004, "i_a_current": 0, "i_b_current": 0, "i_c_current": 0, "last_phase_voltage_communication_time": "0001-01-01T00:00:00Z", "last_phase_power_communication_time": "0001-01-01T00:00:00Z", "last_phase_energy_communication_time": "0001-01-01T00:00:00Z", "timeout": 1500000000, "num_meters_aggregated": 1, "instant_total_current": -0.30000000000000004}, "load": {"last_communication_time": "2024-04-14T20:33:26.622161278+01:00", "instant_power": 2286.527063243744, "instant_reactive_power": -1466.1998038447596, "instant_apparent_power": 2716.237816491861, "frequency": 49.95000076293945, "energy_exported": 0, "energy_imported": 96829884.66837211, "instant_average_voltage": 249.6699981689453, "instant_average_current": 9.158197140276782, "i_a_current": 0, "i_b_current": 0, "i_c_current": 0, "last_phase_voltage_communication_time": "0001-01-01T00:00:00Z", "last_phase_power_communication_time": "0001-01-01T00:00:00Z", "last_phase_energy_communication_time": "0001-01-01T00:00:00Z", "timeout": 1500000000, "instant_total_current": 9.158197140276782}, "solar": {"last_communication_time": "2024-04-14T20:33:26.663190601+01:00", "instant_power": 0.4399999976158142, "instant_reactive_power": 114.41000366210938, "instant_apparent_power": 114.41084973883282, "frequency": 49.95000076293945, "energy_exported": 37285848.73599931, "energy_imported": 57032.56161101488, "instant_average_voltage": 249.97000122070312, "instant_average_current": 0, "i_a_current": 0, "i_b_current": 0, "i_c_current": 0, "last_phase_voltage_communication_time": "0001-01-01T00:00:00Z", "last_phase_power_communication_time": "0001-01-01T00:00:00Z", "last_phase_energy_communication_time": "0001-01-01T00:00:00Z", "timeout": 1500000000, "num_meters_aggregated": 1, "instant_total_current": 0}}
RainRegExp outputs 4 string indexes and their values as expected, but the Rainmeter skin displays all zeros as if the indexes aren't functioning.

What am I doing wrong? I'm running out of hair :/
User avatar
SilverAzide
Rainmeter Sage
Posts: 2617
Joined: March 23rd, 2015, 5:26 pm

Re: RegExp Index Issues

Post by SilverAzide »

spoonwzd wrote: April 14th, 2024, 7:38 pm It's official - RegExp is driving me mad. I cannot get the index to to work when parsing the string, even though RainRegExp says it's fine.

The debug log in Rainmeter never shows the WebParser fetching data for this skin.

The WebParser:

Code: Select all

[MeasurePowerwallStats]
Measure=WebParser
http://internal.site/aggregates
UpdateRate=1
RegExp="(?siU)"site".*instant_power": (.*),.*"battery".*instant_power": (.*),.*"load".*instant_power": (.*),.*"solar".*instant_power": (.*),"
The output from the /aggregates URL:
...

RainRegExp outputs 4 string indexes and their values as expected, but the Rainmeter skin displays all zeros as if the indexes aren't functioning.

What am I doing wrong? I'm running out of hair :/
There's nothing wrong with your regexp... your WebParser measure is missing the URL= option in front of the URL, as in URL=http://internal.site/aggregates. If you look at your Rainmeter About screen for the skin, the [MeasurePowerwallStats] measure should be returning a big chunk of JSON, but it's blank, thus the zeroes.

Also, your UpdateRate is really high... once per second? You sure you want that?
Gadgets Wiki GitHub More Gadgets...
User avatar
spoonwzd
Posts: 17
Joined: November 29th, 2017, 6:24 pm

Re: RegExp Index Issues

Post by spoonwzd »

Thanks, that instantly fixed it. I must have accidentally removed URL= when pasting in the new URL!

Yes, I want one second updates. I use it to plot a live graph which also updates every second.

Thanks again!
User avatar
Yincognito
Rainmeter Sage
Posts: 7185
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: RegExp Index Issues

Post by Yincognito »

If your Update value is 1000 ms aka 1 second, having an UpdateRate of 1 would poll the address every second, which is seriously overkill and prone to malfunction if it's your site (or even a local file), and the same and subject to banning if it's a typical online site. Just saying...
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
spoonwzd
Posts: 17
Joined: November 29th, 2017, 6:24 pm

Re: RegExp Index Issues

Post by spoonwzd »

I've been polling this local device every 1 second for years. It's fine ;)
User avatar
Yincognito
Rainmeter Sage
Posts: 7185
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: RegExp Index Issues

Post by Yincognito »

spoonwzd wrote: April 14th, 2024, 9:05 pm I've been polling this local device every 1 second for years. It's fine ;)
Alright then, if you say so. Having it local is a big plus, since you probably know that WebParser does need a bit of time to retrieve data, it doesn't happen instantaneously. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth