Hey Gene et all,
I had some more time to experiment this weekend and I found another web service from
http://openweathermap.org/ that offers some more data than weatherunderground and requires no API key to work.
So I wrote another widget - this time in C# to get some better understanding for this language.
Also, I experimented with an approach to have a
fully scalable design which is solely based on the font-size of the topmost element (the widget <a> in this case). Every element, text and even graphic scales relative to this and makes best use of the available space without loosing the layout when scaling up or down. I gonna experiment a bit more on this and once I?m happy with it, I will most likely adapt the SunCalc to this layout as well.
The second idea I wanted to try was to also use
one color code as a base and have all
shadings and images behave relative to this as well. So you can provide any hue-value you like and everything ?scales? in relation to this - color-wise.
This is also why, I?d like to have a
popup to configure at least some settings directly on this page (I?m thinking of a color wheel as used for the z-wave lamps and setting the city name as for now). This is also where I have a problem and hope for some guidance from your side (see below).
Last not least: I added a
manual refresh icon on the right panel side (analog to other modules).
Information provided by the widget is:- Country of City
- Long/Lat (useful for SunCalc)
- Description of current weather condition
- Icon according to day/night and current weather situation
- Temperature (incl. daily min/max)
- Windspeed (incl. gust)
- Wind direction
- Pressure (incl. ground- and sea-level)
- Humidity
- Cloudiness
- Rain/Snow within the last 1/3/24-hour or since midnight
What values are displayed specifically is up to the data provided by the local station within the selected city.- Again I implemented full localization with element tooltips (currently eng/ger).
- Also you can choose between metric and imperial display.
Source and Screenshots are included below.
This leads me to the
three problems I?m hoping to get some ideas from your side:
(1) When importing the script it will not start but display an error. Yet, when I open the source for editing and just hit ?update? it shows success and works fine. No idea what is causing this?
Errors:
1. Object reference not set to an instance of an object
2. at HomeGenie.Automation.ProgramEngine.EvaluateProgramCondition (System.Object evalArguments) [0x00000] in :0
Program disabled, fix errors first.
(2) When I try to call HG.WebApp.GroupModules.UpdateModule from ?onchange? of one form element within the preferences popup the settings won?t get saved. I see them as been updated in the widget Data, though. And also this exact code works from within the json. I saw from the fibaro example, I could implement and call a webservice, yet I?d like to try without since - judging by the functions available - it should be doable this way as well, right?
see line 82ff of openweathermap.json for details on this.(3) Last thing: There seems to be a problem with the decoding of special characters within the json-feed (utf-8 in this case) of a webservice-call. You can see the ?? in the german screenshot. I tried to fix that within the C#-Part of my script, but this seems to be to late already. I left it uncommented in the source so maybe this helps at some other point of the source-code?
Program.Parameter("jkUtils.OpenWeatherMap.Weather.Description").Value = Regex.Replace(
data.weather[0].description,
@"\u(?<value>[0-9a-f]{4})",
match => {
string digits = match.Groups["value"].Value;
int number = int.Parse(digits, NumberStyles.HexNumber);
return char.ConvertFromUtf32(number);
}) ?? "";