Subversion Repositories HomeAutomation

Rev

Rev 1619 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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