Modify AQI Block

Our Davis AQ Sensor - map button

I am trying to figure out how to modify this block so when I hit the map button it loads a map from HuntRdLakewood, United States of America Air Pollution: Real-time Air Quality Index (AQI) into the popup box. Thinking maybe it would be easier to just create a new block?

https://travelingrvwx.com/pwsWD

If you modify one of the AQ information frames in …pwsWD/_my_settings/frames.php to show what you want in a full-size frame, like this for PurpleAir:

if ($purpleairhardware == true) {
$frame                = 'airqualityPU';  // copied from line 197
$frm_ttls[$frame]     = 'Air Quality PurpleAir';  // name in menu
$frm_src[$frame]      = 'https://www.purpleair.com/map?opt=1/mAQI/a10/cC0#8.5/56.10/-3.50';
# $frm_src[$frame]      = 'https://www.purpleair.com/map?opt=1/mAQI/a10/cC0#8/'.round($lat,3).'/'.round($lon,3);
$frm_hgth[$frame]     = 800; 
}

You can then add that to the popups under your Davis block in PWS_blocks.php, like this:

$blck_ppp [$script][]   = array ('show' => true,      'popup' => 'airqualityPU' ,                       'chartinfo' => 'page',   'text' => 'PurpleAir '.$map_txt  );

The frame will show on the Menu, too, but you can arrange the frames in any order. On my dashboard choose the PurpleAir Map popup to see what I mean. Note that I put a fixed lat/long in the URL because I didn’t want the map centred on mine.

If you want it popup sized you can add an entry to image_popup.php with a new $n title and then call that in PWS_blocks.php:

$blck_ppp [$script][]   = array ('show' => true,      'popup' => 'image_popup.php?nr=aq_map',           'chartinfo' => 'popup',  'text' => $map_txt );

with ?nr= the $n title.

Thanks for the info. I am anxious to try it and see if I can make it work. The map that shows now is awful and doesn’t show AQ at all, just dust. I should mention that the folks at World Air Quality were very friendly and gave me permission to use their map on my site.

Succes, as Wim would say!

BTW you could add Brian’s chart in a popup, too. Add an entry to image_popup.php:

$n      = 'aqichart';
$pop_img[$n]['url']     = '../aqichart.gif';
$pop_img[$n]['txt']     = 'aqichart';  
$pop_img[$n]['head']    = '';
$pop_img[$n]['show']    = 'other';

and add that to the popups in PWS_blocks.php, as described above. Mine is labelled “Graphs”.

Not sure what I am doing wrong but I can’t make it work like I want. I’m confused… I edit the purpleair section but then switch to the davis block. Makes no sense to me…

I’ve just proved it works by putting the URL of your map in the PurpleAir frame on my dashboard:

You don’t need the conditional I showed above, so just add a frame to frames.php, e.g.

$frame                = 'airqualityDA';  
$frm_ttls[$frame]     = 'Air Quality AirLink';  // name in menu
$frm_src[$frame]      = 'https://aqicn.org/station/united-states-of-america-huntrdlakewood';
$frm_hgth[$frame]     = 800; 

You should be able to see your map by selecting “Air Quality AirLink” from the menu.

Then open PWS_blocks.php and add

$blck_ppp [$script][]   = array ('show' => true, 'popup' => 'airqualityDA', 'chartinfo' => 'page',   'text' => $map_txt  );

in AQ_davis_c_block.php.

Then set 'show' => false for the fct_windy_popup.php line you don’t like.

If you want more of the page you can increase the height from 800.

I don’t see it in any menu…

You have to add the code to …/_my_settings/frames.php first :slightly_smiling_face:

I did that but it isn’t showing in menu options…

# ================================================#
$show   = false; // add the # on position 1 if you want to adapt and use it
#
$frame                = 'airqualityDA';  
$frm_ttls[$frame]     = 'Air Quality AirLink';  // name in menu
$frm_src[$frame]      = 'https://aqicn.org/station/united-states-of-america-huntrdlakewood';
$frm_hgth[$frame]     = 800; 
}
# ================================================#

Comment out (add # to) the line that says $show = 'false';

# ================================================#
$show   = true; 
#$show   = false; // add the # on position 1 if you want to adapt and use it
#
$frame                = 'airqualityDA';  
$frm_ttls[$frame]     = 'Air Quality AirLink';  // name in menu
$frm_src[$frame]      = 'https://aqicn.org/station/united-states-of-america-huntrdlakewood';
$frm_hgth[$frame]     = 800; 
}
# ================================================#

I can’t easily tell from here, but maybe you don’t need the } under the frame?

Making progress…going to step 2 :wink:

Add: I am done messing with it…it appears to be doing what I wanted so I am leaving it as is for now. The biggest issue I noticed is with Filezilla…I noticed that when I edit a file and re-ftp to my server using the “overwite” option the file size is not matching what I am ftp’ing. No doubt that was messing with me. Then I noticed BBEdit was not “coloring” the code, so I knew I had something wrong in the code. The key was my menu items in pws did not match what I was seeing in the code for the true/false sections. Once I figured that out the menu items showed correct. Once I had the item in the menu it was just simple editing code to make it look the way I wanted it. Watching the football game while editing the code was not a good decision on my part. But I really appreciate your help guiding me through this bitsostring.

No problem :wink:

You might want to comment DarkSky Forecast out of your menu?

Happy New Year - soon :laughing:

If you are using Windows, why use FileZilla? Just copy the file across with File Explorer.

I have a stock file of current PWS Dashboard scripts on my machine. If I need to edit one, I use Notepad++. If the edit is experimental I save that in C:\Temp. If it doesn’t work I can restore the good script from stock and work on the edit. When that works I move it to stock.

Honestly I don’t know how/why it still shows up nor how to disable it. I remember they stopped their service back in March I think, and Wim made changes to how PWS handles forecast data, but I thought he just modified something that “used” the DarkSky routines to generate a new feed for the data. I do not see a way to disable Darksky in pws, the setup forces you to select something. I do have Pirate selected in the API tab of pws.

Using an iMac M1 machine here. I like having the color coding and line numbers in BBEdit.

That’s why it still shows – I’d forgotten that :slightly_frowning_face:

Just comment out the lines in PWS_frames.php:

# this one is optionally  used if use DARKSKY as forecast
#
if ( $fct_darksky_block_used == true) {
        $frame                  = 'darkskyPP';
        $frm_ttls[$frame]       = 'DarkSky Forecast';  // name in menu
        $frm_src[$frame]        = 'https://darksky.net/forecast/'.$lat.','.$lon.'/'.$ds_page_unit.'/'.substr($locale_wu,0,2);
        $frm_frme[$frame]       = false;
        $frm_hgth[$frame]       = 2000;}