Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Previous page Next page Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Page 5 of 7
Topic:
Replacement for Weather.com xml feed
This thread has 92 replies. Displaying posts 61 through 75.
Post 61 made on Thursday November 21, 2013 at 06:28
Fischi
Long Time Member
Joined:
Posts:
January 2011
114
I've seen that the values for wind speed and pressure are also metric.
I had only to change miles/h to km/h and in. to hPa.
Next I will try to let the Pronto refresh the weather itself after wakeup.
Any ideas ?
Hope that the weather feed will work for a long time (for ever :) .

Regards, Fischi
Post 62 made on Friday November 22, 2013 at 16:54
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Are you asking us to do special coding for you such that every time your pronto wakes up, it activates the weather?

If you are so inclined, have a look at the Dev Guide's Activity.onWake() function. Note that onWake() only applies to screen activation if the unit remains docked. If undocked, onWake() applies to network reconnect, screen wakeup, etc...
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 63 made on Sunday November 24, 2013 at 17:25
MightyMo
Long Time Member
Joined:
Posts:
August 2013
15
n2hifi, I want to give you a huge thanks for posting the new weather script, along with XCF to go along with it. I was able to extract what I needed from both and implemented them into my existing program and all is working and looking better than it did before. I was really bummed out about losing my weather capabilities and you've hooked us up.. thanks again! I'm not a programmer but you've made me pretty darn proud of myself for being able to accomplish what I have. Now it's time to try programming in some script to work with the HTPC.
Post 64 made on Friday November 29, 2013 at 08:59
ScottGrimes
Long Time Member
Joined:
Posts:
April 2007
78
Hi All,
I’ve managed to get the weather module in my configuration up and working again thanks to some information published here in the forums by Mark Olson (n2hifi) and via PM with Paul Jameson (pjjameso) and Alejandro.

However, I am running into a small issue. In my weather module, I have given the user the ability to view the night forecast as well as the default day forecast for a 5 day period. The issue arises when it is currently night time and I ask it to display the night forecast. It errors out with the error ‘weatherData.dayf.day[i].part[0].icon’ has no properties… which I totally expect because at night time there is no section in the XML stream that has the day time info for Day 0 (i.e., today) anymore. See data feeds below.

Day Time Data Feed
<dayf>
    <lsup>11/25/13 8:56 AM EST</lsup>
    <daydt="Nov 25" t="Monday" d="0">
        <hi>1</hi>
        <low>-1</low>
        <sunr>7:17 AM</sunr>
        <suns>4:25 PM</suns>
        <partp="d">
            <icon>14</icon>
            <t>Few Snow Showers</t>
            <wind>
                <s>13</s>
                <gust>N/A</gust>
                <d>181</d>
                <t>S</t>
            </wind>
            <bt>Snow Showers</bt>
            <ppcp>50</ppcp>
            <hmid>80</hmid>
        </part>
        <partp="n">
            <icon>16</icon>
            <t>Snow</t>
            <wind>
                <s>21</s>
                <gust>N/A</gust>
                <d>70</d>
                <t>ENE</t>
            </wind>
            <bt>Snow</bt>
            <ppcp>100</ppcp>
            <hmid>89</hmid>
        </part>
    </day>

Night Time Data Feed
<dayf>
    <lsup>11/25/13 6:08 PM EST</lsup>
    <daydt="Nov 25" t="Monday" d="0">
        <hi>N/A</hi>
        <low>-3</low>
        <sunr>7:16 AM</sunr>
        <suns>4:25 PM</suns>
        <partp="n">
            <icon>14</icon>
            <t>Snow Shower</t>
            <wind>
                <s>21</s>
                <gust>N/A</gust>
                <d>207</d>
                <t>SSW</t>
            </wind>
            <bt>Snow Showers</bt>
            <ppcp>60</ppcp>
            <hmid>68</hmid>
        </part>
    </day>

I am attempting to fix this issue (which I did not have with the previous XML feed from 'xml.weather.com') by using the code below:

        // If it is the current day and we are asking to look at the evening data... typically the second
        // set of data for the day's forecast, but at night time there is no data in that section because
        // it is already the evening and that section simply does not exist. So we ask to simply use the
        // first section of forecasted as it already contains the night time data.
        if (i == 0 && timeOfDay == 1 && weatherData.hasOwnProperty('dayf.day[0].part[1].icon'))
        {
            var icon = "" + weatherData.dayf.day[0].part[0].icon;  // Force it to be a string
            var weatherText = "" + weatherData.dayf.day[0].part[0].t;
            var pop = weatherData.dayf.day[0].part[0].ppcp;
        }
        else
        {
            // Otherwise, use the data in the first or second parts (dictated by the timeOfDay variable) of
            // the XML stream as both the day and night time data is available.
            var icon = "" + weatherData.dayf.day[i].part[timeOfDay].icon;  // Force it to be a string
            var weatherText = "" + weatherData.dayf.day[i].part[timeOfDay].t;
            var pop = weatherData.dayf.day[i].part[timeOfDay].ppcp;
        }

Note ‘timeOfDay’ variable is either a 0 (day) or 1 (night) as set by the code in my ‘Day/Night’ icon on the weather page. By default it is set to 0.

However, it does not work. I still get the same error. Seems I can only get the ‘hasOwnProperty’ method to work on the top level of objects and not in a subsection. I’ve tried various permutations but to no avail.

    weatherData.hasOwnProperty(‘part[1]’)
    weatherData.hasOwnProperty(‘part[1].icon’)
    weatherData.dayf.day[0].part[1].hasOwnProperty(‘icon’)
    weatherData.dayf.day[0].hasOwnProperty(‘part[1]’)

I've also tried to play around with the following thinking this might help, but no go.

if ('y' in x) {
  // ......
}

Can anyone shed some light on this for me? If anyone has an alternate/more elegant solution, please chime in. I will be submitting the new version to remote central as soon as this issue is resolved. I know a number of individuals have emailed me about this weather module and are eager for a resolution.

Thanks in advance,
Scott
 
Scott Grimes
Liquid Designs
[email protected]
Post 65 made on Friday November 29, 2013 at 10:18
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Did you try

if (weatherData.dayf.day[0].part.length > 1)
// 2 elements and element 0 is day, element 1 is night
else
// 1 element and element 0 is night
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 66 made on Friday November 29, 2013 at 12:15
ScottGrimes
Long Time Member
Joined:
Posts:
April 2007
78
On November 29, 2013 at 10:18, Lyndel McGee said...
Did you try

if (weatherData.dayf.day[0].part.length > 1)
// 2 elements and element 0 is day, element 1 is night
else
// 1 element and element 0 is night

Just tried it. Length does not seem to come back as any value. I used System.print to display the value 'weatherData.dayf.day[0].part.length' and... nothing.

Any other thoughts?
 
Scott Grimes
Liquid Designs
[email protected]
Post 67 made on Friday November 29, 2013 at 14:19
FG3441
Long Time Member
Joined:
Posts:
September 2011
16
Scott,
Excited to hear that you are going to update the weather module and upload. I ve been using your configuration for couple of years. Appreciate all your hard work
Post 68 made on Saturday November 30, 2013 at 10:22
ScottGrimes
Long Time Member
Joined:
Posts:
April 2007
78
On November 29, 2013 at 10:18, Lyndel McGee said...
Did you try

if (weatherData.dayf.day[0].part.length > 1)
// 2 elements and element 0 is day, element 1 is night
else
// 1 element and element 0 is night

I think I may have solved the issue. Looks like the statement above needed the enclosed brackets '()' to make it work (see below).

if (weatherData.dayf.day[0].part.length() > 1)
 // 2 elements and element 0 is day, element 1 is night
 else
 // 1 element and element 0 is night

Currently (day time) it is giving me a value of 2... yeah. Will verify I get a value of 1 tonight.

Thanks for pointing me in the right direction Lyndel.

If all goes well, I will post the whole module this evening.
Scott Grimes
Liquid Designs
[email protected]
Post 69 made on Saturday November 30, 2013 at 12:19
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
As the 'part' is an XMLelement, you can always look for methods available on this via the E4X PDF otherwise known as the ECMA 357 specification.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 70 made on Saturday November 30, 2013 at 23:14
ScottGrimes
Long Time Member
Joined:
Posts:
April 2007
78
On November 30, 2013 at 12:19, Lyndel McGee said...
As the 'part' is an XMLelement, you can always look for methods available on this via the E4X PDF otherwise known as the ECMA 357 specification.

Thanks. I'll have a look at it. I fully admit that my prontoscript/javascript skills are fairly rudimentary. But I am always learning. Thanks for all your help on these forums.

Everything worked well this evening. I will post the new version of my weather module tomorrow... tried to tonight but ran out of time. Got roped into getting the house ready for Christmas and my 2 year old daughter has been sick with the croup and stayed curled up in my arms most of the day.

Scott

Last edited by ScottGrimes on December 1, 2013 22:28.
Scott Grimes
Liquid Designs
[email protected]
Post 71 made on Sunday December 1, 2013 at 17:34
ScottGrimes
Long Time Member
Joined:
Posts:
April 2007
78
For those interested, I have just uploaded the new version of my weather module. Hopefully it will be available soon.

If you have any issues with it, please let me know.

Enjoy!

Scott
Scott Grimes
Liquid Designs
[email protected]
Post 72 made on Sunday December 1, 2013 at 22:04
FG3441
Long Time Member
Joined:
Posts:
September 2011
16
Thanks for taking the time to fix , test it and uploading it. Appreciate the early Christmas Gift and Merry Christmas to you. Cant wait to be available to download it.
Post 73 made on Tuesday December 3, 2013 at 02:04
Fischi
Long Time Member
Joined:
Posts:
January 2011
114
Hi Scott,
Thank you very much for this script.
I've uploaded it and it runs perfect.
Let's hope it will be running for a long time.
Regards, Fischi
Post 74 made on Saturday December 14, 2013 at 17:27
FG3441
Long Time Member
Joined:
Posts:
September 2011
16
I cannot get this module to work. Scott mentioned about adding files to PS libraries from building block sections. Under PEP2 i dont have that ps libraries tab neither in building blocks nor under system properties. Am i doing something wrong or how do i access ps libraries. Under building blocks i have 3 tabs equipment and codes, graphics gallery and prontoscript module. Can someone please guide me in the right direction. Thanks in advance.
Post 75 made on Saturday December 14, 2013 at 18:24
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
Go into Tools->Options and on General Settings Tab, select 'Advanced' View.

Voila!
Lyndel McGee
Philips Pronto Addict/Beta Tester
Find in this thread:
Page 5 of 7


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse