2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-19 00:26:03 +00:00

Unit.pm: RType compasspoint

git-svn-id: https://svn.fhem.de/fhem/trunk@12887 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2016-12-27 00:58:24 +00:00
parent 460e1e945f
commit fed03d9706

View File

@ -1025,6 +1025,7 @@ my $rtypes = {
compasspoint => { compasspoint => {
ref_base => 900, ref_base => 900,
formula_symbol => 'CP', formula_symbol => 'CP',
ref => 'gon',
txt => { txt => {
de => [ de => [
'N', 'NNO', 'NO', 'ONO', 'O', 'OSO', 'SO', 'SSO', 'N', 'NNO', 'NO', 'ONO', 'O', 'OSO', 'SO', 'SSO',
@ -1521,8 +1522,12 @@ my $rtypes = {
de => 'Grad', de => 'Grad',
en => 'gradians', en => 'gradians',
}, },
tmpl => '%value%%symbol%', tmpl => '%value%%symbol%',
scope => { minValue => 0 }, decimal_mark => {
de => 2,
en => 1,
},
format => '%i',
}, },
rad => { rad => {
@ -1532,7 +1537,11 @@ my $rtypes = {
de => 'Radiant', de => 'Radiant',
en => 'radiant', en => 'radiant',
}, },
scope => { minValue => 0 }, decimal_mark => {
de => 2,
en => 1,
},
format => '%i',
}, },
# temperature # temperature
@ -3181,7 +3190,8 @@ sub replaceTemplate ($$$$;$) {
$txt = '%value%' . chr(0x202F) . '%symbol%' if ( $desc->{symbol} ); $txt = '%value%' . chr(0x202F) . '%symbol%' if ( $desc->{symbol} );
$txt = '%value%' . chr(0x202F) . '%symbol%' if ( $desc->{symbol} ); $txt = '%value%' . chr(0x202F) . '%symbol%' if ( $desc->{symbol} );
$txt = $desc->{tmpl} if ( $desc->{tmpl} ); $txt = $desc->{tmpl} if ( $desc->{tmpl} );
$txt = '%txt%' if ( defined( $desc->{txt} ) ); #TODO $txt = '%txt%'
if ( defined( $desc->{txt} ) && !looks_like_number($value) );
Unit_Log3( $device, $reading, $odesc, 9, Unit_Log3( $device, $reading, $odesc, 9,
"replaceTemplate $device $reading: detected txt template: $txt" ); "replaceTemplate $device $reading: detected txt template: $txt" );
@ -3319,9 +3329,9 @@ sub Unit_verifyValueNumber($$) {
} }
elsif ( $_ eq 'eq' ) { elsif ( $_ eq 'eq' ) {
if ( $value ne $scope->{eq} ) { if ( $value ne $scope->{eq} ) {
$log .= " $value is not equal to $scope->{eq}.";
$value = $scope->{eq} $value = $scope->{eq}
if ( !$scope->{keep} || $scope->{strict} ); if ( !$scope->{keep} || $scope->{strict} );
$log .= " $value is not equal to $scope->{eq}.";
} }
} }
elsif ( !$scope->{regex} && !defined( $scope->{eq} ) ) { elsif ( !$scope->{regex} && !defined( $scope->{eq} ) ) {
@ -3336,44 +3346,44 @@ sub Unit_verifyValueNumber($$) {
} }
elsif ( $_ eq 'minValue' ) { elsif ( $_ eq 'minValue' ) {
if ( $value < $scope->{$_} ) { if ( $value < $scope->{$_} ) {
$log .= " $value is lesser than $scope->{$_}.";
$value = $scope->{$_} $value = $scope->{$_}
if ( !$scope->{keep} || $scope->{strict} ); if ( !$scope->{keep} || $scope->{strict} );
$log .= " $value is smaller than $scope->{$_}.";
} }
} }
elsif ( $_ eq 'maxValue' ) { elsif ( $_ eq 'maxValue' ) {
if ( $value > $scope->{$_} ) { if ( $value > $scope->{$_} ) {
$log .= " $value is greater than $scope->{$_}.";
$value = $scope->{$_} $value = $scope->{$_}
if ( !$scope->{keep} || $scope->{strict} ); if ( !$scope->{keep} || $scope->{strict} );
$log .= " $value is higher than $scope->{$_}.";
} }
} }
elsif ( $_ eq 'lt' ) { elsif ( $_ eq 'lt' ) {
if ( $value >= $scope->{$_} ) { if ( $value >= $scope->{$_} ) {
$log .= " $value is not $_ $scope->{$_}.";
$value = $scope->{$_} $value = $scope->{$_}
if ( !$scope->{keep} || $scope->{strict} ); if ( !$scope->{keep} || $scope->{strict} );
$log .= " $value is not $_ $scope->{$_}.";
} }
} }
elsif ( $_ eq 'le' ) { elsif ( $_ eq 'le' ) {
if ( $value > $scope->{$_} ) { if ( $value > $scope->{$_} ) {
$log .= " $value is not $_ $scope->{$_}.";
$value = $scope->{$_} $value = $scope->{$_}
if ( !$scope->{keep} || $scope->{strict} ); if ( !$scope->{keep} || $scope->{strict} );
$log .= " $value is not $_ $scope->{$_}.";
} }
} }
elsif ( $_ eq 'gt' ) { elsif ( $_ eq 'gt' ) {
if ( $value <= $scope->{$_} ) { if ( $value <= $scope->{$_} ) {
$log .= " $value is not $_ $scope->{$_}.";
$value = $scope->{$_} $value = $scope->{$_}
if ( !$scope->{keep} || $scope->{strict} ); if ( !$scope->{keep} || $scope->{strict} );
$log .= " $value is not $_ $scope->{$_}.";
} }
} }
elsif ( $_ eq 'ge' ) { elsif ( $_ eq 'ge' ) {
if ( $value < $scope->{$_} ) { if ( $value < $scope->{$_} ) {
$log .= " $value is not $_ $scope->{$_}.";
$value = $scope->{$_} $value = $scope->{$_}
if ( !$scope->{keep} || $scope->{strict} ); if ( !$scope->{keep} || $scope->{strict} );
$log .= " $value is not $_ $scope->{$_}.";
} }
} }
} }
@ -3488,8 +3498,8 @@ sub formatValue($$$;$$$$) {
( $verified, $value, $value_num, $log ) = ( $verified, $value, $value_num, $log ) =
Unit_verifyValueNumber( $value, $scope ); Unit_verifyValueNumber( $value, $scope );
Unit_Log3( $device, $reading, $desc, 3, Unit_Log3( $device, $reading, $desc, 4,
"formatValue $device $reading: scope: WARNING - $log" ) "formatValue $device $reading: scope: WARNING -$log" )
if ($log); if ($log);
} }
@ -3707,8 +3717,8 @@ sub formatValue($$$;$$$$) {
Unit_verifyValueNumber( $value, $_ ); Unit_verifyValueNumber( $value, $_ );
if ( !$verified && $log ) { if ( !$verified && $log ) {
Unit_Log3( $device, $reading, $desc, 3, Unit_Log3( $device, $reading, $desc, 4,
"formatValue $device $reading: scope: WARNING - $log" "formatValue $device $reading: scope: WARNING -$log"
); );
} }