From 7b4c5d4b5d64dffffd1e0071ea71a7f12815ccdc Mon Sep 17 00:00:00 2001 From: loredo Date: Mon, 10 Apr 2017 12:35:20 +0000 Subject: [PATCH] Unit: add rtype for RGB Decimal git-svn-id: https://svn.fhem.de/fhem/trunk@13962 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/50_HP1000.pm | 2 +- fhem/FHEM/Unit.pm | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fhem/FHEM/50_HP1000.pm b/fhem/FHEM/50_HP1000.pm index f0cdf8f9a..1bb1953c3 100755 --- a/fhem/FHEM/50_HP1000.pm +++ b/fhem/FHEM/50_HP1000.pm @@ -88,7 +88,7 @@ sub HP1000_Initialize($) { 'UV' => { rtype => 'uvi', }, 'UVR' => { rtype => 'uwpscm', }, 'UVcondition' => { rtype => 'condition_uvi', }, - 'UVcondition_rgb' => { rtype => 'rgb', }, + 'UVcondition_rgb' => { rtype => 'rgbhex', }, 'condition' => { rtype => 'condition_weather', }, 'daylight' => { rtype => 'yesno', }, 'dewpoint' => { rtype => 'c', formula_symbol => 'Td', }, diff --git a/fhem/FHEM/Unit.pm b/fhem/FHEM/Unit.pm index 80cfef8c1..66e5e2167 100644 --- a/fhem/FHEM/Unit.pm +++ b/fhem/FHEM/Unit.pm @@ -1328,13 +1328,23 @@ my $rtypes = { }, # color + rgbhex => { + ref_base => 900, + rtype_description => { + de => 'RGB Farbwert in Hex Notation', + en => 'RGB color value in Hex notation', + }, + scope => '^#?(([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2}))$', + }, + rgb => { ref_base => 900, rtype_description => { - de => 'RGB Farbwert', - en => 'RGB color value', + de => 'RGB Farbwert in Dezimal Notation', + en => 'RGB color value in decimal notation', }, - scope => '^#?(([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2}))$', + scope => +'^[\s\t\n ]*(?:rgb|RGB)?[\s\t\n ]*\(?[\s\t\n ]*((?:([0-9]{1,2}|1[0-9]{1,2}|2[0-4][0-9]|25[0-5])[\s\t\n ]*,?[\s\t\n ]*)(?:([0-9]{1,2}|1[0-9]{1,2}|2[0-4][0-9]|25[0-5])[\s\t\n ]*,?[\s\t\n ]*)(?:([0-9]{1,2}|1[0-9]{1,2}|2[0-4][0-9]|25[0-5])))[\s\t\n ]*\)?[\s\t\n ]*$', }, # logical operators