Subversion Repositories HomeAutomation

Rev

Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
1603 runge 1
 
1624 runge 2
RequireModule("irReceive");
3
RequireModule("irTransmit");
4
RequireModule("Dimmer230");
5
 
1603 runge 6
var dimmer_module = GetModule("Dimmer230");
7
var ir_module = GetModule("irReceive");
8
 
9
function test_press(event, id, channel, data, protocol)
10
{
1619 runge 11
    Log("Pressed: protocol=" + protocol + ", channel=" + channel + ", data=" + data);
12
 
1603 runge 13
    if (protocol == "NEC" && data == 3877174275)
14
    {
1609 runge 15
        Dimmer230_StartFade(2, 0, 135, "Increase");
16
        Dimmer230_StartFade(1, 0, 135, "Increase");
1603 runge 17
    }
18
    else if (protocol == "NEC" && data == 3860462595)
19
    {
1609 runge 20
        Dimmer230_StartFade(2, 0, 135, "Decrease");
21
        Dimmer230_StartFade(1, 0, 135, "Decrease");
1603 runge 22
    }
1619 runge 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
    }
1603 runge 31
}
32
 
33
function test_release(event, id, channel, data, protocol)
34
{
1619 runge 35
    Log("Released: protocol=" + protocol + ", channel=" + channel + ", data=" + data);
36
 
1603 runge 37
    if (protocol == "NEC" && (data == 3877174275 || data == 3860462595))
38
    {
1609 runge 39
        Dimmer230_StopFade(2, 0);
1619 runge 40
        Dimmer230_StopFade(1, 0);
1603 runge 41
    }
1619 runge 42
    else if (protocol == "NEC" && (data == 4144561155 || data == 4211407875))
43
    {
44
        //irTransmit_SendCode(1, 0, "Released", "NEC", data);
45
    }
1603 runge 46
}
47
 
48
function test_status(event, id, available)
49
{
1610 runge 50
    //Log("status change!");
1603 runge 51
}
52
 
1624 runge 53
ir_module.Bind("onStatusChange", test_status);
54
ir_module.Bind("onPressed", test_press);
55
ir_module.Bind("onReleased", test_release);
1603 runge 56
 
1608 runge 57
 
58
 
1614 runge 59
 
1620 runge 60
 
1625 runge 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" ]); });