2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

SynoMOdules: extend the routines

git-svn-id: https://svn.fhem.de/fhem/trunk@22669 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2020-08-25 16:53:12 +00:00
parent c445cdd868
commit 54ecac6739
2 changed files with 22 additions and 3 deletions

View File

@ -32,7 +32,7 @@ use warnings;
use utf8;
use Carp qw(croak carp);
use version; our $VERSION = qv('1.0.0');
use version; our $VERSION = version->declare('1.0.1');
use Exporter ('import');
our @EXPORT_OK = qw(apistatic);

View File

@ -35,7 +35,7 @@ use utf8;
use GPUtils qw( GP_Import GP_Export );
use Carp qw(croak carp);
use version; our $VERSION = qv('1.0.0');
use version; our $VERSION = version->declare('1.1.0');
use Exporter ('import');
our @EXPORT_OK = qw(
@ -43,6 +43,7 @@ our @EXPORT_OK = qw(
trim
sortVersion
setVersionInfo
jboolmap
);
our %EXPORT_TAGS = (all => [@EXPORT_OK]);
@ -156,6 +157,9 @@ sub setVersionInfo {
$hash->{HELPER}{PACKAGE} = __PACKAGE__;
$hash->{HELPER}{VERSION} = $v;
$hash->{HELPER}{VERSION_API} = FHEM::SynoModules::API->VERSION() // "unused";
$hash->{HELPER}{VERSION_SMUtils} = FHEM::SynoModules::SMUtils->VERSION() // "unused";
if($modules{$type}{META}{x_prereqs_src} && !$hash->{HELPER}{MODMETAABSENT}) { # META-Daten sind vorhanden
$modules{$type}{META}{version} = "v".$v; # Version aus META.json überschreiben, Anzeige mit {Dumper $modules{<TYPE>}{META}}
@ -167,7 +171,7 @@ sub setVersionInfo {
return $@ unless (FHEM::Meta::SetInternals($hash)); # FVERSION wird gesetzt ( nur gesetzt wenn $Id$ im Kopf komplett! vorhanden )
if(__PACKAGE__ eq "FHEM::$type" || __PACKAGE__ eq $type) { # es wird mit Packages gearbeitet -> mit {<Modul>->VERSION()} im FHEMWEB kann Modulversion abgefragt werden
use version; our $VERSION = FHEM::Meta::Get( $hash, 'version' ); ## no critic 'VERSION Reused'
use version 0.77; our $VERSION = FHEM::Meta::Get( $hash, 'version' ); ## no critic 'VERSION Reused'
}
} else { # herkömmliche Modulstruktur
@ -177,4 +181,19 @@ sub setVersionInfo {
return;
}
###############################################################################
# JSON Boolean Test und Mapping
###############################################################################
sub jboolmap {
my $bool = shift // carp "got no value to check if bool !" && return;
my $is_boolean = JSON::is_bool($bool);
if($is_boolean) {
$bool = $bool ? "true" : "false";
}
return $bool;
}
1;