Display HM-Dis-WM55 Beispielscript

Kabellose und kabelgebundene Sender und Empfänger der klassischen Homematic-Serie

Moderator: Co-Administratoren

GeosShark
Beiträge: 26
Registriert: 25.10.2014, 13:03
Wohnort: Dresden

Display HM-Dis-WM55 Beispielscript

Beitrag von GeosShark » 30.12.2014, 12:28

Hai all,
ich habe mich eine Weile mit dem Display beschäftigt und auf der Basis des Universalscripts von DrTob "mal was zusammengebastelt".
Vielleicht verhilft es jemand zum Einstieg und es werden vielleicht noch mehrere Ideen gepostet.

Ach ja, ich habe das Script auf Taste2 kurz gelegt. Zum Ansteuern des Displays muss man ja den Tastendruck auswerten... Somit können 4 Scripte bedient werden: Taste2 (oben) kurz bzw. lang und das Gleiche für Taste1 (unten).

Viel Spaß beim ausprobieren.

Code: Alles auswählen

!! Display 1 Taste2 kurz                                                        
!! 
!! Universalprogramm zum Füllen                                                  
!! (c) DrTob 
!! optimized by thkl
!! 
!! überarbeitet geosshark 30.12.2014 11:48:00
!! Anzeige der Aussentemperatur und der Stati aller Fenster, die mit dem 
!! Drehgriffsensor (nur mit diesem getestet) ausgerüstet sind.
!! Alle Sensoren müssen im Gewerk "Fenster" sein.
!! Die Namenskonvention der Sensoren : z.B. xx_Bad_yyy_zz..., der 2. mit "_" getrennt Parameter wird angezeigt, hier "Bad".

!! Das Script holt sich jetzt die Seriennummer des Displays selbst aus der Auslösebedingung des Programms

! Farben
! 0x80 weiß
! 0x81 rot
! 0x82 orange
! 0x83 gelb
! 0x84 gruen
! 0x85 blau 
string weiss  = "0x80";
string rot    = "0x81";
string orange = "0x82";
string gelb   = "0x83";
string gruen  = "0x84";
string blau   = "0x85";

! Symbole 
! 
! 0x80 AUS
! 0x81 EIN
! 0x82 OFFEN
! 0x83 geschlossen
! 0x84 fehler
! 0x85 alles ok
! 0x86 information
! 0x87 neue nachricht
! 0x88 servicemeldung
! 0x89 Signal grün
! 0x8A Signal gelb
! 0x8B Signal rot

! Zugriff auf vordefinierte Texte
! 
! 0x80 Text  0 (Kanal 1  Text Zeile 1)
! 0x81 Text  1 (Kanal 1  Text Zeile 2)
! 0x82 Text  2 (Kanal 2  Text Zeile 3)
! 0x83 Text  3 (Kanal 2  Text Zeile 4)
! 0x84 Text  4 (Kanal 3  Text Zeile 5)
! 0x85 Text  5 (Kanal 3  Text Zeile 6)
! 0x86 Text  6 (Kanal 4  Text Zeile 7)
! 0x87 Text  7 (Kanal 4  Text Zeile 8)
! 0x88 Text  8 (Kanal 5  Text Zeile 9)
! 0x89 Text  9 (Kanal 5  Text Zeile 10)
! 0x8A Text 10 (Kanal 6  Text Zeile 11)
! 0x8B Text 11 (Kanal 6  Text Zeile 12)
! 0x8C Text 12 (Kanal 7  Text Zeile 13)
! 0x8D Text 13 (Kanal 7  Text Zeile 14)
! 0x8E Text 14 (Kanal 8  Text Zeile 15)
! 0x8F Text 15 (Kanal 8  Text Zeile 16)
! 0x90 Text 16 (Kanal 9  Text Zeile 17)
! 0x91 Text 17 (Kanal 9  Text Zeile 18)
! 0x92 Text 18 (Kanal 10 Text Zeile 19)
! 0x93 Text 19 (Kanal 10 Text Zeile 20)

! ==================================================================================================
var istTemp = dom.GetObject("BidCos-RF.LEQ0099367:1.TEMPERATURE").State();
var istHum  = dom.GetObject("BidCos-RF.LEQ0099367:1.HUMIDITY").State();

! Temperatur aussen
string zeile1 = "Außentemp.";
string color1 = orange;
string  icon1 = "0x86";

string zeile2 = istTemp.ToString(1) # " C";
if (istTemp >= 0.0)  { string color2 = orange; }
if (istTemp >= 10.0) { string color2 = gelb; }
if (istTemp >= 20.0) { string color2 = rot; }
if (istTemp < 0.0)   { string color2 = weiss; }
if (istTemp < -6.0)  { string color2 = blau; }
string icon2 = "";
! ----------------------------------------------------------------------------------------
var fem = dom.GetObject("Fenster");
string m;
string listg;
string listo;
string Wo;
integer status = 0;

listo = "";
listg = "";

foreach(m, fem.EnumUsedIDs())
{
  var item = dom.GetObject(m);
  if(item.IsTypeOf(OT_CHANNEL))
  {
    var dev = dom.GetObject(item.Device());
    if((dev.HssType()=="HM-Sec-RHS") || (dev.HssType()=="HM-Sec-SC") || (dev.HssType()=="HM-Sec-SC-2"))
    {
      var stat = item.DPByHssDP("STATE");
      if(stat.Value()== '0')					
      {
        status = status + 0;	! geschlossen
      }
      if (stat.Value()== '1')		
      {
      	status = status + 1;	! gekippt
      	Wo = dev.Name();
      	Wo = Wo.StrValueByIndex("_", 1);

        listg = listg + Wo # ",";
      }
      if (stat.Value()== '2')		
      {
      	status = status + 1000;	! offen
      	Wo = dev.Name();
      	Wo = Wo.StrValueByIndex("_", 1);
        listo = listo + Wo # ",";
      }
    }
  }
}

string zeile3 = "--Fenster--";
string color3 = weiss;
string icon3  = "";

! if (status < 1000)
! {	! mindestens 1 gekippt
! 	string zeile4 = "gekippt:";
! 	string color4 = "0x83";
! 	string icon4  = "";
! } 
! 
! if (status >= 1000)
! {	! mindestens 1 offen
! 	string zeile4 = "offen:";
! 	string color4 = "0x81";
! 	string icon4  = "";
! }	
string zeile4 = "";
string color4 = "";
string  icon4 = "";

string zeile5 = "";
string color5 = "";
string  icon5 = "";

string zeile6 = "";
string color6 = "";
string  icon6	= "";

if ( status == 0)
{		
	! alles zu
	string zeile4 = "geschlossen";
	string color4 = gruen;
	string  icon4 = "";
}
else
{
	! irgendwo was offen
	integer i = 4;
	foreach (nam, listo.Split(","))
	{
		if ((zeil.Length() + nam.Length()) < 12)
		{
			if (zeil == "")
			{
				zeil = nam;
			} 
			else 
			{
				zeil = zeil # "," # nam;
			}
		}
		else
		{

			if (i == 4)
			{
				string zeile4 = zeil;
				string color4 = rot;
				string  icon4 = "";			
			}
			if (i == 5)
			{
				string zeile5 = zeil;
				string color5 = rot;
				string  icon5 = "";			
			}
			if (i == 6)
			{
				string zeile6 = zeil;
				string color6 = rot;
				string  icon6 = "";			
			}
			zeil = nam;
			i = i + 1;
		}
	}
	if (zeil <> "")
	{
		if (i == 4)
		{
			string zeile4 = zeil;
			string color4 = rot;
			string  icon4 = "";			
		}
		if (i == 5)
		{
			string zeile5 = zeil;
			string color5 = rot;
			string  icon5 = "";			
		}
		if (i == 6)
		{
			string zeile6 = zeil;
			string color6 = rot;
			string  icon6 = "";			
		}
		zeil = "";
		i = i + 1;
		
	}

	foreach (nam, listg.Split(","))
	{
		if ((zeil.Length() + nam.Length()) < 12)
		{
			if (zeil == "")
			{
				zeil = nam;
			} 
			else 
			{
				zeil = zeil # "," # nam;
			}
		}
		else
		{
			if (i == 4)
			{
				string zeile4 = zeil;
				string color4 = gelb;
				string  icon4 = "";			
			}
			if (i == 5)
			{
				string zeile5 = zeil;
				string color5 = gelb;
				string  icon5 = "";			
			}
			if (i == 6)
			{
				string zeile6 = zeil;
				string color6 = gelb;
				string  icon6 = "";			
			}
			zeil = nam;
			i = i + 1;
		}
	}
	if (zeil <> "")
	{
			if (i == 4)
			{
				string zeile4 = zeil;
				string color4 = gelb;
				string  icon4 = "";			
			}
			if (i == 5)
			{
				string zeile5 = zeil;
				string color5 = gelb;
				string  icon5 = "";			
			}
			if (i == 6)
			{
				string zeile6 = zeil;
				string color6 = gelb;
				string  icon6 = "";			
			}
		zeil = "";
		i = i + 1;	
	}
}


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! System Routine do not change anything below !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

string splitter="|";
string msgBuffer = zeile1 # splitter # color1 # splitter # icon1 # "\t";
msgBuffer = msgBuffer # zeile2 # splitter # color2 # splitter # icon2 # "\t";
msgBuffer = msgBuffer # zeile3 # splitter # color3 # splitter # icon3 # "\t";
msgBuffer = msgBuffer # zeile4 # splitter # color4 # splitter # icon4 # "\t";
msgBuffer = msgBuffer # zeile5 # splitter # color5 # splitter # icon5 # "\t";
msgBuffer = msgBuffer # zeile6 # splitter # color6 # splitter # icon6 # "\t";

string substitutions = "A,0x41\tB,0x42\tC,0x43\tD,0x44\tE,0x45\tF,0x46\tG,0x47\tH,0x48\tI,0x49\tJ,0x4A\tK,0x4B\tL,0x4C\tM,0x4D\tN,0x4E\tO,0x4F\tP,0x50\tQ,0x51\tR,0x52\tS,0x53\tT,0x54\tU,0x55\tV,0x56\tW,0x57\tX,0x58\tY,0x59\tZ,0x5A";
substitutions = substitutions # "\ta,0x61\tb,0x62\tc,0x63\td,0x64\te,0x65\tf,0x66\tg,0x67\th,0x68\ti,0x69\tj,0x6A\tk,0x6B\tl,0x6C\tm,0x6D\tn,0x6E\to,0x6F\tp,0x70\tq,0x71\tr,0x72\ts,0x73\tt,0x74\tu,0x75\tv,0x76\tw,0x77\tx,0x78\ty,0x79\tz,0x7A";
substitutions = substitutions # "\t0,0x30\t1,0x31\t2,0x32\t3,0x33\t4,0x34\t5,0x35\t6,0x36\t7,0x37\t8,0x38\t9,0x39\t ,0x20\t!,0x21\t\",0x22\t%,0x25\t&,0x26\t=,0x27\t(,0x28\t),0x29\t*,0x2A\t+,0x2B\t,,0x2C\t-,0x2D\t.,0x2E\t/,0x2F";
substitutions = substitutions # "\tÄ,0x5B\tÖ,0x23\tÜ,0x24\tä,0x7B\tö,0x7C\tü,0x7D\tß,0x5F\t:,0x3A\t;,0x3B\t@,0x40\t>,0x3E"; 

string bufferLine;
string substEntry;

string command = "0x02";
integer i = 0;
string char = "";

foreach(bufferLine, msgBuffer) 
{
   string line = bufferLine.StrValueByIndex(splitter, 0);
   string color = bufferLine.StrValueByIndex(splitter, 1);
   string icon = bufferLine.StrValueByIndex(splitter, 2);
   if ((line <> "") || (icon <> "")) 
   {
      command = command # ",0x12";
      if ((line.Substr(0,2) == "0x") && (line.Length() == 4)) 
      {
         command = command # "," # line;
         i = 12;
      } else {
         i = 0;
      }
      while ((i < line.Length()) && (i < 12)) 
      { 
         char = line.Substr(i, 1);     
         foreach(substEntry, substitutions)
         {
            if (char == substEntry.Substr(0,1)){command = command # substEntry.Substr(1,5);}
         }
         i = i + 1; 
      }
      command = command # ",0x11," # color;
      if (icon <> "") 
      {
         command = command # ",0x13," # icon;
      }
    }
 command = command # ",0x0A";
}
command = command # ",0x0A,0x03";

dom.GetObject("BidCos-RF." # dom.GetObject("$src$").Name().StrValueByIndex(".",1) # ".SUBMIT").State(command);
-------------------------------------------------------------------
Gruß
Frank
__________________________________________________________________
Signatur verboten

lötix
Beiträge: 347
Registriert: 10.03.2014, 18:41

Re: Display HM-Dis-WM55 Beispielscript

Beitrag von lötix » 30.12.2014, 21:00

Moin....

so nen nettes Teil habe ich mir auch gerade zugelegt und schon geschaut, was man damit anstellen kann. Da kommt dein Script gerade recht. ;-)
Ich habe es auf nen Tastendruck in ein Programm gepackt und das Gewerk von "Fenster" in "Verschluss" geändert, da sind nun mal meine Fenster drin. Aber schon beim Prüfen des Scriptes kommen Fehler. Hat das jetzt mit der Umbenennung zu tun, habe ich da etwas übersehen?

tnx4info lötix

Code: Alles auswählen

Error 1 at row 163 col 20 near ^, listo.Split(","))
       {
          if ((zeil.Length() + nam.Length()) < 12)

Error 1 at row 163 col 20 near ^, listo.Split(","))
       {
          if ((zeil.Length() + nam.Length()) < 12)

Parse following code failed:
    !! Display 1 Taste2 kurz                                                       
    !!
    !! Universalprogramm zum Füllen                                                 
    !! (c) DrTob
    !! optimized by thkl
    !!
    !! überarbeitet geosshark 30.12.2014 11:48:00
    !! Anzeige der Aussentemperatur und der Stati aller Fenster, die mit dem
    !! Drehgriffsensor (nur mit diesem getestet) ausgerüstet sind.
    !! Alle Sensoren müssen im Gewerk "Fenster" sein.
    !! Die Namenskonvention der Sensoren : z.B. xx_Bad_yyy_zz..., der 2. mit "_" getrennt Parameter wird angezeigt, hier "Bad".

    !! Das Script holt sich jetzt die Seriennummer des Displays selbst aus der Auslösebedingung des Programms

    ! Farben
    ! 0x80 weiß
    ! 0x81 rot
    ! 0x82 orange
    ! 0x83 gelb
    ! 0x84 gruen
    ! 0x85 blau
    string weiss  = "0x80";
    string rot    = "0x81";
    string orange = "0x82";
    string gelb   = "0x83";
    string gruen  = "0x84";
    string blau   = "0x85";

    ! Symbole
    !
    ! 0x80 AUS
    ! 0x81 EIN
    ! 0x82 OFFEN
    ! 0x83 geschlossen
    ! 0x84 fehler
    ! 0x85 alles ok
    ! 0x86 information
    ! 0x87 neue nachricht
    ! 0x88 servicemeldung
    ! 0x89 Signal grün
    ! 0x8A Signal gelb
    ! 0x8B Signal rot

    ! Zugriff auf vordefinierte Texte
    !
    ! 0x80 Text  0 (Kanal 1  Text Zeile 1)
    ! 0x81 Text  1 (Kanal 1  Text Zeile 2)
    ! 0x82 Text  2 (Kanal 2  Text Zeile 3)
    ! 0x83 Text  3 (Kanal 2  Text Zeile 4)
    ! 0x84 Text  4 (Kanal 3  Text Zeile 5)
    ! 0x85 Text  5 (Kanal 3  Text Zeile 6)
    ! 0x86 Text  6 (Kanal 4  Text Zeile 7)
    ! 0x87 Text  7 (Kanal 4  Text Zeile 8)
    ! 0x88 Text  8 (Kanal 5  Text Zeile 9)
    ! 0x89 Text  9 (Kanal 5  Text Zeile 10)
    ! 0x8A Text 10 (Kanal 6  Text Zeile 11)
    ! 0x8B Text 11 (Kanal 6  Text Zeile 12)
    ! 0x8C Text 12 (Kanal 7  Text Zeile 13)
    ! 0x8D Text 13 (Kanal 7  Text Zeile 14)
    ! 0x8E Text 14 (Kanal 8  Text Zeile 15)
    ! 0x8F Text 15 (Kanal 8  Text Zeile 16)
    ! 0x90 Text 16 (Kanal 9  Text Zeile 17)
    ! 0x91 Text 17 (Kanal 9  Text Zeile 18)
    ! 0x92 Text 18 (Kanal 10 Text Zeile 19)
    ! 0x93 Text 19 (Kanal 10 Text Zeile 20)

    ! ==================================================================================================
    var istTemp = dom.GetObject("BidCos-RF.LEQ0099367:1.TEMPERATURE").State();
    var istHum  = dom.GetObject("BidCos-RF.LEQ0099367:1.HUMIDITY").State();

    ! Temperatur aussen
    string zeile1 = "Außentemp.";
    string color1 = orange;
    string  icon1 = "0x86";

    string zeile2 = istTemp.ToString(1) # " C";
    if (istTemp >= 0.0)  { string color2 = orange; }
    if (istTemp >= 10.0) { string color2 = gelb; }
    if (istTemp >= 20.0) { string color2 = rot; }
    if (istTemp < 0.0)   { string color2 = weiss; }
    if (istTemp < -6.0)  { string color2 = blau; }
    string icon2 = "";
    ! ----------------------------------------------------------------------------------------
    var fem = dom.GetObject("Verschluss");
    string m;
    string listg;
    string listo;
    string Wo;
    integer status = 0;

    listo = "";
    listg = "";

    foreach(m, fem.EnumUsedIDs())
    {
      var item = dom.GetObject(m);
      if(item.IsTypeOf(OT_CHANNEL))
      {
        var dev = dom.GetObject(item.Device());
        if((dev.HssType()=="HM-Sec-RHS") || (dev.HssType()=="HM-Sec-SC") || (dev.HssType()=="HM-Sec-SC-2"))
        {
          var stat = item.DPByHssDP("STATE");
          if(stat.Value()== '0')               
          {
            status = status + 0;   ! geschlossen
          }
          if (stat.Value()== '1')      
          {
             status = status + 1;   ! gekippt
             Wo = dev.Name();
             Wo = Wo.StrValueByIndex("_", 1);

            listg = listg + Wo # ",";
          }
          if (stat.Value()== '2')      
          {
             status = status + 1000;   ! offen
             Wo = dev.Name();
             Wo = Wo.StrValueByIndex("_", 1);
            listo = listo + Wo # ",";
          }
        }
      }
    }

    string zeile3 = "--Fenster--";
    string color3 = weiss;
    string icon3  = "";

    ! if (status < 1000)
    ! {   ! mindestens 1 gekippt
    !    string zeile4 = "gekippt:";
    !    string color4 = "0x83";
    !    string icon4  = "";
    ! }
    !
    ! if (status >= 1000)
    ! {   ! mindestens 1 offen
    !    string zeile4 = "offen:";
    !    string color4 = "0x81";
    !    string icon4  = "";
    ! }   
    string zeile4 = "";
    string color4 = "";
    string  icon4 = "";

    string zeile5 = "";
    string color5 = "";
    string  icon5 = "";

    string zeile6 = "";
    string color6 = "";
    string  icon6   = "";

    if ( status == 0)
    {      
       ! alles zu
       string zeile4 = "geschlossen";
       string color4 = gruen;
       string  icon4 = "";
    }
    else
    {
       ! irgendwo was offen
       integer i = 4;
       foreach (nam, listo.Split(","))
       {
          if ((zeil.Length() + nam.Length()) < 12)
          {
             if (zeil == "")
             {
                zeil = nam;
             }
             else
             {
                zeil = zeil # "," # nam;
             }
          }
          else
          {

             if (i == 4)
             {
                string zeile4 = zeil;
                string color4 = rot;
                string  icon4 = "";         
             }
             if (i == 5)
             {
                string zeile5 = zeil;
                string color5 = rot;
                string  icon5 = "";         
             }
             if (i == 6)
             {
                string zeile6 = zeil;
                string color6 = rot;
                string  icon6 = "";         
             }
             zeil = nam;
             i = i + 1;
          }
       }
       if (zeil <> "")
       {
          if (i == 4)
          {
             string zeile4 = zeil;
             string color4 = rot;
             string  icon4 = "";         
          }
          if (i == 5)
          {
             string zeile5 = zeil;
             string color5 = rot;
             string  icon5 = "";         
          }
          if (i == 6)
          {
             string zeile6 = zeil;
             string color6 = rot;
             string  icon6 = "";         
          }
          zeil = "";
          i = i + 1;
          
       }

       foreach (nam, listg.Split(","))
       {
          if ((zeil.Length() + nam.Length()) < 12)
          {
             if (zeil == "")
             {
                zeil = nam;
             }
             else
             {
                zeil = zeil # "," # nam;
             }
          }
          else
          {
             if (i == 4)
             {
                string zeile4 = zeil;
                string color4 = gelb;
                string  icon4 = "";         
             }
             if (i == 5)
             {
                string zeile5 = zeil;
                string color5 = gelb;
                string  icon5 = "";         
             }
             if (i == 6)
             {
                string zeile6 = zeil;
                string color6 = gelb;
                string  icon6 = "";         
             }
             zeil = nam;
             i = i + 1;
          }
       }
       if (zeil <> "")
       {
             if (i == 4)
             {
                string zeile4 = zeil;
                string color4 = gelb;
                string  icon4 = "";         
             }
             if (i == 5)
             {
                string zeile5 = zeil;
                string color5 = gelb;
                string  icon5 = "";         
             }
             if (i == 6)
             {
                string zeile6 = zeil;
                string color6 = gelb;
                string  icon6 = "";         
             }
          zeil = "";
          i = i + 1;   
       }
    }


    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ! System Routine do not change anything below !
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    string splitter="|";
    string msgBuffer = zeile1 # splitter # color1 # splitter # icon1 # "\t";
    msgBuffer = msgBuffer # zeile2 # splitter # color2 # splitter # icon2 # "\t";
    msgBuffer = msgBuffer # zeile3 # splitter # color3 # splitter # icon3 # "\t";
    msgBuffer = msgBuffer # zeile4 # splitter # color4 # splitter # icon4 # "\t";
    msgBuffer = msgBuffer # zeile5 # splitter # color5 # splitter # icon5 # "\t";
    msgBuffer = msgBuffer # zeile6 # splitter # color6 # splitter # icon6 # "\t";

    string substitutions = "A,0x41\tB,0x42\tC,0x43\tD,0x44\tE,0x45\tF,0x46\tG,0x47\tH,0x48\tI,0x49\tJ,0x4A\tK,0x4B\tL,0x4C\tM,0x4D\tN,0x4E\tO,0x4F\tP,0x50\tQ,0x51\tR,0x52\tS,0x53\tT,0x54\tU,0x55\tV,0x56\tW,0x57\tX,0x58\tY,0x59\tZ,0x5A";
    substitutions = substitutions # "\ta,0x61\tb,0x62\tc,0x63\td,0x64\te,0x65\tf,0x66\tg,0x67\th,0x68\ti,0x69\tj,0x6A\tk,0x6B\tl,0x6C\tm,0x6D\tn,0x6E\to,0x6F\tp,0x70\tq,0x71\tr,0x72\ts,0x73\tt,0x74\tu,0x75\tv,0x76\tw,0x77\tx,0x78\ty,0x79\tz,0x7A";
    substitutions = substitutions # "\t0,0x30\t1,0x31\t2,0x32\t3,0x33\t4,0x34\t5,0x35\t6,0x36\t7,0x37\t8,0x38\t9,0x39\t ,0x20\t!,0x21\t\",0x22\t%,0x25\t&,0x26\t=,0x27\t(,0x28\t),0x29\t*,0x2A\t+,0x2B\t,,0x2C\t-,0x2D\t.,0x2E\t/,0x2F";
    substitutions = substitutions # "\tÄ,0x5B\tÖ,0x23\tÜ,0x24\tä,0x7B\tö,0x7C\tü,0x7D\tß,0x5F\t:,0x3A\t;,0x3B\t@,0x40\t>,0x3E";

    string bufferLine;
    string substEntry;

    string command = "0x02";
    integer i = 0;
    string char = "";

    foreach(bufferLine, msgBuffer)
    {
       string line = bufferLine.StrValueByIndex(splitter, 0);
       string color = bufferLine.StrValueByIndex(splitter, 1);
       string icon = bufferLine.StrValueByIndex(splitter, 2);
       if ((line <> "") || (icon <> ""))
       {
          command = command # ",0x12";
          if ((line.Substr(0,2) == "0x") && (line.Length() == 4))
          {
             command = command # "," # line;
             i = 12;
          } else {
             i = 0;
          }
          while ((i < line.Length()) && (i < 12))
          {
             char = line.Substr(i, 1);     
             foreach(substEntry, substitutions)
             {
                if (char == substEntry.Substr(0,1)){command = command # substEntry.Substr(1,5);}
             }
             i = i + 1;
          }
          command = command # ",0x11," # color;
          if (icon <> "")
          {
             command = command # ",0x13," # icon;
          }
        }
     command = command # ",0x0A";
    }
    command = command # ",0x0A,0x03";

    dom.GetObject("BidCos-RF." # dom.GetObject("$src$").Name().StrValueByIndex(".",1) # ".SUBMIT").State(command);



DrTob
Beiträge: 3426
Registriert: 29.10.2010, 08:24
Danksagung erhalten: 5 Mal

Re: Display HM-Dis-WM55 Beispielscript

Beitrag von DrTob » 30.12.2014, 21:42

es fehlen die Deklarationen von nam und zeil.

hier korrigiert:

Code: Alles auswählen

!! Display 1 Taste2 kurz                                                        
!! 
!! Universalprogramm zum Füllen                                                  
!! (c) DrTob 
!! optimized by thkl
!! 
!! überarbeitet geosshark 30.12.2014 11:48:00
!! Anzeige der Aussentemperatur und der Stati aller Fenster, die mit dem 
!! Drehgriffsensor (nur mit diesem getestet) ausgerüstet sind.
!! Alle Sensoren müssen im Gewerk "Fenster" sein.
!! Die Namenskonvention der Sensoren : z.B. xx_Bad_yyy_zz..., der 2. mit "_" getrennt Parameter wird angezeigt, hier "Bad".

!! Das Script holt sich jetzt die Seriennummer des Displays selbst aus der Auslösebedingung des Programms

! Farben
! 0x80 weiß
! 0x81 rot
! 0x82 orange
! 0x83 gelb
! 0x84 gruen
! 0x85 blau 
string weiss  = "0x80";
string rot    = "0x81";
string orange = "0x82";
string gelb   = "0x83";
string gruen  = "0x84";
string blau   = "0x85";

! Symbole 
! 
! 0x80 AUS
! 0x81 EIN
! 0x82 OFFEN
! 0x83 geschlossen
! 0x84 fehler
! 0x85 alles ok
! 0x86 information
! 0x87 neue nachricht
! 0x88 servicemeldung
! 0x89 Signal grün
! 0x8A Signal gelb
! 0x8B Signal rot

! Zugriff auf vordefinierte Texte
! 
! 0x80 Text  0 (Kanal 1  Text Zeile 1)
! 0x81 Text  1 (Kanal 1  Text Zeile 2)
! 0x82 Text  2 (Kanal 2  Text Zeile 3)
! 0x83 Text  3 (Kanal 2  Text Zeile 4)
! 0x84 Text  4 (Kanal 3  Text Zeile 5)
! 0x85 Text  5 (Kanal 3  Text Zeile 6)
! 0x86 Text  6 (Kanal 4  Text Zeile 7)
! 0x87 Text  7 (Kanal 4  Text Zeile 8)
! 0x88 Text  8 (Kanal 5  Text Zeile 9)
! 0x89 Text  9 (Kanal 5  Text Zeile 10)
! 0x8A Text 10 (Kanal 6  Text Zeile 11)
! 0x8B Text 11 (Kanal 6  Text Zeile 12)
! 0x8C Text 12 (Kanal 7  Text Zeile 13)
! 0x8D Text 13 (Kanal 7  Text Zeile 14)
! 0x8E Text 14 (Kanal 8  Text Zeile 15)
! 0x8F Text 15 (Kanal 8  Text Zeile 16)
! 0x90 Text 16 (Kanal 9  Text Zeile 17)
! 0x91 Text 17 (Kanal 9  Text Zeile 18)
! 0x92 Text 18 (Kanal 10 Text Zeile 19)
! 0x93 Text 19 (Kanal 10 Text Zeile 20)

! ==================================================================================================
var istTemp = dom.GetObject("BidCos-RF.LEQ0099367:1.TEMPERATURE").State();
var istHum  = dom.GetObject("BidCos-RF.LEQ0099367:1.HUMIDITY").State();

! Temperatur aussen
string zeile1 = "Außentemp.";
string color1 = orange;
string  icon1 = "0x86";

string zeile2 = istTemp.ToString(1) # " C";
if (istTemp >= 0.0)  { string color2 = orange; }
if (istTemp >= 10.0) { string color2 = gelb; }
if (istTemp >= 20.0) { string color2 = rot; }
if (istTemp < 0.0)   { string color2 = weiss; }
if (istTemp < -6.0)  { string color2 = blau; }
string icon2 = "";
! ----------------------------------------------------------------------------------------
var fem = dom.GetObject("Fenster");
string m;
string listg;
string listo;
string Wo;
integer status = 0;
string nam;
string zeil = "";

listo = "";
listg = "";

foreach(m, fem.EnumUsedIDs())
{
  var item = dom.GetObject(m);
  if(item.IsTypeOf(OT_CHANNEL))
  {
    var dev = dom.GetObject(item.Device());
    if((dev.HssType()=="HM-Sec-RHS") || (dev.HssType()=="HM-Sec-SC") || (dev.HssType()=="HM-Sec-SC-2"))
    {
      var stat = item.DPByHssDP("STATE");
      if(stat.Value()== '0')               
      {
        status = status + 0;   ! geschlossen
      }
      if (stat.Value()== '1')      
      {
         status = status + 1;   ! gekippt
         Wo = dev.Name();
         Wo = Wo.StrValueByIndex("_", 1);

        listg = listg + Wo # ",";
      }
      if (stat.Value()== '2')      
      {
         status = status + 1000;   ! offen
         Wo = dev.Name();
         Wo = Wo.StrValueByIndex("_", 1);
        listo = listo + Wo # ",";
      }
    }
  }
}

string zeile3 = "--Fenster--";
string color3 = weiss;
string icon3  = "";

! if (status < 1000)
! {   ! mindestens 1 gekippt
!    string zeile4 = "gekippt:";
!    string color4 = "0x83";
!    string icon4  = "";
! } 
! 
! if (status >= 1000)
! {   ! mindestens 1 offen
!    string zeile4 = "offen:";
!    string color4 = "0x81";
!    string icon4  = "";
! }   
string zeile4 = "";
string color4 = "";
string  icon4 = "";

string zeile5 = "";
string color5 = "";
string  icon5 = "";

string zeile6 = "";
string color6 = "";
string  icon6   = "";


if ( status == 0)
{      
   ! alles zu
   string zeile4 = "geschlossen";
   string color4 = gruen;
   string  icon4 = "";
}
else
{
   ! irgendwo was offen
   integer i = 4;
   foreach (nam, listo.Split(","))
   {
      if ((zeil.Length() + nam.Length()) < 12)
      {
         if (zeil == "")
         {
            zeil = nam;
         } 
         else 
         {
            zeil = zeil # "," # nam;
         }
      }
      else
      {

         if (i == 4)
         {
            string zeile4 = zeil;
            string color4 = rot;
            string  icon4 = "";         
         }
         if (i == 5)
         {
            string zeile5 = zeil;
            string color5 = rot;
            string  icon5 = "";         
         }
         if (i == 6)
         {
            string zeile6 = zeil;
            string color6 = rot;
            string  icon6 = "";         
         }
         zeil = nam;
         i = i + 1;
      }
   }
   if (zeil <> "")
   {
      if (i == 4)
      {
         string zeile4 = zeil;
         string color4 = rot;
         string  icon4 = "";         
      }
      if (i == 5)
      {
         string zeile5 = zeil;
         string color5 = rot;
         string  icon5 = "";         
      }
      if (i == 6)
      {
         string zeile6 = zeil;
         string color6 = rot;
         string  icon6 = "";         
      }
      zeil = "";
      i = i + 1;
      
   }

   foreach (nam, listg.Split(","))
   {
      if ((zeil.Length() + nam.Length()) < 12)
      {
         if (zeil == "")
         {
            zeil = nam;
         } 
         else 
         {
            zeil = zeil # "," # nam;
         }
      }
      else
      {
         if (i == 4)
         {
            string zeile4 = zeil;
            string color4 = gelb;
            string  icon4 = "";         
         }
         if (i == 5)
         {
            string zeile5 = zeil;
            string color5 = gelb;
            string  icon5 = "";         
         }
         if (i == 6)
         {
            string zeile6 = zeil;
            string color6 = gelb;
            string  icon6 = "";         
         }
         zeil = nam;
         i = i + 1;
      }
   }
   if (zeil <> "")
   {
         if (i == 4)
         {
            string zeile4 = zeil;
            string color4 = gelb;
            string  icon4 = "";         
         }
         if (i == 5)
         {
            string zeile5 = zeil;
            string color5 = gelb;
            string  icon5 = "";         
         }
         if (i == 6)
         {
            string zeile6 = zeil;
            string color6 = gelb;
            string  icon6 = "";         
         }
      zeil = "";
      i = i + 1;   
   }
}


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! System Routine do not change anything below !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

string splitter="|";
string msgBuffer = zeile1 # splitter # color1 # splitter # icon1 # "\t";
msgBuffer = msgBuffer # zeile2 # splitter # color2 # splitter # icon2 # "\t";
msgBuffer = msgBuffer # zeile3 # splitter # color3 # splitter # icon3 # "\t";
msgBuffer = msgBuffer # zeile4 # splitter # color4 # splitter # icon4 # "\t";
msgBuffer = msgBuffer # zeile5 # splitter # color5 # splitter # icon5 # "\t";
msgBuffer = msgBuffer # zeile6 # splitter # color6 # splitter # icon6 # "\t";

string substitutions = "A,0x41\tB,0x42\tC,0x43\tD,0x44\tE,0x45\tF,0x46\tG,0x47\tH,0x48\tI,0x49\tJ,0x4A\tK,0x4B\tL,0x4C\tM,0x4D\tN,0x4E\tO,0x4F\tP,0x50\tQ,0x51\tR,0x52\tS,0x53\tT,0x54\tU,0x55\tV,0x56\tW,0x57\tX,0x58\tY,0x59\tZ,0x5A";
substitutions = substitutions # "\ta,0x61\tb,0x62\tc,0x63\td,0x64\te,0x65\tf,0x66\tg,0x67\th,0x68\ti,0x69\tj,0x6A\tk,0x6B\tl,0x6C\tm,0x6D\tn,0x6E\to,0x6F\tp,0x70\tq,0x71\tr,0x72\ts,0x73\tt,0x74\tu,0x75\tv,0x76\tw,0x77\tx,0x78\ty,0x79\tz,0x7A";
substitutions = substitutions # "\t0,0x30\t1,0x31\t2,0x32\t3,0x33\t4,0x34\t5,0x35\t6,0x36\t7,0x37\t8,0x38\t9,0x39\t ,0x20\t!,0x21\t\",0x22\t%,0x25\t&,0x26\t=,0x27\t(,0x28\t),0x29\t*,0x2A\t+,0x2B\t,,0x2C\t-,0x2D\t.,0x2E\t/,0x2F";
substitutions = substitutions # "\tÄ,0x5B\tÖ,0x23\tÜ,0x24\tä,0x7B\tö,0x7C\tü,0x7D\tß,0x5F\t:,0x3A\t;,0x3B\t@,0x40\t>,0x3E"; 

string bufferLine;
string substEntry;

string command = "0x02";
integer i = 0;
string char = "";

foreach(bufferLine, msgBuffer) 
{
   string line = bufferLine.StrValueByIndex(splitter, 0);
   string color = bufferLine.StrValueByIndex(splitter, 1);
   string icon = bufferLine.StrValueByIndex(splitter, 2);
   if ((line <> "") || (icon <> "")) 
   {
      command = command # ",0x12";
      if ((line.Substr(0,2) == "0x") && (line.Length() == 4)) 
      {
         command = command # "," # line;
         i = 12;
      } else {
         i = 0;
      }
      while ((i < line.Length()) && (i < 12)) 
      { 
         char = line.Substr(i, 1);     
         foreach(substEntry, substitutions)
         {
            if (char == substEntry.Substr(0,1)){command = command # substEntry.Substr(1,5);}
         }
         i = i + 1; 
      }
      command = command # ",0x11," # color;
      if (icon <> "") 
      {
         command = command # ",0x13," # icon;
      }
    }
 command = command # ",0x0A";
}
command = command # ",0x0A,0x03";

dom.GetObject("BidCos-RF." # dom.GetObject("$src$").Name().StrValueByIndex(".",1) # ".SUBMIT").State(command);
PS: die Funktionalität selbst habe ich nicht geprüft. Aber zumindest syntaktisch ist es nun korrekt.

lötix
Beiträge: 347
Registriert: 10.03.2014, 18:41

Re: Display HM-Dis-WM55 Beispielscript

Beitrag von lötix » 30.12.2014, 21:49

Moin.....

also die Scriptprüfung gibt jetzt nen "kein Fehler" aus, soweit läuft das gut durch. Aber am Taster erscheint nach wie vor: "keine Daten empfangen"

mfg lötix

GeosShark
Beiträge: 26
Registriert: 25.10.2014, 13:03
Wohnort: Dresden

Re: Display HM-Dis-WM55 Beispielscript

Beitrag von GeosShark » 31.12.2014, 13:08

Hai,

in dem Script steht aber immer noch das Gewerk "Fenster"....
-------------------------------------------------------------------
Gruß
Frank
__________________________________________________________________
Signatur verboten

lötix
Beiträge: 347
Registriert: 10.03.2014, 18:41

Re: Display HM-Dis-WM55 Beispielscript

Beitrag von lötix » 31.12.2014, 14:00

Moin....

den Eintrag habe ich bei mir eben in "Verschluss" geändert. Auch die Bezeichnung von HM-Sec-SC in HM-Sec-SCo. Genau so musst du ja noch die Adresse das Aussenfühlers anpassen. Die Temperatur wird ja angezeigt in Zeile 1 und 2. In Zeile 3 ist dann "-Verschluss-" zu lesen. Die Zeilen 4-6 bleiben leer. Wie sind denn die Tasten im Programm zugewiesen? Vlt. ist da ja noch nen Fehler bei mir.
IMG_0742.JPG
prg.jpg
mfg lötix

DrTob
Beiträge: 3426
Registriert: 29.10.2010, 08:24
Danksagung erhalten: 5 Mal

Re: Display HM-Dis-WM55 Beispielscript

Beitrag von DrTob » 31.12.2014, 14:19

GeosShark hat geschrieben:Hai,

in dem Script steht aber immer noch das Gewerk "Fenster"....
ja, der Fehler war schon in dem Originalskript von dir. Das habe ich korrigiert. Die Anpassung hatte lötix gar nicht gepostet. (sondern nur die Fehlermeldung)

GeosShark
Beiträge: 26
Registriert: 25.10.2014, 13:03
Wohnort: Dresden

Re: Display HM-Dis-WM55 Beispielscript

Beitrag von GeosShark » 31.12.2014, 14:41

Hai,

Code: Alles auswählen

var fem = dom.GetObject("Fenster");
Hier musst Du statt "Fenster" "Verschluss" eintragen.

Ich weiß nicht, welche Fenstersensoren Du benutzt...
Ich habe derzeit nur die Drehgriffsensoren ( HM-Sec-RHS ).
Diese liefern über den Inhalt des Datenpunktes "STATE" die Werte 0 für geschlossen, 1 für gekippt und 2 für offen.
Das wird dann ausgewertet. Welche Werte andere Sensoren liefern, kann ich nicht sagen. Da aber die Abfrage der 3 Sensortypen aus dem Forum stammt, wird das schon richtig sein.
-------------------------------------------------------------------
Gruß
Frank
__________________________________________________________________
Signatur verboten

lötix
Beiträge: 347
Registriert: 10.03.2014, 18:41

Re: Display HM-Dis-WM55 Beispielscript

Beitrag von lötix » 31.12.2014, 14:49

Moin....

jetzt habe ich's: Du hast den Unterstrich als Trenner benutzt und ausgewertet. Meine Geräte haben nen Leerzeichen als Trenner. Nur wo zeigst du denn die Luftfeuchte "istHum" an? Dann zeigt der MH-Sec-RHS zwar richtig bei kipp und offen an, aber die beiden HM-Sec-SCo und HM-Sec-SC-2 werden zwei Mal angezeigt, bei kipp und offen.

mfg lötix
IMG_0744.JPG

GeosShark
Beiträge: 26
Registriert: 25.10.2014, 13:03
Wohnort: Dresden

Re: Display HM-Dis-WM55 Beispielscript

Beitrag von GeosShark » 31.12.2014, 15:01

Hai,
steht doch oben im Kommentar....

Die Luftfeuchte zeige ich da nicht mehr an... Ist ein Überbleibsel...
-------------------------------------------------------------------
Gruß
Frank
__________________________________________________________________
Signatur verboten

Antworten

Zurück zu „HomeMatic Aktoren und Sensoren (klassisch)“