first commit

- create wrapper file 98_backupToStorage.pm for upgradeable new package
  politic
- create backuptoStorage.pm as a package file with minimal FHEM Fn
	neue Datei:     FHEM/98_backupToStorage.pm
	neue Datei:     lib/FHEM/backupToStorage.pm
This commit is contained in:
Marko Oldenburg 2020-06-17 09:27:46 +02:00
commit 528e16b166
2 changed files with 224 additions and 0 deletions

131
FHEM/98_backupToStorage.pm Normal file
View File

@ -0,0 +1,131 @@
###############################################################################
#
# Developed with Kate
#
# (c) 2020 Copyright: Marko Oldenburg (fhemsupport@cooltux.net)
# All rights reserved
#
# Special thanks goes to:
# -
#
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License,or
# any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# $Id$
#
###############################################################################
package main;
use strict;
use warnings;
use utf8;
use FHEM::backupToStorage;
sub backupToStorage_Initialize {
my $hash = shift;
## Da ich mit package arbeite müssen in die Initialize für die jeweiligen hash Fn Funktionen der Funktionsname
# und davor mit :: getrennt der eigentliche package Name des Modules
$hash->{SetFn} = \&FHEM::backupToStorage::Set;
$hash->{DefFn} = \&FHEM::backupToStorage::Define;
$hash->{NotifyFn} = \&FHEM::backupToStorage::Notify;
$hash->{UndefFn} = \&FHEM::backupToStorage::Undef;
$hash->{AttrList} =
'bTS_Host '
. 'bTS_User '
. 'bTS_Path ';
$hash->{NotifyOrderPrefix} = '51-'; # Order Nummer für NotifyFn
return FHEM::Meta::InitMod( __FILE__, $hash );
}
1;
=pod
=item device
=item summary Module for copy finished fhem backups to storage (Nextcloud)
=item summary_DE Modul zum kopieren fertiger fhem Backups auf ein Storage (Nextcloud)
=begin html
<a name="backupToStorage"></a>
<h3>backupToStorage</h3>
<ul>
</ul>
=end html
=begin html_DE
<a name="backupToStorage"></a>
<h3>backupToStorage</h3>
<ul>
</ul>
=end html_DE
=for :application/json;q=META.json 98_backupToStorage.pm
{
"abstract": "Module for copy finished fhem backups to storage (Nextcloud)",
"x_lang": {
"de": {
"abstract": "Modul zum kopieren fertiger fhem Backups auf ein Storage (Nextcloud)"
}
},
"keywords": [
"fhem-mod-device",
"fhem-core",
"Backup",
"Nextcloud"
],
"release_status": "devepolment",
"license": "GPL_2",
"version": "v0.0.1",
"author": [
"Marko Oldenburg <fhemsupport@cooltux.net>"
],
"x_fhem_maintainer": [
"CoolTux"
],
"x_fhem_maintainer_github": [
"LeonGaultier"
],
"prereqs": {
"runtime": {
"requires": {
"FHEM": 5.00918799,
"perl": 5.016,
"Meta": 0,
"JSON": 0,
"Date::Parse": 0
},
"recommends": {
},
"suggests": {
}
}
}
}
=end :application/json;q=META.json
=cut

View File

@ -0,0 +1,93 @@
###############################################################################
#
# Developed with Kate
#
# (c) 2020 Copyright: Marko Oldenburg (fhemsupport@cooltux.net)
# All rights reserved
#
# Special thanks goes to:
# -
#
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License,or
# any later version.
#
# The GNU General Public License can be found at
# http://www.gnu.org/copyleft/gpl.html.
# A copy is found in the textfile GPL.txt and important notices to the license
# from the author is found in LICENSE.txt distributed with these scripts.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# $Id$
#
###############################################################################
package FHEM::backupToStorage;
use strict;
use warnings;
use utf8;
use GPUtils qw(GP_Import GP_Export);
## Import der FHEM Funktionen
#-- Run before package compilation
BEGIN {
# Import from main context
GP_Import(
qw(
readingsSingleUpdate
readingsBulkUpdate
readingsBulkUpdateIfChanged
readingsBeginUpdate
readingsEndUpdate
defs
modules
Log3
CommandAttr
attr
AttrVal
deviceEvents
init_done
devspec2array)
);
}
sub Define {
my $hash = shift // return;
my $aArg = shift // return;
return $@ unless ( FHEM::Meta::SetInternals($hash) );
use version 0.60; our $VERSION = FHEM::Meta::Get( $hash, 'version' );
return 'only one backupToStorage instance allowed'
if ( devspec2array('TYPE=backupToStorage') > 1 )
; # es wird geprüft ob bereits eine Instanz unseres Modules existiert,wenn ja wird abgebrochen
return 'too few parameters: define <name> backupToStorage'
if ( scalar( @{$aArg} ) != 2 );
my $name = shift @$aArg;
$hash->{VERSION} = version->parse($VERSION)->normal;
$hash->{NOTIFYDEV} = 'global';
Log3( $name, 3, "backupToStorage ($name) - defined" );
return;
}
sub Undef {
my $hash = shift;
my $name = shift;
Log3( $name, 3, "backupToStorage ($name) - delete device $name" );
return;
}