more G-Labs products

Author Topic: HG Smart control Weather update  (Read 1182 times)

January 26, 2015, 03:29:54 PM
Read 1182 times

Gaxil

  • *
  • Information
  • Newbie
  • Posts: 2
Hi,

First, thank you very much for this great software, it's exactly what I was looking for!
I've installed a Raspberry pi server for my X10 devices and an HG smart control on another Pi and it's working great so far. I just have a question about the update of the weather information on the smart control. I've dig a bit in the code and as far as I can tell, there is no way of updating the status/temperature with the current code as the data looks to be loaded just once. As I'm not really confortable with Json.net, I wonder if there is an easy way to update that information? I can modify the code is necessary, but so far, I've not found any way of doing this, any help is welcome ...

Thanks in advance  :)

January 26, 2015, 04:04:54 PM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
The reason the Smart Control app is not updating weather info, is because the Weather program in HG is not raising any event when updating data but it just updates parameters internally.
So to make it send events when updating data, you can add a Program.RaiseEvent instruction in the Weather app.
Open the Weather app in HG program editor and add this at line 80, before the Program.Notify instruction:

Code: [Select]
       
        Program.RaiseEvent("Conditions.Updated", DateTime.Now.ToString(), "Weather Underground");

no modification is needed from the smartcontroll software side.

Cheers,
g.

January 26, 2015, 04:36:41 PM
Reply #2

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Well it was too good to be true =)
All parameters have to be sent in order to be updated. So remove that line of code I said before and change this piece of code starting at line 58:

Code: [Select]
        Program.Parameter("Conditions.City").Value = city;
        Program.Parameter("Conditions.Country").Value = country;
        Program.Parameter("Conditions.CountryCode").Value = country_iso3166;
        Program.Parameter("Conditions.TemperatureC").Value = temperaturec;
        Program.Parameter("Conditions.TemperatureF").Value = temperaturef;
        Program.Parameter("Conditions.DisplayLocation").Value = display_location;
        Program.Parameter("Conditions.Description").Value = weather_text;
        Program.Parameter("Conditions.IconUrl").Value = icon_url;
        Program.Parameter("Conditions.Status").Value = icon; // eg. cloudy, sunny, etc..
        Program.Parameter("Conditions.WindDirection").Value = wind_dir;
        Program.Parameter("Conditions.WindKph").Value = wind_kph;
        Program.Parameter("Conditions.PressureMb").Value = pressure_mb;
        Program.Parameter("Conditions.FeelsLikeC").Value = feelslike_c;
        Program.Parameter("Conditions.FeelsLikeF").Value = feelslike_f;
        Program.Parameter("Conditions.UV").Value = UV;
        Program.Parameter("Conditions.PrecipitationHourMetric").Value = precip_1hr_metric;

to this:

Code: [Select]
        Program.RaiseEvent("Conditions.City", city, "");
        Program.RaiseEvent("Conditions.Country", country, "");
        Program.RaiseEvent("Conditions.CountryCode", country_iso3166, "");
        Program.RaiseEvent("Conditions.TemperatureC", temperaturec, "");
        Program.RaiseEvent("Conditions.TemperatureF", temperaturef, "");
        Program.RaiseEvent("Conditions.DisplayLocation", display_location, "");
        Program.RaiseEvent("Conditions.Description", weather_text, "");
        Program.RaiseEvent("Conditions.IconUrl", icon_url, "");
        Program.RaiseEvent("Conditions.Status", icon, ""); // eg. cloudy, sunny, etc..
        Program.RaiseEvent("Conditions.WindDirection", wind_dir, "");
        Program.RaiseEvent("Conditions.WindKph", wind_kph, "");
        Program.RaiseEvent("Conditions.PressureMb", pressure_mb, "");
        Program.RaiseEvent("Conditions.FeelsLikeC", feelslike_c, "");
        Program.RaiseEvent("Conditions.FeelsLikeF", feelslike_f, "");
        Program.RaiseEvent("Conditions.UV", UV, "");
        Program.RaiseEvent("Conditions.PrecipitationHourMetric", precip_1hr_metric, "");

g.

January 26, 2015, 06:25:40 PM
Reply #3

Gaxil

  • *
  • Information
  • Newbie
  • Posts: 2
Thank you very very much, it works like a charm!

I've also changed the parameter LastUpdated and set it as event as I've modified the smart control app to display also the last updated time on the client side.

From this
Code: [Select]
Program.Parameter("Conditions.LastUpdated").Value = last_updated;to this
Code: [Select]
Program.RaiseEvent("Conditions.LastUpdated", last_updated, "");
And once again, thank you for the help! You're the best!