Subversion Repositories HomeAutomation

Rev

Rev 1625 | Blame | Last modification | View Log | SVN | RSS feed

  1.  
  2. RequireModule("irReceive");
  3. RequireModule("irTransmit");
  4. RequireModule("Dimmer230");
  5.  
  6. var dimmer_module = GetModule("Dimmer230");
  7. var ir_module = GetModule("irReceive");
  8.  
  9. function test_press(event, id, channel, data, protocol)
  10. {
  11.     Log("Pressed: protocol=" + protocol + ", channel=" + channel + ", data=" + data);
  12.    
  13.     if (protocol == "NEC" && data == 3877174275)
  14.     {
  15.         Dimmer230_StartFade(2, 0, 135, "Increase");
  16.         Dimmer230_StartFade(1, 0, 135, "Increase");
  17.     }
  18.     else if (protocol == "NEC" && data == 3860462595)
  19.     {
  20.         Dimmer230_StartFade(2, 0, 135, "Decrease");
  21.         Dimmer230_StartFade(1, 0, 135, "Decrease");
  22.     }
  23.     else if (protocol == "NEC" && data == 4144561155)
  24.     {
  25.         irTransmit_SendCode(1, 0, "Burst", "NEC", 3843720570);
  26.     }
  27.     else if (protocol == "NEC" && data == 4211407875)
  28.     {
  29.         irTransmit_SendCode(1, 0, "Burst", "NEC", 3827008890);
  30.     }
  31. }
  32.  
  33. function test_release(event, id, channel, data, protocol)
  34. {
  35.     Log("Released: protocol=" + protocol + ", channel=" + channel + ", data=" + data);
  36.    
  37.     if (protocol == "NEC" && (data == 3877174275 || data == 3860462595))
  38.     {
  39.         Dimmer230_StopFade(2, 0);
  40.         Dimmer230_StopFade(1, 0);
  41.     }
  42.     else if (protocol == "NEC" && (data == 4144561155 || data == 4211407875))
  43.     {
  44.         //irTransmit_SendCode(1, 0, "Released", "NEC", data);
  45.     }
  46. }
  47.  
  48. function test_status(event, id, available)
  49. {
  50.     //Log("status change!");
  51. }
  52.  
  53. ir_module.Bind("onStatusChange", test_status);
  54. ir_module.Bind("onPressed", test_press);
  55. ir_module.Bind("onReleased", test_release);
  56.  
  57.  
  58.  
  59.  
  60.  
  61. function media(mode)
  62. {
  63.     if (!mode)
  64.     {
  65.         return "You must specify a mode";
  66.     }
  67.    
  68.     if (mode == "movie")
  69.     {
  70.         irsend("tvbankut", "Yamaha_RAV34", "POWER");
  71.        
  72.         fadeto("bokhylla", 100, 135);
  73.         fadeto("bardisk", 0, 135);
  74.  
  75.         sleep(1000);
  76.         irsend("tvbankut", "Yamaha_RAV34", "CD");
  77.     }
  78.     else if (mode == "tv")
  79.     {
  80.         irsend("tvbankut", "Yamaha_RAV34", "POWER");
  81.        
  82.         fadeto("bokhylla", 150, 135);
  83.         fadeto("bardisk", 150, 135);
  84.  
  85.         sleep(1000);
  86.         irsend("tvbankut", "Yamaha_RAV34", "DTV_CBL");
  87.     }
  88.     else if (mode == "off")
  89.     {
  90.         irsend("tvbankut", "Yamaha_RAV34", "STANDBY");
  91.        
  92.         fadeto("bokhylla", 0, 135);
  93.         fadeto("bardisk", 0, 135);
  94.     }
  95.    
  96.     return "OK";
  97. }
  98. RegisterConsoleCommand(media, function(args) { return StandardAutocomplete(args, [ "off", "tv", "movie" ]); });
  99.