From c97c7d31e06f23db9ed249b506e6718e531a847d Mon Sep 17 00:00:00 2001 From: jpawlowski Date: Thu, 21 Feb 2019 13:18:49 +0000 Subject: [PATCH] Multiple: Add FHEM::Meta support git-svn-id: https://svn.fhem.de/fhem/trunk@18681 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_RESIDENTS.pm | 2 ++ fhem/FHEM/20_GUEST.pm | 2 ++ fhem/FHEM/20_ROOMMATE.pm | 2 ++ fhem/FHEM/50_HP1000.pm | 6 +++++ fhem/FHEM/59_Wunderground.pm | 6 +++++ fhem/FHEM/70_ENIGMA2.pm | 6 +++++ fhem/FHEM/70_LaMetric2.pm | 41 ++++++++++++++++++++++++++++++++- fhem/FHEM/70_PHTV.pm | 5 ++++ fhem/FHEM/70_Pushover.pm | 6 +++++ fhem/FHEM/74_THINKINGCLEANER.pm | 6 +++++ fhem/FHEM/75_msgConfig.pm | 10 +++++++- fhem/FHEM/98_GEOFANCY.pm | 6 +++++ fhem/FHEM/RESIDENTStk.pm | 14 +++++++---- 13 files changed, 106 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/10_RESIDENTS.pm b/fhem/FHEM/10_RESIDENTS.pm index 81bb82b18..8b22f338f 100644 --- a/fhem/FHEM/10_RESIDENTS.pm +++ b/fhem/FHEM/10_RESIDENTS.pm @@ -25,6 +25,8 @@ sub RESIDENTS_Initialize($) { "disable:1,0 disabledForIntervals do_not_notify:1,0 " . "rgr_states:multiple-strict,home,gotosleep,asleep,awoken,absent,gone rgr_lang:EN,DE rgr_noDuration:0,1 rgr_showAllStates:0,1 rgr_wakeupDevice " . $readingFnAttributes; + + return FHEM::Meta::Load( __FILE__, $hash ); } # module Fn #################################################################### diff --git a/fhem/FHEM/20_GUEST.pm b/fhem/FHEM/20_GUEST.pm index 8d5bae2c0..0cfe568ee 100644 --- a/fhem/FHEM/20_GUEST.pm +++ b/fhem/FHEM/20_GUEST.pm @@ -30,6 +30,8 @@ sub GUEST_Initialize($) { foreach (@RESIDENTStk_attr) { $hash->{AttrList} .= " " . $hash->{AttrPrefix} . $_; } + + return FHEM::Meta::Load( __FILE__, $hash ); } 1; diff --git a/fhem/FHEM/20_ROOMMATE.pm b/fhem/FHEM/20_ROOMMATE.pm index fe6ff9f61..a7e42887b 100644 --- a/fhem/FHEM/20_ROOMMATE.pm +++ b/fhem/FHEM/20_ROOMMATE.pm @@ -30,6 +30,8 @@ sub ROOMMATE_Initialize($) { foreach (@RESIDENTStk_attr) { $hash->{AttrList} .= " " . $hash->{AttrPrefix} . $_; } + + return FHEM::Meta::Load( __FILE__, $hash ); } 1; diff --git a/fhem/FHEM/50_HP1000.pm b/fhem/FHEM/50_HP1000.pm index 3628e4fd8..6fe5ee28d 100755 --- a/fhem/FHEM/50_HP1000.pm +++ b/fhem/FHEM/50_HP1000.pm @@ -10,6 +10,7 @@ use List::Util qw(sum); use HttpUtils; use Unit; +use FHEM::Meta; # module hashes ############################################################### my %HP1000_pwsMapping = ( @@ -266,6 +267,8 @@ sub HP1000_Initialize($) { }, }, }; + + return FHEM::Meta::Load( __FILE__, $hash ); } # regular Fn ################################################################## @@ -285,6 +288,9 @@ sub HP1000_Define($$$) { . " (there can only be one instance as per restriction of the weather station itself)" if ( defined( $modules{HP1000}{defptr} ) && !defined( $hash->{OLDDEF} ) ); + # Initialize the module and the device + return $@ unless ( FHEM::Meta::SetInternals($hash) ); + # check FHEMWEB instance when user first defines the device if ( $init_done && !defined( $hash->{OLDDEF} ) ) { my $FWports; diff --git a/fhem/FHEM/59_Wunderground.pm b/fhem/FHEM/59_Wunderground.pm index 39af820c9..07bf19dda 100644 --- a/fhem/FHEM/59_Wunderground.pm +++ b/fhem/FHEM/59_Wunderground.pm @@ -12,6 +12,7 @@ use utf8; use Encode qw(encode_utf8 decode_utf8); use Unit; use Data::Dumper; +use FHEM::Meta; # initialize ################################################################## sub Wunderground_Initialize($) { @@ -293,6 +294,8 @@ sub Wunderground_Initialize($) { 'wind_speed' => { rtype => 'kmph', formula_symbol => 'Ws' }, 'wind_speed_mph' => { rtype => 'mph', formula_symbol => 'Ws' } }; + + return FHEM::Meta::Load( __FILE__, $hash ); } # regular Fn ################################################################## @@ -321,6 +324,9 @@ sub Wunderground_Define($$$) { $hash->{API_KEY} = @$a[2]; $hash->{QUERY} = @$a[3]; + # Initialize the module and the device + return $@ unless ( FHEM::Meta::SetInternals($hash) ); + $hash->{QUERY} = "pws:" . $hash->{QUERY} if ( $hash->{QUERY} =~ /^[A-Z]{3,}\d{1,}$/ ); diff --git a/fhem/FHEM/70_ENIGMA2.pm b/fhem/FHEM/70_ENIGMA2.pm index b67cb601a..262f715b1 100644 --- a/fhem/FHEM/70_ENIGMA2.pm +++ b/fhem/FHEM/70_ENIGMA2.pm @@ -8,6 +8,7 @@ use Time::Local; use Encode qw(encode_utf8 decode_utf8); use HttpUtils; +use FHEM::Meta; # initialize ################################################################## sub ENIGMA2_Initialize($) { @@ -58,6 +59,8 @@ sub ENIGMA2_Initialize($) { }, }, }; + + return FHEM::Meta::Load( __FILE__, $hash ); } # regular Fn ################################################################## @@ -93,6 +96,9 @@ sub ENIGMA2_Define($$) { unless ( $interval =~ /^\d+$/ ); $hash->{INTERVAL} = $interval; + # Initialize the device + return $@ unless ( FHEM::Meta::SetInternals($hash) ); + my $http_user = shift @$a; my $http_passwd = shift @$a; $hash->{URL} = "$http_user:$http_passwd@" . $hash->{URL} diff --git a/fhem/FHEM/70_LaMetric2.pm b/fhem/FHEM/70_LaMetric2.pm index 61d00bf81..a0d31a950 100644 --- a/fhem/FHEM/70_LaMetric2.pm +++ b/fhem/FHEM/70_LaMetric2.pm @@ -36,6 +36,7 @@ use HttpUtils; use SetExtensions; use Unit; use utf8; +use FHEM::Meta; my %LaMetric2_sounds = ( notifications => [ @@ -247,6 +248,8 @@ sub LaMetric2_Initialize($$) { #$hash->{parseParams} = 1; # not possible due to legacy msg command schema $hash->{'.msgParams'} = { parseParams => 1, }; + + return FHEM::Meta::Load( __FILE__, $hash ); } #------------------------------------------------------------------------------ @@ -266,9 +269,11 @@ sub LaMetric2_Define($$) { return "$apikey does not seem to be a valid key" if ( $apikey !~ /^([a-f0-9]{64})$/ ); + # Initialize the device + return $@ unless ( FHEM::Meta::SetInternals($hash) ); + $hash->{HOST} = $host; $hash->{".API_KEY"} = $apikey; - $hash->{VERSION} = "2.3.1"; $hash->{INTERVAL} = $interval && looks_like_number($interval) ? $interval : 60; $hash->{PORT} = $port && looks_like_number($port) ? $port : 4343; @@ -2687,4 +2692,38 @@ Leider keine deutsche Dokumentation vorhanden. Die englische Version gibt es hie =end html_DE + +=for :application/json;q=META.json 70_LaMetric2.pm +{ + "version": "v2.3.2", + "release_status": "stable", + "author": [ + "Julian Pawlowski " + ], + "x_fhem_maintainer": [ + "loredo" + ], + "x_fhem_maintainer_github": [ + "jpawlowski" + ], + "resources": { + "license": [ + "https://fhem.de/#License" + ], + "homepage": "https://fhem.de/", + "bugtracker": { + "web": "https://forum.fhem.de/index.php/board,53.0.html", + "x_web_title": "Multimedia" + }, + "repository": { + "type": "svn", + "url": "https://svn.fhem.de/fhem/", + "x_branch_master": "trunk", + "x_branch_dev": "trunk", + "web": "https://svn.fhem.de/" + } + } +} +=end :application/json;q=META.json + =cut diff --git a/fhem/FHEM/70_PHTV.pm b/fhem/FHEM/70_PHTV.pm index c75fa739b..4de3e997e 100644 --- a/fhem/FHEM/70_PHTV.pm +++ b/fhem/FHEM/70_PHTV.pm @@ -9,6 +9,7 @@ use Time::HiRes qw(gettimeofday); use HttpUtils; use Color; use Encode; +use FHEM::Meta; # initialize ################################################################## sub PHTV_Initialize($) { @@ -49,6 +50,7 @@ sub PHTV_Initialize($) { }; FHEM_colorpickerInit(); + return FHEM::Meta::Load( __FILE__, $hash ); } # regular Fn ################################################################## @@ -73,6 +75,9 @@ sub PHTV_Define($$) { return $msg; } + # Initialize the module and the device + return $@ unless ( FHEM::Meta::SetInternals($hash) ); + $hash->{NOTIFYDEV} = "global"; my $address = $a[2]; diff --git a/fhem/FHEM/70_Pushover.pm b/fhem/FHEM/70_Pushover.pm index a2bd95ce7..5a5890b09 100644 --- a/fhem/FHEM/70_Pushover.pm +++ b/fhem/FHEM/70_Pushover.pm @@ -9,6 +9,7 @@ use utf8; use Data::Dumper; use HttpUtils; use Encode; +use FHEM::Meta; # initialize ################################################################## sub Pushover_Initialize($$) { @@ -23,6 +24,8 @@ sub Pushover_Initialize($$) { #$hash->{parseParams} = 1; # not possible due to legacy msg command schema $hash->{'.msgParams'} = { parseParams => 1, }; + + return FHEM::Meta::Load( __FILE__, $hash ); } # regular Fn ################################################################## @@ -44,6 +47,9 @@ sub Pushover_Define($$) { if ( defined($token) && defined($user) ) { + # Initialize the device + return $@ unless ( FHEM::Meta::SetInternals($hash) ); + $hash->{APP_TOKEN} = $token; $hash->{USER_KEY} = $user; diff --git a/fhem/FHEM/74_THINKINGCLEANER.pm b/fhem/FHEM/74_THINKINGCLEANER.pm index 3a20993d2..2cb0df5b9 100644 --- a/fhem/FHEM/74_THINKINGCLEANER.pm +++ b/fhem/FHEM/74_THINKINGCLEANER.pm @@ -8,6 +8,7 @@ use vars qw(%data); use HttpUtils; use Encode; use Data::Dumper; +use FHEM::Meta; # initialize ################################################################## sub THINKINGCLEANER_Initialize($) { @@ -56,6 +57,8 @@ sub THINKINGCLEANER_Initialize($) { }, }, }; + + return FHEM::Meta::Load( __FILE__, $hash ); } # regular Fn ################################################################## @@ -83,6 +86,9 @@ sub THINKINGCLEANER_Define($$$) { $hash->{TYPE} = "THINKINGCLEANER"; + # Initialize the device + return $@ unless ( FHEM::Meta::SetInternals($hash) ); + my $address = @$a[2]; $hash->{DeviceName} = $address; diff --git a/fhem/FHEM/75_msgConfig.pm b/fhem/FHEM/75_msgConfig.pm index 960bcccbc..5df7f65dc 100755 --- a/fhem/FHEM/75_msgConfig.pm +++ b/fhem/FHEM/75_msgConfig.pm @@ -4,6 +4,7 @@ package main; use strict; use warnings; use Data::Dumper; +use FHEM::Meta; # initialize ################################################################## sub msgConfig_Initialize($) { @@ -144,6 +145,8 @@ sub msgConfig_Initialize($) { { addToAttrList($_); } + + return FHEM::Meta::Load( __FILE__, $hash ); } # regular Fn ################################################################## @@ -159,7 +162,12 @@ sub msgConfig_Define($$) { return "Global configuration device already defined: " . $modules{$TYPE}{defptr}{NAME} - if ( defined( $modules{$TYPE}{defptr} ) ); + if ( defined( $modules{$TYPE}{defptr} ) + && $init_done + && !defined( $hash->{OLDDEF} ) ); + + # Initialize the device + return $@ unless ( FHEM::Meta::SetInternals($hash) ); # create global unique device definition $modules{$TYPE}{defptr} = $hash; diff --git a/fhem/FHEM/98_GEOFANCY.pm b/fhem/FHEM/98_GEOFANCY.pm index f31c6ec5d..c205150a6 100755 --- a/fhem/FHEM/98_GEOFANCY.pm +++ b/fhem/FHEM/98_GEOFANCY.pm @@ -8,6 +8,7 @@ use Time::Local; use UConv; use HttpUtils; +use FHEM::Meta; # initialize ################################################################## sub GEOFANCY_Initialize($) { @@ -16,6 +17,8 @@ sub GEOFANCY_Initialize($) { $hash->{UndefFn} = "GEOFANCY_Undefine"; $hash->{SetFn} = "GEOFANCY_Set"; $hash->{AttrList} = "devAlias disable:0,1 " . $readingFnAttributes; + + return FHEM::Meta::Load( __FILE__, $hash ); } # regular Fn ################################################################## @@ -28,6 +31,9 @@ sub GEOFANCY_Define($$) { my $name = $a[0]; my $infix = $a[2]; + # Initialize the device + return $@ unless ( FHEM::Meta::SetInternals($hash) ); + $hash->{fhem}{infix} = $infix; GEOFANCY_addExtension( $name, "GEOFANCY_CGI", $infix ); diff --git a/fhem/FHEM/RESIDENTStk.pm b/fhem/FHEM/RESIDENTStk.pm index 5de7322dc..2157154cc 100644 --- a/fhem/FHEM/RESIDENTStk.pm +++ b/fhem/FHEM/RESIDENTStk.pm @@ -6,6 +6,7 @@ use warnings; use Data::Dumper; use Unit; +use FHEM::Meta; our (@RESIDENTStk_attr); # module variables ############################################################ @@ -73,6 +74,10 @@ sub RESIDENTStk_Define($$) { || !defined( $a[2] ) || $a[2] =~ /^[A-Za-z\d._]+(?:,[A-Za-z\d._]*)*$/ ); + # Initialize the module and the device + return $@ unless ( FHEM::Meta::SetInternals($hash) ); + use version 0.77; our $VERSION = FHEM::Meta::Get( $hash, 'version' ); + $hash->{MOD_INIT} = 1; $hash->{NOTIFYDEV} = "global"; delete $hash->{RESIDENTGROUPS} if ( $hash->{RESIDENTGROUPS} ); @@ -1533,10 +1538,11 @@ sub RESIDENTStk_SetLocation(@) { # update locationPresence # if ( $posBeaconUUID eq "" ) { - readingsBulkUpdate( $hash, "locationPresence", "present" ) - if ( $trigger == 1 ); - readingsBulkUpdate( $hash, "locationPresence", "absent" ) - if ( $trigger == 0 ); + readingsBulkUpdate( $hash, "locationPresence", "present" ) + if ( $trigger == 1 ); + readingsBulkUpdate( $hash, "locationPresence", "absent" ) + if ( $trigger == 0 ); + # } # # update positionPresence