Zitat von SebastianFey
Beitrag anzeigen
Ankündigung
Einklappen
Keine Ankündigung bisher.
Vorstellung meiner smartVisu
Einklappen
X
-
Mit freundlichen Grüßen
Niko Will
Logiken und Schnittstelle zu anderen Systemen: smarthome.py - Visualisierung: smartVISU
- Gira TS3 - iPhone & iPad - Mobotix T24 - ekey - Denon 2313 - Russound C5 (RIO over TCP Plugin) -
-
Danke für die Infos!
Geplant hab ich die "Realtime"-Fähigkeit ab Anfang Septempter anzugehen (nach meinen Urlaub). Hab mir auch schon einen Überblick verschafft und erste erfolgreiche Tests gemacht.
Das Gerüst bleibt aber so bestehen, d. h. jeder der jetzt sein Haus damit macht, wird das auch so verwenden können.
GrussJoin smartVISU on facebook. Web: smartvisu.de.
Dir gefällt smartVISU? Bitte spenden für die Weiterentwicklung.
Kommentar
-
weather-app
Servus,
bei mir funktioniert das wetter leider nicht. Nach einigen Recherchen bei Google & Co. scheint die Google-Weather-API in naher Zukunft abgestellt zu werden.
Ich habe daher das google-weather plugin für weather-underground angepasst. Bei Weather Forecast & Reports - Long Range & Local | Wunderground | Weather Underground kann man sich einen API key organisieren (für lau). Den key dann im file unten anpassen. Viel Spass
PHP-Code:<?
/**
* -----------------------------------------------------------------------------
* @package smartVISU
* @author Florian Meister
* @copyright 2012
* @license GPL <http://www.gnu.de>
* -----------------------------------------------------------------------------
*/
// get config-variables
require_once '../../../config.php';
// init parameters
$request = array_merge($_GET, $_POST);
$location = $request['location'];
$lang = $request['lang'];
// Anstelle einer Stadt bzw. einer PLZ kann auch kommagetrennt
// Längen- und Breitengrad eines Ortes angegeben werden,
// z.B. http://www.google.de/ig/api?weather=,,,48187575,11513672&hl=de
// für München
if($lang == "de")
$wlang="DL";
else
$wlang=strtoupper($lang);
$current_url ="http://api.wunderground.com/api/API-KEY-HIER-REIN/conditions/lang:" . $wlang . "/q/" . $location . ".json";
$forecast_url ="http://api.wunderground.com/api/API-KEY-HIER-REIN/forecast/lang:" . $wlang . "/q/" . $location . ".json";
// get contents
$current_json_string = mb_convert_encoding(file_get_contents($current_url), "UTF-8", "ISO-8859-1");
$current_parsed_json = json_decode($current_json_string);
// get contents
$forecast_json_string = mb_convert_encoding(file_get_contents($forecast_url), "UTF-8", "ISO-8859-1");
$forecast_parsed_json = json_decode($forecast_json_string);
//$location = $parsed_json->{'location'}->{'city'};
//echo "Current temperature in ${location} is: ${temp_f}\n";
// today
//$weather['city'] = (string)$forecast_parsed_json->{'forecast'}->{'fcttext_metric'};
if (config_lang == "de")
$weather['now_temp'] = (int)$current_parsed_json->{'current_observation'}->{'temp_c'};
else
$weather['now_temp'] = (int)$current_parsed_json->{'current_observation'}->{'temp_f'};
$weather['now_cond'] = (string)$current_parsed_json->{'current_observation'}->{'weather'};
$weather['now_icon'] = icon((string)$current_parsed_json->{'current_observation'}->{'icon'});
$weather['now_wind'] = (string)$current_parsed_json->{'current_observation'}->{'wind_string'};
$weather['now_humi'] = (string)$current_parsed_json->{'current_observation'}->{'relative_humidity'};
$i=0;
foreach($forecast_parsed_json->{'forecast'}->{'simpleforecast'}->{'forecastday'} as $day) {
$weather['forecast'][$i]['day_date'] = (string)$day->{'date'}->{'weekday'};
$weather['forecast'][$i]['day_cond'] = (string)$day->{'conditions'};
$weather['forecast'][$i]['day_icon'] = icon((string)$day->{'icon'});
$weather['forecast'][$i]['day_ltemp'] = (int)$day->{'low'}->{'celsius'};
$weather['forecast'][$i]['day_htemp'] = (int)$day->{'high'}->{'celsius'};
$i++;
}
// forecast
//$days = 4;
//for ($i = 0; $i < $days; $i++) {
//$weather['forecast'][$i]['day_date'] = (string)$forecast_parsed_json->{'forecast'}->{'forecastday[$i]'}->{''};
//$weather['forecast'][$i]['day_cond'] = (string)$forecast_parsed_json->{'forecast'}->{'forecastday[$i]'}->{'title'};
//$weather['forecast'][$i]['day_icon'] = icon((string)$forecast_parsed_json->{'forecast'}->{'forecastday[$i]'}->{'title'});
//$weather['forecast'][$i]['day_ltemp'] = (int)$forecast_parsed_json->{'forecast'}->{'forecastday[$i]'}->{'title'};
//$weather['forecast'][$i]['day_htemp'] = (int)$forecast_parsed_json->{'forecast'}->{'forecastday[$i]'}->{'title'};
//}
echo json_encode($weather);
// -----------------------------------------------------------------------------
// I C O N - M A P P E R
// -----------------------------------------------------------------------------
function icon($name)
{
$ret = "";
$icon["sunny"] = "sun_1";
$icon["mostlysunny"] = "sun_2";
$icon["partlycloudy"] = "sun_3";
$icon["mostlycloudy"] = "sun_5";
$icon["mist"] = "sun_6";
$icon["chancerain"] = "sun_7";
$icon["rain"] = "sun_8";
$icon["chancestorm"] = "sun_9";
$icon["storm"] = "sun_10";
$icon["chancesnow"] = "sun_11";
$icon["snow"] = "sun_12";
$icon["cloudy"] = "cloud_4";
$icon["showers"] = "cloud_8";
$icon["thunderstorm"] = "cloud_10";
$icon["rain_snow"] = "cloud_15";
$icon["foggy"] = "cloud_6";
$icon["fog"] = "cloud_6";
$icon["icy"] = "cloud_16";
$icon["smoke"] = "na";
$icon["dusty"] = "na";
$icon["hazy"] = "na";
$ret = $icon[$name];
return $ret;
}
/*
weather_thunderstorms-40.gif
weather_partlycloudy-40.gif
weather_sunny-40.gif
weather_overcast-40.gif
weather_rainsnow-40.gif
weather_mostlycloudy-40.gif
weather_rain-40.gif
weather_scatteredthunderstorms-40.gif
weather_scatteredshowers-40.gif
weather_snowflurries-40.gif
weather_haze-40.gif
weather_smoke-40.gif
weather_fog-40.gif
weather_dust-40.gif
weather_icy-40.gif
weather_snow-40.gif
weather_sleet-40.gif
weather_cloudy-40.gif
weather_drizzle-40.gif
weather_windy-40.gif
weather_heavyrain-40.gif
weather_heavysnow-40.gif
weather_scatteredsnowshowers-40.gif
*/
?>
Kommentar
-
@fmeister: Danke, werde das sofort übernehmen und mit dem nächsten release veröffentlichen.Join smartVISU on facebook. Web: smartvisu.de.
Dir gefällt smartVISU? Bitte spenden für die Weiterentwicklung.
Kommentar
-
Zitat von Bodo Beitrag anzeigenHoi
Das mit dem Google-Weather haben wir auch schon gemerkt.
Welche Variablen hast Du denn in config.php
ich hab prinzipiell nur die lib/weather/service/google.php ersetzt. Dort noch den API-key von dir eintragen.
Die wetter-widgets brauchen aber noch eine andere Ortsformatierung:
{{ lib.weather('weather', 'Austria/Hohenems') }}
Nicht mehr wie bisher bei google-weather einfach nur der Ort, sondern Ort+Land durch einen slash getrennt.
sonst solltest du nichts ändern müssen.
lg, Flo
Kommentar
-
Zitat von Apollo Beitrag anzeigenDanke für die Infos!
Geplant hab ich die "Realtime"-Fähigkeit ab Anfang Septempter anzugehen (nach meinen Urlaub). Hab mir auch schon einen Überblick verschafft und erste erfolgreiche Tests gemacht.
Das Gerüst bleibt aber so bestehen, d. h. jeder der jetzt sein Haus damit macht, wird das auch so verwenden können.
Gruss
PS: Finde die Visu auch sehr gelungen, es ist echt einfach damit was vernünftiges auf die Beine zu stellen, ohne sich ständig über Iphone, Ipad, Browser & Co. Gedanken machen zu müssen.
lg, Flo
Kommentar
-
Hier noch V2 der wunderground API.
changes:
- Umlautproblem behoben
- Icon für "Heiter"
- Reduktion auf 1 query zur wunderground API
ciao, flo
PHP-Code:<?
/**
* -----------------------------------------------------------------------------
* @package smartVISU
* @author Florian Meister
* @copyright 2012
* @license GPL <http://www.gnu.de>
* -----------------------------------------------------------------------------
*/
/config.php';
// init parameters
$request = array_merge($_GET, $_POST);
$location = $request['location'];
$lang = $request['lang'];
// Anstelle einer Stadt bzw. einer PLZ kann auch kommagetrennt
// Längen- und Breitengrad eines Ortes angegeben werden,
// z.B. http://www.google.de/ig/api?weather=,,,48187575,11513672&hl=de
// für München
if($lang == "de")
$wlang="DL";
else
$wlang=strtoupper($lang);
$url ="http://api.wunderground.com/api/DEIN_WUNDERGROUND_API_KEY/conditions/forecast/lang:" . $wlang . "/q/" . $location . ".json";
// get contents
$json_string = file_get_contents($url);
$parsed_json = json_decode($json_string);
if (config_lang == "de")
$weather['now_temp'] = (int)$parsed_json->{'current_observation'}->{'temp_c'};
else
$weather['now_temp'] = (int)$parsed_json->{'current_observation'}->{'temp_f'};
$weather['now_cond'] = (string)$parsed_json->{'current_observation'}->{'weather'};
$weather['now_icon'] = icon((string)$parsed_json->{'current_observation'}->{'icon'});
$weather['now_wind'] = (string)$parsed_json->{'current_observation'}->{'wind_string'};
$weather['now_humi'] = (string)$parsed_json->{'current_observation'}->{'relative_humidity'};
$i=0;
foreach($parsed_json->{'forecast'}->{'simpleforecast'}->{'forecastday'} as $day) {
$weather['forecast'][$i]['day_date'] = (string)$day->{'date'}->{'weekday'};
$weather['forecast'][$i]['day_cond'] = (string)$day->{'conditions'};
$weather['forecast'][$i]['day_icon'] = icon((string)$day->{'icon'});
$weather['forecast'][$i]['day_ltemp'] = (int)$day->{'low'}->{'celsius'};
$weather['forecast'][$i]['day_htemp'] = (int)$day->{'high'}->{'celsius'};
$i++;
}
echo json_encode($weather);
// -----------------------------------------------------------------------------
// I C O N - M A P P E R
// -----------------------------------------------------------------------------
function icon($name)
{
$ret = "";
$icon["sunny"] = "sun_1";
$icon["mostlysunny"] = "sun_2";
$icon["clear"] = "sun_2";
$icon["partlycloudy"] = "sun_3";
$icon["mostlycloudy"] = "sun_5";
$icon["mist"] = "sun_6";
$icon["chancerain"] = "sun_7";
$icon["rain"] = "sun_8";
$icon["chancestorm"] = "sun_9";
$icon["storm"] = "sun_10";
$icon["chancesnow"] = "sun_11";
$icon["snow"] = "sun_12";
$icon["cloudy"] = "cloud_4";
$icon["showers"] = "cloud_8";
$icon["thunderstorm"] = "cloud_10";
$icon["rain_snow"] = "cloud_15";
$icon["foggy"] = "cloud_6";
$icon["fog"] = "cloud_6";
$icon["icy"] = "cloud_16";
$icon["smoke"] = "na";
$icon["dusty"] = "na";
$icon["hazy"] = "na";
$ret = $icon[$name];
return $ret;
}
/*
weather_thunderstorms-40.gif
weather_partlycloudy-40.gif
weather_sunny-40.gif
weather_overcast-40.gif
weather_rainsnow-40.gif
weather_mostlycloudy-40.gif
weather_rain-40.gif
weather_scatteredthunderstorms-40.gif
weather_scatteredshowers-40.gif
weather_snowflurries-40.gif
weather_haze-40.gif
weather_smoke-40.gif
weather_fog-40.gif
weather_dust-40.gif
weather_icy-40.gif
weather_snow-40.gif
weather_sleet-40.gif
weather_cloudy-40.gif
weather_drizzle-40.gif
weather_windy-40.gif
weather_heavyrain-40.gif
weather_heavysnow-40.gif
weather_scatteredsnowshowers-40.gif
*/
?>
Kommentar
-
Super, dann geht heute abend bei mir das Wetter ja auch wieder.
Würde es nicht Sinn machen den Api-Key mit in den lib.weather-Aufruf oder die config zu nehmen? Dann muß nicht jeder an den Source der Visu.
Edit: Habe grade mal nachgesehen. Eigentlich reicht es, wenn der Apollo - als Developer - einen Api-Key fest im source einträgt.
@Apollo: Evtl. kannst Du den ja posten, dann braucht nicht jeder einen eigenen.
Edit2: Weiter gelesen: Der kostenlose Api-Key ist beschränkt auf 500 Anfragen pro Tag und max 10 pro Minute. Also doch jeder einen - oder eine andere Quelle.
Viele Grüße
Intruder73
Kommentar
-
somit erledigt. API key wird via
define ('config_wunderground_key', 'DEIN_WUNDERGROUND_APIKEY');
in der config.php definiert.
Ja das mit den beschränken Anfragen ist das Problem, sonst hätt ich schon meinen mitgepostet
Aber nachdem der key nichts kostet, 500 Anfragen/Tag mehr als genug für jeden hier sein sollten und das beschaffen des keys absolut unkompliziert ist, denk ich es ist gut so.
Sollte jemand eine gute weather-api alternative kennen die ohne key auskommt - bin für Vorschläge offen.
lg, flo
PHP-Code:<?
/**
* -----------------------------------------------------------------------------
* @package smartVISU
* @author Florian Meister
* @copyright 2012
* @license GPL <http://www.gnu.de>
* -----------------------------------------------------------------------------
*/
// get config-variables
require_once '../../../config.php';
// init parameters
$request = array_merge($_GET, $_POST);
$location = $request['location'];
$lang = $request['lang'];
if($lang == "de")
$wlang="DL";
else
$wlang=strtoupper($lang);
$apikey = config_wunderground_key;
$url ="http://api.wunderground.com/api/$apikey/conditions/forecast/lang:" . $wlang . "/q/" . $location . ".json";
// get contents
$json_string = file_get_contents($url);
$parsed_json = json_decode($json_string);
if (config_lang == "de")
$weather['now_temp'] = (int)$parsed_json->{'current_observation'}->{'temp_c'};
else
$weather['now_temp'] = (int)$parsed_json->{'current_observation'}->{'temp_f'};
$weather['now_cond'] = (string)$parsed_json->{'current_observation'}->{'weather'};
$weather['now_icon'] = icon((string)$parsed_json->{'current_observation'}->{'icon'});
$weather['now_wind'] = (string)$parsed_json->{'current_observation'}->{'wind_string'};
$weather['now_humi'] = (string)$parsed_json->{'current_observation'}->{'relative_humidity'};
$i=0;
foreach($parsed_json->{'forecast'}->{'simpleforecast'}->{'forecastday'} as $day) {
$weather['forecast'][$i]['day_date'] = (string)$day->{'date'}->{'weekday'};
$weather['forecast'][$i]['day_cond'] = (string)$day->{'conditions'};
$weather['forecast'][$i]['day_icon'] = icon((string)$day->{'icon'});
$weather['forecast'][$i]['day_ltemp'] = (int)$day->{'low'}->{'celsius'};
$weather['forecast'][$i]['day_htemp'] = (int)$day->{'high'}->{'celsius'};
$i++;
}
echo json_encode($weather);
// -----------------------------------------------------------------------------
// I C O N - M A P P E R
// -----------------------------------------------------------------------------
function icon($name)
{
$ret = "";
$icon["sunny"] = "sun_1";
$icon["mostlysunny"] = "sun_2";
$icon["clear"] = "sun_2";
$icon["partlycloudy"] = "sun_3";
$icon["mostlycloudy"] = "sun_5";
$icon["mist"] = "sun_6";
$icon["chancerain"] = "sun_7";
$icon["rain"] = "sun_8";
$icon["chancestorm"] = "sun_9";
$icon["storm"] = "sun_10";
$icon["chancesnow"] = "sun_11";
$icon["snow"] = "sun_12";
$icon["cloudy"] = "cloud_4";
$icon["showers"] = "cloud_8";
$icon["thunderstorm"] = "cloud_10";
$icon["rain_snow"] = "cloud_15";
$icon["foggy"] = "cloud_6";
$icon["fog"] = "cloud_6";
$icon["icy"] = "cloud_16";
$icon["smoke"] = "na";
$icon["dusty"] = "na";
$icon["hazy"] = "na";
$ret = $icon[$name];
return $ret;
}
/*
weather_thunderstorms-40.gif
weather_partlycloudy-40.gif
weather_sunny-40.gif
weather_overcast-40.gif
weather_rainsnow-40.gif
weather_mostlycloudy-40.gif
weather_rain-40.gif
weather_scatteredthunderstorms-40.gif
weather_scatteredshowers-40.gif
weather_snowflurries-40.gif
weather_haze-40.gif
weather_smoke-40.gif
weather_fog-40.gif
weather_dust-40.gif
weather_icy-40.gif
weather_snow-40.gif
weather_sleet-40.gif
weather_cloudy-40.gif
weather_drizzle-40.gif
weather_windy-40.gif
weather_heavyrain-40.gif
weather_heavysnow-40.gif
weather_scatteredsnowshowers-40.gif
*/
?>
Kommentar
-
Zitat von Bodo Beitrag anzeigenWelche Variablen hast Du denn in config.php// get config-variables
require_once '../../../config.php';
Auch noch gute Wetterdaten liefert gratis yr.no
Code:http://www.yr.no/place/Switzerland/Z%C3%BCrich/R%C3%BCti~2658909/forecast_hour_by_hour.xml
Grüsse Bodo
Fragen gehören ins Forum, und nicht in mein Postfach;
EibPC-Fan; Wiregate-Fan; Timberwolf-Fan mit 30x 1-Wire Sensoren;
Kommentar
-
Zitat von Bodo Beitrag anzeigenAuch noch gute Wetterdaten liefert gratis yr.no
(siehe xml-file und http://om.yr.no/verdata/vilkar/)
Kommentar
-
Zitat von Intruder73 Beitrag anzeigenDann muß aber der Hinweis...
Wenn ich's öffentlich zugänglich mache schon.Grüsse Bodo
Fragen gehören ins Forum, und nicht in mein Postfach;
EibPC-Fan; Wiregate-Fan; Timberwolf-Fan mit 30x 1-Wire Sensoren;
Kommentar
Kommentar