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

Unit.pm: add data type information

git-svn-id: https://svn.fhem.de/fhem/trunk@12572 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2016-11-14 05:00:27 +00:00
parent b720f9efaa
commit 12b5f0c83f

View File

@ -178,7 +178,7 @@ my $rtype_base = {
dimension => 'L',
formula_symbol => 'l',
rtype_base => 'm',
txt_base => {
base_description => {
de => 'Länge',
en => 'length',
fr => 'length',
@ -193,7 +193,7 @@ my $rtype_base = {
dimension => 'M',
formula_symbol => 'm',
rtype_base => 'kg',
txt_base => {
base_description => {
de => 'Masse',
en => 'mass',
fr => 'mass',
@ -208,7 +208,7 @@ my $rtype_base = {
dimension => 'T',
formula_symbol => 't',
rtype_base => 's',
txt_base => {
base_description => {
de => 'Zeit',
en => 'time',
fr => 'time',
@ -223,7 +223,7 @@ my $rtype_base = {
dimension => 'I',
formula_symbol => 'i',
rtype_base => 'a',
txt_base => {
base_description => {
de => 'elektrische Stromstärke',
en => 'electric current',
fr => 'electric current',
@ -238,7 +238,7 @@ my $rtype_base = {
dimension => 'θ',
formula_symbol => 'T',
rtype_base => 'k',
txt_base => {
base_description => {
de => 'absolute Temperatur',
en => 'absolute temperature',
fr => 'absolute temperature',
@ -253,7 +253,7 @@ my $rtype_base = {
dimension => 'N',
formula_symbol => 'n',
rtype_base => 'mol',
txt_base => {
base_description => {
de => 'Stoffmenge',
en => 'amount of substance',
fr => 'amount of substance',
@ -268,7 +268,7 @@ my $rtype_base = {
dimension => 'J',
formula_symbol => 'Iv',
rtype_base => 'cd',
txt_base => {
base_description => {
de => 'Lichtstärke',
en => 'luminous intensity',
fr => 'luminous intensity',
@ -283,7 +283,7 @@ my $rtype_base = {
dimension => 'M L^2 T^2',
formula_symbol => 'E',
rtype_base => 'j',
txt_base => {
base_description => {
de => 'Energie',
en => 'energy',
fr => 'energy',
@ -298,7 +298,7 @@ my $rtype_base = {
dimension => 'T^1',
formula_symbol => 'f',
rtype_base => 'hz',
txt_base => {
base_description => {
de => 'Frequenz',
en => 'frequency',
fr => 'frequency',
@ -313,7 +313,7 @@ my $rtype_base = {
dimension => 'M L^2 T^3',
formula_symbol => 'P',
rtype_base => 'w',
txt_base => {
base_description => {
de => 'Leistung',
en => 'power',
fr => 'power',
@ -328,7 +328,7 @@ my $rtype_base = {
dimension => 'M L^1 T^2',
formula_symbol => 'p',
rtype_base => 'pa',
txt_base => {
base_description => {
de => 'Druck',
en => 'pressure',
fr => 'pressure',
@ -343,7 +343,7 @@ my $rtype_base = {
dimension => 'M L^1 T^2',
formula_symbol => 'pabs',
rtype_base => 'pabs',
txt_base => {
base_description => {
de => 'absoluter Druck',
en => 'absolute pressure',
fr => 'absolute pressure',
@ -358,7 +358,7 @@ my $rtype_base = {
dimension => 'M L^1 T^2',
formula_symbol => 'pamb',
rtype_base => 'pamb',
txt_base => {
base_description => {
de => 'Luftdruck',
en => 'air pressure',
fr => 'air pressure',
@ -373,7 +373,7 @@ my $rtype_base = {
dimension => 'M L^2 T^3 I^1',
formula_symbol => 'U',
rtype_base => 'v',
txt_base => {
base_description => {
de => 'elektrische Spannung',
en => 'electric voltage',
fr => 'electric voltage',
@ -388,7 +388,7 @@ my $rtype_base = {
dimension => '1',
formula_symbol => '',
rtype_base => 'rad',
txt_base => {
base_description => {
de => 'ebener Winkel',
en => 'plane angular',
fr => 'plane angular',
@ -403,7 +403,7 @@ my $rtype_base = {
dimension => 'L T^1',
formula_symbol => 'v',
rtype_base => 'kmh',
txt_base => {
base_description => {
de => 'Geschwindigkeit',
en => 'speed',
fr => 'speed',
@ -418,7 +418,7 @@ my $rtype_base = {
dimension => 'L^2 J',
formula_symbol => 'Ev',
rtype_base => 'lx',
txt_base => {
base_description => {
de => 'Beleuchtungsstärke',
en => 'illumination intensity',
fr => 'illumination intensity',
@ -433,7 +433,7 @@ my $rtype_base = {
dimension => 'J',
formula_symbol => 'F',
rtype_base => 'lm',
txt_base => {
base_description => {
de => 'Lichtstrom',
en => 'luminous flux',
fr => 'luminous flux',
@ -448,7 +448,7 @@ my $rtype_base = {
dimension => 'L^3',
formula_symbol => 'V',
rtype_base => 'm3',
txt_base => {
base_description => {
de => 'Volumen',
en => 'volume',
fr => 'volume',
@ -463,7 +463,7 @@ my $rtype_base = {
dimension => '1',
formula_symbol => 'B',
rtype_base => 'b',
txt_base => {
base_description => {
de => 'Logarithmische Größe',
en => 'logarithmic level',
fr => 'logarithmic level',
@ -478,7 +478,7 @@ my $rtype_base = {
dimension => 'I T',
formula_symbol => 'C',
rtype_base => 'coul',
txt_base => {
base_description => {
de => 'elektrische Ladung',
en => 'electric charge',
fr => 'electric charge',
@ -493,7 +493,7 @@ my $rtype_base = {
dimension => '',
formula_symbol => 'F',
rtype_base => 'far',
txt_base => {
base_description => {
de => 'elektrische Kapazität',
en => 'electric capacity',
fr => 'electric capacity',
@ -508,7 +508,7 @@ my $rtype_base = {
dimension => '',
formula_symbol => 'F',
rtype_base => 'far',
txt_base => {
base_description => {
de => 'elektrische Widerstand',
en => 'electric resistance',
fr => 'electric resistance',
@ -523,7 +523,7 @@ my $rtype_base = {
dimension => 'L^2',
formula_symbol => 'A',
rtype_base => 'm2',
txt_base => {
base_description => {
de => 'Flächeninhalt',
en => 'surface area',
fr => 'surface area',
@ -535,13 +535,13 @@ my $rtype_base = {
},
900 => {
txt_base => 'FHEM Builtin Readings Type',
base_description => 'FHEM Builtin Readings Type',
tmpl => '%value%',
tmpl_long => '%value%',
},
999 => {
txt_base => 'FHEM User Defined Readings Type',
base_description => 'FHEM User Defined Readings Type',
tmpl => '%value%',
tmpl_long => '%value%',
},
@ -560,6 +560,13 @@ my $rtypes = {
pl => [ 'error', 'on' ],
},
scope => [ '^(nok|error|0)$', '^(ok|1)$' ],
rtype_description => {
de => 'Zweiwertiger Fehlerstatus',
en => 'two-way error state',
fr => 'two-way error state',
nl => 'two-way error state',
pl => 'two-way error state',
},
},
onoff => {
@ -572,6 +579,13 @@ my $rtypes = {
pl => [ 'off', 'on' ],
},
scope => [ '^(off|0)$', '^(on|1)$' ],
rtype_description => {
de => 'Schaltstatus',
en => 'Switch state',
fr => 'Switch state',
nl => 'Switch state',
pl => 'Switch state',
},
},
bool => {
@ -583,57 +597,76 @@ my $rtypes = {
nl => [ 'false', 'true' ],
pl => [ 'false', 'true' ],
},
scope => [ '^(0|false)$', '^(1|true)$' ],
scope => [ '^(false|0)$', '^(true|1)$' ],
rtype_description => {
de => 'Boolesch',
en => 'Boolean',
fr => 'Boolean',
nl => 'Boolean',
pl => 'Boolean',
},
},
epoch => {
ref_base => 900,
txt => {
scope => { min => 0 },
rtype_description => {
de => 'Unix Epoche in s seit 1970-01-01T00:00:00Z',
en => 'Unix epoch in s since 1970-01-01T00:00:00Z',
fr => 'Unix epoch in s since 1970-01-01T00:00:00Z',
nl => 'Unix epoch in s since 1970-01-01T00:00:00Z',
pl => 'Unix epoch in s since 1970-01-01T00:00:00Z',
},
scope => { min => 0 },
},
time => {
ref_base => 900,
txt => {
scope => '^(([0-1]?[0-9]|[0-2]?[0-3]):([0-5]?[0-9]))$',
rtype_description => {
de => 'Uhrzeit hh:mm',
en => 'time hh:mm',
fr => 'time hh:mm',
nl => 'time hh:mm',
pl => 'time hh:mm',
},
scope => '^(([0-1]?[0-9]|[0-2]?[0-3]):([0-5]?[0-9]))$',
},
datetime => {
ref_base => 900,
txt => 'YYYY-mm-dd hh:mm',
scope =>
'^(([1-2][0-9]{3})-(0?[1-9]|1[0-2])-(0?[1-9]|[1-2][0-9]|30|31) (0?[1-9]|1[0-9]|2[0-3]):(0?[1-9]|[1-5][0-9]))$',
rtype_description => {
de => 'Datum+Uhrzeit YYYY-mm-dd hh:mm',
en => 'date+time YYYY-mm-dd hh:mm',
fr => 'date+time YYYY-mm-dd hh:mm',
nl => 'date+time YYYY-mm-dd hh:mm',
pl => 'date+time YYYY-mm-dd hh:mm',
},
},
timesec => {
ref_base => 900,
txt => {
scope => '^(([0-1]?[0-9]|[0-2]?[0-3]):([0-5]?[0-9]):([0-5]?[0-9]))$',
rtype_description => {
de => 'Uhrzeit hh:mm:ss',
en => 'time hh:mm:ss',
fr => 'time hh:mm:ss',
nl => 'time hh:mm:ss',
pl => 'time hh:mm:ss',
},
scope => '(([0-1]?[0-9]|[0-2]?[0-3]):([0-5]?[0-9]):([0-5]?[0-9]))',
},
datetimesec => {
ref_base => 900,
txt => 'YYYY-mm-dd hh:mm:ss',
scope =>
'^(([1-2][0-9]{3})-(0?[1-9]|1[0-2])-(0?[1-9]|[1-2][0-9]|30|31) (0?[1-9]|1[0-9]|2[0-3]):(0?[1-9]|[1-5][0-9]):(0?[1-9]|[1-5][0-9]))$',
rtype_description => {
de => 'Datum+Uhrzeit YYYY-mm-dd hh:mm:ss',
en => 'date+time YYYY-mm-dd hh:mm:ss',
fr => 'date+time YYYY-mm-dd hh:mm:ss',
nl => 'date+time YYYY-mm-dd hh:mm:ss',
pl => 'date+time YYYY-mm-dd hh:mm:ss',
},
},
direction => {
@ -641,6 +674,13 @@ my $rtypes = {
formula_symbol => 'Dir',
ref => 'gon',
scope => { min => 0, max => 360 },
rtype_description => {
de => 'Richtungsangabe',
en => 'direction',
fr => 'direction',
nl => 'direction',
pl => 'direction',
},
},
compasspoint => {
@ -698,49 +738,77 @@ my $rtypes = {
'^(S|8)$', '^(SSW|9)$', '^(SW|10)$', '^(WSW|11)$',
'^(W|12)$', '^(WNW|13)$', '^(NW|14)$', '^(NNW|15)$'
],
rtype_description => {
de => 'Himmelsrichtung',
en => 'point of the compass',
fr => 'point of the compass',
nl => 'point of the compass',
pl => 'point of the compass',
},
},
closure => {
ref_base => 900,
txt => {
de => 'offen/geschlossen/gekippt',
en => 'open/closed/tilted',
fr => 'open/closed/tilted',
nl => 'open/closed/tilted',
pl => 'open/closed/tilted',
de => [ 'geschlossen', 'offen', 'gekippt' ],
en => [ 'closed', 'open', 'tilted' ],
fr => [ 'closed', 'open', 'tilted' ],
nl => [ 'closed', 'open', 'tilted' ],
pl => [ 'closed', 'open', 'tilted' ],
},
scope => [ '^(closed|0)$', '^(open|1)$', '^(tilted|2)$' ],
rtype_description => {
de => 'Status für Fenster und Türen',
en => 'state for windows and doors',
fr => 'state for windows and doors',
nl => 'state for windows and doors',
pl => 'state for windows and doors',
},
},
condition_hum => {
ref_base => 900,
txt => {
de => [ 'trocken', 'niedrig', 'optimal', 'hoch', 'feucht' ],
en => [ 'dry', 'low', 'optimal', 'high', 'wet' ],
fr => [ 'dry', 'low', 'optimal', 'high', 'wet' ],
nl => [ 'dry', 'low', 'optimal', 'high', 'wet' ],
pl => [ 'dry', 'low', 'optimal', 'high', 'wet' ],
},
scope => [
'^(dry|0)$', '^(low|1)$', '^(optimal|2)$', '^(high|3)$',
'^(wet|4)$'
],
rtype_description => {
de => 'Feuchtigkeitsbedingung',
en => 'humidity condition',
fr => 'humidity condition',
nl => 'humidity condition',
pl => 'humidity condition',
},
scope => [
'^(dry|0)$', '^(low|1)$', '^(optimal|2)$', '^(high|3)$',
'^(wet|4)$'
],
},
condition_uvi => {
ref_base => 900,
txt => {
de => 'UV Bedingung',
en => 'UV condition',
fr => 'UV condition',
nl => 'UV condition',
pl => 'UV condition',
de => [ 'niedrig', 'moderat', 'high', 'sehr hoch', 'extrem' ],
en => [ 'low', 'moderate', 'high', 'veryhigh', 'extreme' ],
fr => [ 'low', 'moderate', 'high', 'veryhigh', 'extreme' ],
nl => [ 'low', 'moderate', 'high', 'veryhigh', 'extreme' ],
pl => [ 'low', 'moderate', 'high', 'veryhigh', 'extreme' ],
},
scope => [
'^(low|0)$', '^(moderate|1)$',
'^(high|2)$', '^(veryhigh|3)$',
'^(extreme|4)$'
],
rtype_description => {
de => 'UV Bedingung',
en => 'UV condition',
fr => 'UV condition',
nl => 'UV condition',
pl => 'UV condition',
},
},
pct => {
@ -2561,7 +2629,9 @@ sub formatValue($$$;$$$$) {
elsif ( ref($format) eq 'HASH' && looks_like_number($value) ) {
my $v = abs($value);
foreach my $l ( sort { $b <=> $a } keys( %{$format} ) ) {
next if ( ref( $format->{$l} ) ne 'HASH' || !$format->{$l}{scale} );
next
if ( ref( $format->{$l} ) ne 'HASH'
|| !$format->{$l}{scale} );
if ( $v >= $l ) {
my $scale = $format->{$l}{scale};