Subversion Repositories HomeAutomation

Rev

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

Rev 2117 Rev 2123
Line 155... Line 155...
155
function IROut_SendBurst_Raw(alias_name, protocol, data)
155
function IROut_SendBurst_Raw(alias_name, protocol, data)
156
{
156
{
157
    return IROut_Send_Raw(alias_name, protocol, data, "Burst");
157
    return IROut_Send_Raw(alias_name, protocol, data, "Burst");
158
}
158
}
159
Console_RegisterCommand(IROut_SendBurst_Raw, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, IROut_Aliases(), IROut_Protocols()); });
159
Console_RegisterCommand(IROut_SendBurst_Raw, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, IROut_Aliases(), IROut_Protocols()); });
-
 
160
 
-
 
161
function IROut_SendDimmer(alias_name, remote_name, button_name, level)
-
 
162
{
-
 
163
    if (arguments.length < 4)
-
 
164
    {
-
 
165
        Log("\033[31mNot enough parameters given.\033[0m\n");
-
 
166
        return false;
-
 
167
    }
-
 
168
   
-
 
169
    var remote_storage_name = Storage_GetParameter("RemoteList", remote_name);
-
 
170
   
-
 
171
    if (!remote_storage_name)
-
 
172
    {
-
 
173
        Log("\033[31mNo such remote name in list, " + remote_name + ".\033[0m\n");
-
 
174
        return false;
-
 
175
    }
-
 
176
   
-
 
177
    var button_string = Storage_GetParameter(remote_storage_name, button_name);
-
 
178
   
-
 
179
    if (!button_string)
-
 
180
    {
-
 
181
        Log("\033[31mNo such button " + button_name + " found on remote " + remote + ".\033[0m\n");
-
 
182
        return false;
-
 
183
    }
-
 
184
   
-
 
185
    var button_data = eval("(" + button_string + ")");
-
 
186
   
-
 
187
    if (typeof button_data["protocol"] == 'undefined' || typeof button_data["data"] == 'undefined')
-
 
188
    {
-
 
189
        Log("\033[31mButton data is corrupt.\033[0m\n");
-
 
190
        return false;
-
 
191
    }  
-
 
192
    levelInt = parseInt(level);
-
 
193
    dataInt = parseInt(button_data["data"]);
-
 
194
    if (levelInt  >= 0 && levelInt <= 15) {
-
 
195
        switch(levelInt) {
-
 
196
          case 0:
-
 
197
            levelInt = 15;
-
 
198
            break;
-
 
199
          case 1:
-
 
200
            levelInt = 7;
-
 
201
            break;
-
 
202
          case 2:
-
 
203
            levelInt = 11;
-
 
204
            break;
-
 
205
          case 3:
-
 
206
            levelInt = 3;
-
 
207
            break;
-
 
208
          case 4:
-
 
209
            levelInt = 13;
-
 
210
            break;
-
 
211
          case 5:
-
 
212
            levelInt = 5;
-
 
213
            break;
-
 
214
          case 6:
-
 
215
            levelInt = 9;
-
 
216
            break;
-
 
217
          case 7:
-
 
218
            levelInt = 1;
-
 
219
            break;
-
 
220
          case 8:
-
 
221
            levelInt = 14;
-
 
222
            break;
-
 
223
          case 9:
-
 
224
            levelInt = 6;
-
 
225
            break;
-
 
226
          case 10:
-
 
227
            levelInt = 10;
-
 
228
            break;
-
 
229
          case 11:
-
 
230
            levelInt = 2;
-
 
231
            break;
-
 
232
          case 12:
-
 
233
            levelInt = 12;
-
 
234
            break;
-
 
235
          case 13:
-
 
236
            levelInt = 4;
-
 
237
            break;
-
 
238
          case 14:
-
 
239
            levelInt = 8;
-
 
240
            break;
-
 
241
          case 15:
-
 
242
            levelInt = 0;
-
 
243
            break;
-
 
244
        }
-
 
245
        dataInt += 549755813888; //Set MSB
-
 
246
        dataInt += levelInt*4294967296//Add dimmer level
-
 
247
        return IROut_Send_Raw(alias_name, button_data["protocol"], dataInt.toString(), "Burst");   
-
 
248
    } else {
-
 
249
        Log("\033[31mDimmer level out of range [0 -> 16].\033[0m\n");
-
 
250
        return false;
-
 
251
    }
-
 
252
}
-
 
253
Console_RegisterCommand(IROut_SendDimmer, IROut_StartSendAutoComplete);
-
 
254
 
-
 
255
 
160
 
256
 
161
function IROut_SendDuration(alias_name, remote_name, button_name, duration_ms)
257
function IROut_SendDuration(alias_name, remote_name, button_name, duration_ms)
162
{
258
{
163
    IROut_Send(alias_name, remote_name, button_name, "Pressed");
259
    IROut_Send(alias_name, remote_name, button_name, "Pressed");
164
    Timer_SetTimer(function(timer) {IROut_StopSend(alias_name);}, duration_ms, false);
260
    Timer_SetTimer(function(timer) {IROut_StopSend(alias_name);}, duration_ms, false);