2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-05-04 20:17:45 +00:00

59_Weather: Codestyle, add attribut model to API

git-svn-id: https://svn.fhem.de/fhem/trunk@18292 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2019-01-17 10:51:24 +00:00
parent a4af61f28a
commit 63fe6a3066
2 changed files with 197 additions and 207 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- change: 59_Weather: Codestyle, add attribut model to API
- bugfix: 73_AutoShuttersControl: fix drive up then roommate asleep - bugfix: 73_AutoShuttersControl: fix drive up then roommate asleep
- bugfix: DarkSkyAPI: fix uninitialized value in localtime at line 430 - bugfix: DarkSkyAPI: fix uninitialized value in localtime at line 430
- bugfix: 89_FULLY: fixed command set url - bugfix: 89_FULLY: fixed command set url

View File

@ -79,7 +79,6 @@ my @iconlist = (
################################### ###################################
sub Weather_LanguageInitialize($) { sub Weather_LanguageInitialize($) {
my ($lang) = @_; my ($lang) = @_;
if($lang eq "de") { if($lang eq "de") {
@ -117,7 +116,6 @@ sub Weather_LanguageInitialize($) {
################################### ###################################
sub Weather_DebugCodes($) { sub Weather_DebugCodes($) {
my ($lang)= @_; my ($lang)= @_;
my @YahooCodes_i18n= YahooWeatherAPI_getYahooCodes($lang); my @YahooCodes_i18n= YahooWeatherAPI_getYahooCodes($lang);
@ -131,7 +129,6 @@ sub Weather_DebugCodes($) {
##################################### #####################################
sub Weather_Initialize($) { sub Weather_Initialize($) {
my ($hash) = @_; my ($hash) = @_;
$hash->{DefFn} = "Weather_Define"; $hash->{DefFn} = "Weather_Define";
@ -173,7 +170,6 @@ sub Weather_ReturnWithError($$) {
} }
sub Weather_RetrieveCallbackFn($) { sub Weather_RetrieveCallbackFn($) {
my $name = shift; my $name = shift;
my $hash = $defs{$name}; my $hash = $defs{$name};
my $responseRef = $hash->{fhem}->{api}->getWeather; my $responseRef = $hash->{fhem}->{api}->getWeather;
@ -300,7 +296,6 @@ sub Weather_WriteReadings($$) {
################################### ###################################
sub Weather_GetUpdate($) { sub Weather_GetUpdate($) {
my ($hash) = @_; my ($hash) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -321,7 +316,6 @@ sub Weather_GetUpdate($) {
################################### ###################################
sub Weather_Get($@) { sub Weather_Get($@) {
my ($hash, @a) = @_; my ($hash, @a) = @_;
return "argument is missing" if(int(@a) != 2); return "argument is missing" if(int(@a) != 2);
@ -361,15 +355,15 @@ sub Weather_Set($@) {
################################### ###################################
sub Weather_RearmTimer($$) { sub Weather_RearmTimer($$) {
my ($hash, $t) = @_; my ($hash, $t) = @_;
InternalTimer($t, "Weather_GetUpdate", $hash, 0) ; InternalTimer($t, "Weather_GetUpdate", $hash, 0) ;
} }
sub Weather_DisarmTimer($) { sub Weather_DisarmTimer($) {
my ($hash)= @_; my ($hash)= @_;
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
} }
@ -398,7 +392,6 @@ sub Weather_Notify($$) {
##################################### #####################################
sub Weather_Define($$) { sub Weather_Define($$) {
my ($hash, $def) = @_; my ($hash, $def) = @_;
my $usage= "syntax: define <name> Weather [API=<API>] [apikey=<apikey>] [location=<location>] [interval=<interval>] [lang=<lang>]"; my $usage= "syntax: define <name> Weather [API=<API>] [apikey=<apikey>] [location=<location>] [interval=<interval>] [lang=<lang>]";
@ -439,6 +432,7 @@ sub Weather_Define($$) {
$hash->{API} = $api; $hash->{API} = $api;
$hash->{APIKEY} = $apikey; $hash->{APIKEY} = $apikey;
$hash->{APIOPTIONS} = $apioptions; $hash->{APIOPTIONS} = $apioptions;
$attr{$name}->{model} = $api;
#$hash->{UNITS} = "c"; # hardcoded to use degrees centigrade (Celsius) #$hash->{UNITS} = "c"; # hardcoded to use degrees centigrade (Celsius)
$hash->{READINGS}->{current_date_time}->{TIME}= TimeNow(); $hash->{READINGS}->{current_date_time}->{TIME}= TimeNow();
$hash->{READINGS}->{current_date_time}->{VAL}= "none"; $hash->{READINGS}->{current_date_time}->{VAL}= "none";
@ -458,7 +452,6 @@ sub Weather_Define($$) {
##################################### #####################################
sub Weather_Undef($$) { sub Weather_Undef($$) {
my ($hash, $arg) = @_; my ($hash, $arg) = @_;
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
@ -476,21 +469,18 @@ use constant ICONSCALE => 0.5;
##################################### #####################################
sub WeatherIconIMGTag($) { sub WeatherIconIMGTag($) {
my $width= int(ICONSCALE*ICONWIDTH); my $width= int(ICONSCALE*ICONWIDTH);
my ($icon)= @_; my ($icon)= @_;
my $url= FW_IconURL("weather/$icon"); my $url= FW_IconURL("weather/$icon");
my $style= " width=$width"; my $style= " width=$width";
return "<img src=\"$url\"$style alt=\"$icon\">"; return "<img src=\"$url\"$style alt=\"$icon\">";
} }
##################################### #####################################
sub WeatherAsHtmlV($;$) sub WeatherAsHtmlV($;$) {
{
my ($d,$items) = @_; my ($d,$items) = @_;
$d = "<none>" if(!$d); $d = "<none>" if(!$d);
$items = 9 if( !$items ); $items = 9 if( !$items );
return "$d is not a Weather instance<br>" return "$d is not a Weather instance<br>"
@ -521,16 +511,15 @@ sub WeatherAsHtmlV($;$)
return $ret; return $ret;
} }
sub WeatherAsHtml($;$) sub WeatherAsHtml($;$) {
{
my ($d,$i) = @_; my ($d,$i) = @_;
WeatherAsHtmlV($d,$i); WeatherAsHtmlV($d,$i);
} }
sub WeatherAsHtmlH($;$) sub WeatherAsHtmlH($;$) {
{
my ($d,$items) = @_; my ($d,$items) = @_;
$d = "<none>" if(!$d); $d = "<none>" if(!$d);
$items = 9 if( !$items ); $items = 9 if( !$items );
return "$d is not a Weather instance<br>" return "$d is not a Weather instance<br>"
@ -578,9 +567,9 @@ sub WeatherAsHtmlH($;$)
return $ret; return $ret;
} }
sub WeatherAsHtmlD($;$) sub WeatherAsHtmlD($;$) {
{
my ($d,$i) = @_; my ($d,$i) = @_;
if($FW_ss) { if($FW_ss) {
WeatherAsHtmlV($d,$i); WeatherAsHtmlV($d,$i);
} else { } else {