Subversion Repositories HomeAutomation

Rev

Rev 1614 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1614 Rev 1619
Line 2... Line 2...
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);
-
 
8
   
7
    if (protocol == "NEC" && data == 3877174275)
9
    if (protocol == "NEC" && data == 3877174275)
8
    {
10
    {
9
        Dimmer230_StartFade(2, 0, 135, "Increase");
11
        Dimmer230_StartFade(2, 0, 135, "Increase");
10
        Dimmer230_StartFade(1, 0, 135, "Increase");
12
        Dimmer230_StartFade(1, 0, 135, "Increase");
11
    }
13
    }
12
    else if (protocol == "NEC" && data == 3860462595)
14
    else if (protocol == "NEC" && data == 3860462595)
13
    {
15
    {
14
        Dimmer230_StartFade(2, 0, 135, "Decrease");
16
        Dimmer230_StartFade(2, 0, 135, "Decrease");
15
        Dimmer230_StartFade(1, 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);
16
    }
26
    }
17
}
27
}
18
 
28
 
19
function test_release(event, id, channel, data, protocol)
29
function test_release(event, id, channel, data, protocol)
20
{
30
{
-
 
31
    Log("Released: protocol=" + protocol + ", channel=" + channel + ", data=" + data);
-
 
32
   
21
    if (protocol == "NEC" && (data == 3877174275 || data == 3860462595))
33
    if (protocol == "NEC" && (data == 3877174275 || data == 3860462595))
22
    {
34
    {
23
        Dimmer230_StopFade(2, 0);
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
    }
24
    }
42
}
25
}
-
 
26
 
43
 
27
function test_status(event, id, available)
44
function test_status(event, id, available)
28
{
45
{
29
    //Log("status change!");
46
    //Log("status change!");
30
}
47
}
Line 32... Line 49...
32
ir_module.Bind("onStatusChange", test_status);
49
ir_module.Bind("onStatusChange", test_status);
33
ir_module.Bind("onPressed", test_press);
50
ir_module.Bind("onPressed", test_press);
34
ir_module.Bind("onReleased", test_release);
51
ir_module.Bind("onReleased", test_release);
35
 
52
 
36
 
53
 
37
CreateModuleAlias("bardisk", "Dimmer230", 2, { "channel" : 0 });
54
/*CreateModuleAlias("bardisk", "Dimmer230", 2, { "channel" : 0 });
38
CreateModuleAlias("bokhylla", "Dimmer230", 1, { "channel" : 0 });
55
CreateModuleAlias("bokhylla", "Dimmer230", 1, { "channel" : 0 });
39
CreateModuleAliasGroup("vardagsrum", [ "bokhylla", "bardisk" ]);
56
CreateModuleAliasGroup("vardagsrum", [ "bokhylla", "bardisk" ]);
40
 
57
*/
41
 
58
 
42
function fadeto(alias, level, speed)
59
function fadeto(alias, level, speed)
43
{
60
{
-
 
61
    var alias_data = resolvealias(alias);
-
 
62
   
44
    if (typeof module_aliases[alias] == 'undefined')
63
    if (alias_data == null)
45
    {
64
    {
46
        return "No such module name found";
65
        return "No such module name found";
47
    }
66
    }
48
   
67
   
49
    if (module_aliases[alias]["is_group"])
68
    if (alias_data["is_group"])
50
    {
69
    {
51
        var result = "";
70
        var result = "";
52
       
71
       
53
        for (var n = 0; n < module_aliases[alias]["aliases"].length; n++)
72
        for (var n = 0; n < alias_data["aliases"].length; n++)
54
        {
73
        {
55
            result += fadeto(module_aliases[alias]["aliases"][n], level, speed) + "\n";
74
            result += fadeto(alias_data["aliases"][n], level, speed) + "\n";
56
        }
75
        }
57
       
76
       
58
        return result;
77
        return result;
59
    }
78
    }
60
   
79
   
61
    if (module_aliases[alias]["module_name"] != "Dimmer230")
80
    if (alias_data["module_name"] != "Dimmer230")
62
    {
81
    {
63
        return "Module type " + module_aliases[alias]["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";
64
    }
83
    }
65
   
84
   
66
    if (!speed)
85
    if (!speed)
67
    {
86
    {
68
        speed = 135;
87
        speed = 135;
69
    }
88
    }
70
 
89
 
71
    return Dimmer230_AbsoluteFade(module_aliases[alias]["module_id"], module_aliases[alias]["extra"]["channel"], speed, level);
90
    return Dimmer230_AbsoluteFade(alias_data["module_id"], alias_data["extra"], speed, level);
72
}
91
}
73
 
92
 
74
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 ]); });