Announcement

Collapse
No announcement yet.

Reading Jon00BBCWeather.ini file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Reading Jon00BBCWeather.ini file

    I have been using Jon00's plugins for quite a long time and am so grateful as many plugins are specific to the U.S. and don't work here in the UK .... so firstly thanks for all your hard work.

    Having recently bought a copy of HS Touch, I discovered that the weather template doesn't work, as it requires a U.S. zip code and won't work with UK postcodes.

    I had been using Jon00's BBC weather script for a long time (latest version) so decided to try and map the status's of Jon00's devices to my HS Touch interface. The problem I found was that many of the forecast elements have been concatenated / joined to read as a sentence in the status field. I wanted the discrete values to show in HS Touch. I am not that experienced in advanced programming functions within HS, but managed to figure out that the discrete values are stored in the Jon00BBCWeather.ini file. So all I needed to do was read the value from the ini file and store it as a virtual device to map into HS Touch. I searched as much as I could to try and find out how to do it and read the help file. The help file shows you how to access data in the default "settings.ini" file, but when I do my best to retrieve data from the Jon00BBCWeather.ini file, it comes back with blank values. The HS help file doesnt give an example of how to code for a different ini file ... only that you can do it. I decided to test it in two steps .. firstly get it to just show a popup box with the value, then if I managed that - to write the value to a new virtual device status. Needless to say I cant get past stage 1 LOL. If anyone can help with either steps I would be so grateful.

    The following script was what I tried just to retrieve a simple value to test. Although the script below shows the full file extension, I have tried it with just the file name, with the filename and .ini extension and also with and without "" either side of the file.

    sub main()
    dim Value
    Value = hs.GetINIsetting("Settings","LocationCode","","C:\Program Files\HomeSeer HS2\Config\Jon00Weather.ini")
    msgbox Value
    end sub

    All I get is the blank value - infering that it can't find a matching entry.

    Many many thanks,

    Jay

    #2
    Hi Jay,

    The name of the ini file is incorrect in your code.

    Try:

    PHP Code:
    sub main()
    dim Value
    Value 
    hs.GetINIsetting("Settings","LocationCode","","Jon00BBCWeather.ini")
    msgbox Value
    end sub 
    Jon

    Comment


      #3
      Thankyou Jon,

      I can't believe how fast your response was!! And once again thankyou for all your hard work in helping me with your great scripts!

      I think that was a typo and am sure that I had tried it correctly before. I am in my office at the moment so have just done a remote change to the script to fix the typo. Unfortunately as my test script was just to produce a pop up, I can't see anything as I would imagine the pop up only appears on the host PC. Is it easy to change the script to post the value to a new virtual device, as I would be able to check it straight away if I could.

      Many thanks,

      Jay

      Comment


        #4
        I just tried what I think would be the correct code and confirm that it does update the Z4 value, however I guess that it still doesn't get the data from the ini file, as the Z4 status is now "Not Found" which was the error message I had entered in the script.

        sub main()
        dim Value

        Value = hs.GetINIsetting("Settings","LocationCode","Not Found","C:\Program Files\HomeSeer HS2\Config\Jon00BBCWeather.ini")

        hs.SetDeviceString "z4", Value, True

        end sub
        Last edited by ; November 23, 2010, 09:13 AM.

        Comment


          #5
          I'm sure this will work for you:

          PHP Code:
          sub main()
          dim Value

          Value 
          hs.GetINIsetting("Settings","LocationCode","","Jon00BBCWeather.ini")
          hs.SetDeviceString "z4"ValueTrue

          end sub 
          Jon

          Comment


            #6
            Jon,

            You are a legend - I can't thank you enough. It works!!! Now I just need to set up virtual devices for each of the discrete values!

            Many thanks,

            Jay

            Comment


              #7
              FYI, I was letting you have a go at a bit of coding but you might like to know that I also store the data in the devicevalue for each house code.

              You should be able to use the devicevalue directly for many of the weather variables rather than devicestring which does contain html code. The only rub is that the value may be multiplied by 10 or 100 if the actual data is decimalised as devicevalues can only store whole numbers.
              Jon

              Comment

              Working...
              X