Subversion Repositories HomeAutomation

Rev

Rev 1614 | Go to most recent revision | Blame | Last modification | View Log | SVN | RSS feed

  1.  
  2. var dimmer_module = GetModule("Dimmer230");
  3. var ir_module = GetModule("irReceive");
  4.  
  5. function test_press(event, id, channel, data, protocol)
  6. {
  7.     Log("Pressed: protocol=" + protocol + ", channel=" + channel + ", data=" + data);
  8.    
  9.     if (protocol == "NEC" && data == 3877174275)
  10.     {
  11.         Dimmer230_StartFade(2, 0, 135, "Increase");
  12.         Dimmer230_StartFade(1, 0, 135, "Increase");
  13.     }
  14.     else if (protocol == "NEC" && data == 3860462595)
  15.     {
  16.         Dimmer230_StartFade(2, 0, 135, "Decrease");
  17.         Dimmer230_StartFade(1, 0, 135, "Decrease");
  18.     }
  19.     else if (protocol == "NEC" && data == 4144561155)
  20.     {
  21.         irTransmit_SendCode(1, 0, "Burst", "NEC", 3843720570);
  22.     }
  23.     else if (protocol == "NEC" && data == 4211407875)
  24.     {
  25.         irTransmit_SendCode(1, 0, "Burst", "NEC", 3827008890);
  26.     }
  27. }
  28.  
  29. function test_release(event, id, channel, data, protocol)
  30. {
  31.     Log("Released: protocol=" + protocol + ", channel=" + channel + ", data=" + data);
  32.    
  33.     if (protocol == "NEC" && (data == 3877174275 || data == 3860462595))
  34.     {
  35.         Dimmer230_StopFade(2, 0);
  36.         Dimmer230_StopFade(1, 0);
  37.     }
  38.     else if (protocol == "NEC" && (data == 4144561155 || data == 4211407875))
  39.     {
  40.         //irTransmit_SendCode(1, 0, "Released", "NEC", data);
  41.     }
  42. }
  43.  
  44. function test_status(event, id, available)
  45. {
  46.     //Log("status change!");
  47. }
  48.  
  49. ir_module.Bind("onStatusChange", test_status);
  50. ir_module.Bind("onPressed", test_press);
  51. ir_module.Bind("onReleased", test_release);
  52.  
  53.  
  54. /*CreateModuleAlias("bardisk", "Dimmer230", 2, { "channel" : 0 });
  55. CreateModuleAlias("bokhylla", "Dimmer230", 1, { "channel" : 0 });
  56. CreateModuleAliasGroup("vardagsrum", [ "bokhylla", "bardisk" ]);
  57. */
  58.  
  59. function fadeto(alias, level, speed)
  60. {
  61.     var alias_data = resolvealias(alias);
  62.    
  63.     if (alias_data == null)
  64.     {
  65.         return "No such module name found";
  66.     }
  67.    
  68.     if (alias_data["is_group"])
  69.     {
  70.         var result = "";
  71.        
  72.         for (var n = 0; n < alias_data["aliases"].length; n++)
  73.         {
  74.             result += fadeto(alias_data["aliases"][n], level, speed) + "\n";
  75.         }
  76.        
  77.         return result;
  78.     }
  79.    
  80.     if (alias_data["module_name"] != "Dimmer230")
  81.     {
  82.         return "Module type " + alias_data["module_name"] + " is not valid for this action, valid are Dimmer230";
  83.     }
  84.    
  85.     if (!speed)
  86.     {
  87.         speed = 135;
  88.     }
  89.  
  90.     return Dimmer230_AbsoluteFade(alias_data["module_id"], alias_data["extra"], speed, level);
  91. }
  92.  
  93. RegisterConsoleCommand(fadeto, function(args) { return StandardAutocomplete(args, Dimmer230.instance_.GetAvailableNames(), [ 0, 50, 100, 150, 200, 255 ], [ 50, 135, 200, 255 ]); });
  94.