Subversion Repositories HomeAutomation

Rev

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

Rev 1648 Rev 1649
Line 40... Line 40...
40
function IRIn_Record(alias_name, remote_name)
40
function IRIn_Record(alias_name, remote_name)
41
{
41
{
42
   
42
   
43
    if (arguments.length < 2)
43
    if (arguments.length < 2)
44
    {
44
    {
45
        Log("\033[31;1mNot enough parameters given.\033[0m\n");
45
        Log("\033[31mNot enough parameters given.\033[0m\n");
46
        return false;
46
        return false;
47
    }
47
    }
48
   
48
   
49
    IRIn_RecordRemoteName = Storage_GetParameter("RemoteList", remote_name);
49
    IRIn_RecordRemoteName = Storage_GetParameter("RemoteList", remote_name);
50
   
50
   
51
    if (!IRIn_RecordRemoteName)
51
    if (!IRIn_RecordRemoteName)
52
    {
52
    {
53
        IRIn_RecordRemoteName = "Remote_" + remote_name;
53
        IRIn_RecordRemoteName = "Remote_" + remote_name;
54
       
54
       
55
        Log("\033[32;1mNo such remote name in list, " + remote_name + ", creating...\033[0m\n");
55
        Log("\033[32mNo such remote name in list, " + remote_name + ", creating...\033[0m\n");
56
       
56
       
57
        Storage_SetParameter("RemoteList", remote_name, IRIn_RecordRemoteName);
57
        Storage_SetParameter("RemoteList", remote_name, IRIn_RecordRemoteName);
58
    }
58
    }
59
   
59
   
60
    var aliases_data = Module_ResolveAlias(alias_name, IRIn_ModuleNames);
60
    var aliases_data = Module_ResolveAlias(alias_name, IRIn_ModuleNames);
61
   
61
   
62
    for (var name in aliases_data)
62
    for (var name in aliases_data)
63
    {
63
    {
64
        if (aliases_data[name]["group"])
64
        if (aliases_data[name]["group"])
65
        {
65
        {
66
            Log("\033[31;1mAlias must not be an alias group.\033[0m\n");
66
            Log("\033[31mAlias must not be an alias group.\033[0m\n");
67
            return false;
67
            return false;
68
        }
68
        }
69
       
69
       
70
        IRIn_RecordAliasData = aliases_data[name];
70
        IRIn_RecordAliasData = aliases_data[name];
71
        Log("Enter a single dot to finish.\n");
71
        Log("Enter a single dot to finish.\n");
72
       
72
       
73
        Log("\033[29;1mPress a button on you remote...\033[0m\n");
73
        Log("\033[29mPress a button on you remote...\033[0m\n");
74
        Console_PreventDefaultPrompt();
74
        Console_PreventDefaultPrompt();
75
   
75
   
76
        Module_RegisterToOnMessage(alias_name, IRIn_RecordOnIrMessage);
76
        Module_RegisterToOnMessage(alias_name, IRIn_RecordOnIrMessage);
77
        return true;
77
        return true;
78
    }
78
    }
79
   
79
   
80
    Log("\033[31;1mNo such alias name found, " + alias_name + ".\033[0m\n");
80
    Log("\033[31mNo such alias name found, " + alias_name + ".\033[0m\n");
81
    return false;
81
    return false;
82
   
82
   
83
}
83
}
84
Console_RegisterCommand(IRIn_Record, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, IRIn_Aliases(), IRIn_Remotes()); });
84
Console_RegisterCommand(IRIn_Record, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, IRIn_Aliases(), IRIn_Remotes()); });
85
 
85
 
Line 91... Line 91...
91
    }
91
    }
92
   
92
   
93
    Storage_SetParameter(IRIn_RecordRemoteName, response, JSON.stringify(IRIn_RecordLast));
93
    Storage_SetParameter(IRIn_RecordRemoteName, response, JSON.stringify(IRIn_RecordLast));
94
    IRIn_RecordLast = null;
94
    IRIn_RecordLast = null;
95
   
95
   
96
    Log("\033[29;1mPress a button on you remote...\033[0m\n");
96
    Log("\033[29mPress a button on you remote...\033[0m\n");
97
    Console_PreventDefaultPrompt();
97
    Console_PreventDefaultPrompt();
98
   
98
   
99
    return true;
99
    return true;
100
}
100
}
101
 
101
 
Line 104... Line 104...
104
    if (variables["Status"] != "Pressed" || IRIn_RecordLast != null)
104
    if (variables["Status"] != "Pressed" || IRIn_RecordLast != null)
105
    {
105
    {
106
        return;
106
        return;
107
    }
107
    }
108
   
108
   
109
    Log("\033[32;1mGot code " + variables["IRdata"] + " on protocol " + variables["Protocol"] + ".\033[0m\n");
109
    Log("\033[32mGot code " + variables["IRdata"] + " on protocol " + variables["Protocol"] + ".\033[0m\n");
110
   
110
   
111
    IRIn_RecordLast = { "protocol" : variables["Protocol"], "data" : variables["IRdata"] };
111
    IRIn_RecordLast = { "protocol" : variables["Protocol"], "data" : variables["IRdata"] };
112
   
112
   
113
    Console_PromptRequest("\033[29;1mEnter name: \033[0m", IRIn_RecordOnResponse);
113
    Console_PromptRequest("\033[29mEnter name: \033[0m", IRIn_RecordOnResponse);
114
   
114
   
115
    return true;
115
    return true;
116
}
116
}
117
 
117
 
118
 
118