Subversion Repositories HomeAutomation

Rev

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

Rev 2232 Rev 2237
Line 245... Line 245...
245
        "module_id"   : module_id,
245
        "module_id"   : module_id,
246
        "group"       : false   });
246
        "group"       : false   });
247
 
247
       
248
        /* Must check sensor here in case no alias is stored the adress needs to be printed */
248
        /* Must check sensor here in case no alias is stored the adress needs to be printed */
249
        var VikingSuccess = "NoVikingSensor";
249
        var VikingSuccess = "NoVikingSensor";
-
 
250
        var VikingSteakSuccess = "NoVikingSteakSensor";
250
        if (variables["Protocol"] == "Viking")
251
        if (variables["Protocol"] == "Viking")
251
        {
252
        {
252
            /*
253
            /*
253
                              ??? aaaaaaaa sttttttttttt hhhhhhhh cccccccc
254
                              ??? aaaaaaaa sttttttttttt hhhhhhhh cccccccc
254
            341731651126    0b100 11111001 000011001011 00101110 00110110   20.3 46%
255
            341731651126    0b100 11111001 000011001011 00101110 00110110   20.3 46%
Line 274... Line 275...
274
           
275
           
275
            if (unknown != 4)
276
            if (unknown != 4)
276
            {
277
            {
277
                Log("\033[33mWarning: VikingSensor, unknown part="+unknown+", data="+data+"\033[0m");
278
                Log("\033[33mWarning: VikingSensor, unknown part="+unknown+", data="+data+"\033[0m");
278
            }
279
            }
-
 
280
        } else if (variables["Protocol"] == "VikingSteak")
-
 
281
        {
-
 
282
            var data = variables["IRdata"];
-
 
283
            var addr = (data>>>4)&0xFF;
-
 
284
            var byte0 = rshift(data,32)&0xF;
-
 
285
            var byte1 = rshift(data,28)&0xF;
-
 
286
            var byte2 = rshift(data,24)&0xF;
-
 
287
            var temp = Math.round((((((byte1^byte2)<<8)+((byte0^byte1)<<4)+byte0^10)-122)*5)/9);
-
 
288
            VikingSteakSuccess = "VikingNotFound";
279
        }
289
        }
280
               
290
               
281
        loopAliases:    /* Label to break nested */
291
        loopAliases:    /* Label to break nested */
282
        for (var alias_name in aliases_data)
292
        for (var alias_name in aliases_data)
283
        {
293
        {
Line 295... Line 305...
295
                        }
305
                        }
296
                        if (addr == aliases_data[alias_name]["specific"]["Address"])
306
                        if (addr == aliases_data[alias_name]["specific"]["Address"])
297
                        {
307
                        {
298
                            VikingSuccess = "VikingFound";
308
                            VikingSuccess = "VikingFound";
299
 
309
 
300
                            var last_value = {};
310
                            var last_value = {};
301
                            var last_value_string = Storage_GetParameter("LastValues", alias_name);
311
                            var last_value_string = Storage_GetParameter("LastValues", alias_name);
302
 
312
 
303
                            if (last_value_string)
313
                            if (last_value_string)
304
                            {
314
                            {
305
                                last_value = eval("(" + last_value_string + ")");
315
                                last_value = eval("(" + last_value_string + ")");
306
                            }
316
                            }
307
 
317
 
308
                            var timestamp = get_time();
318
                            var timestamp = get_time();
309
                            last_value["Temperature_Celsius"] = { "value" : temp.toString(), "timestamp" : timestamp };
319
                            last_value["Temperature_Celsius"] = { "value" : temp.toString(), "timestamp" : timestamp };
310
                            if (humidity<101)
320
                            if (humidity<101)
311
                            {
321
                            {
312
                                last_value["Humidity_Percent"] = { "value" : humidity.toString(), "timestamp" : timestamp };
322
                                last_value["Humidity_Percent"] = { "value" : humidity.toString(), "timestamp" : timestamp };
-
 
323
                            }
-
 
324
 
-
 
325
                            Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value));
-
 
326
                           
-
 
327
                            break loopAliases;
-
 
328
                        }
-
 
329
                        break;
-
 
330
                    }
-
 
331
                    case "VikingSteak":
-
 
332
                    {   /* Add alias with these specifics: Channel=0,Proto=VikingSteak,Address=<address of sensor> */
-
 
333
                        /* if no Address is added to the alias, all vikingSteaksensors will match*/
-
 
334
                        if (aliases_data[alias_name]["specific"]["Address"] == undefined)
-
 
335
                        {
-
 
336
                            VikingSteakSuccess = "VikingFound";
-
 
337
                            var last_value = {};
-
 
338
                            var last_value_string = Storage_GetParameter("LastValues", alias_name);
-
 
339
 
-
 
340
                            if (last_value_string)
-
 
341
                            {
-
 
342
                                last_value = eval("(" + last_value_string + ")");
-
 
343
                            }
-
 
344
 
-
 
345
                            var timestamp = get_time();
-
 
346
                            last_value["Temperature_Celsius"] = { "value" : temp.toString(), "timestamp" : timestamp };
-
 
347
                            last_value["Address"] = { "value" : addr, "timestamp" : timestamp };
-
 
348
                            Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value));
-
 
349
                            break loopAliases;
-
 
350
                        }
-
 
351
                        else if (addr == aliases_data[alias_name]["specific"]["Address"])
-
 
352
                        {
-
 
353
                            VikingSteakSuccess = "VikingFound";
-
 
354
                            var last_value = {};
-
 
355
                            var last_value_string = Storage_GetParameter("LastValues", alias_name);
-
 
356
 
-
 
357
                            if (last_value_string)
-
 
358
                            {
-
 
359
                                last_value = eval("(" + last_value_string + ")");
313
                            }
360
                            }
314
 
361
 
-
 
362
                            var timestamp = get_time();
-
 
363
                            last_value["Temperature_Celsius"] = { "value" : temp.toString(), "timestamp" : timestamp };
-
 
364
                            last_value["Address"] = { "value" : addr, "timestamp" : timestamp };
315
                            Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value));
365
                            Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value));
316
                           
366
                           
317
                            break loopAliases;
367
                            break loopAliases;
318
                        }
368
                        }
319
                        break;
369
                        break;
Line 328... Line 378...
328
                        else if (variables["IRdata"] == aliases_data[alias_name]["specific"]["OffData"] && variables["Status"] == "Pressed")
378
                        else if (variables["IRdata"] == aliases_data[alias_name]["specific"]["OffData"] && variables["Status"] == "Pressed")
329
                        {
379
                        {
330
                            deviceStateCommand = "Off";
380
                            deviceStateCommand = "Off";
331
                        }
381
                        }
332
                        else
382
                        else
333
                        {
383
                        {
334
                            break;
384
                            break;
335
                        }
385
                        }
336
                       
386
                       
337
                        var last_value = {};
387
                        var last_value = {};
338
                        var last_value_string = Storage_GetParameter("LastValues", alias_name);
388
                        var last_value_string = Storage_GetParameter("LastValues", alias_name);
339
 
389
 
340
                        if (last_value_string)
390
                        if (last_value_string)
341
                        {
391
                        {
Line 366... Line 416...
366
            }
416
            }
367
        }
417
        }
368
        if (VikingSuccess == "VikingNotFound")
418
        if (VikingSuccess == "VikingNotFound")
369
        {
419
        {
370
            Log("Found unknown vikingsensor address="+addr+" temperature="+temp+" humidity="+humidity+" unknown="+unknown);
420
            Log("Found unknown vikingsensor address="+addr+" temperature="+temp+" humidity="+humidity+" unknown="+unknown);
-
 
421
        }
-
 
422
        if (VikingSteakSuccess == "VikingNotFound")
-
 
423
        {
-
 
424
            Log("Found unknown vikingSteaksensor address="+addr+" temperature="+temp);
371
        }
425
        }
372
    }
426
    }
373
}
427
}
374
Module_RegisterToOnMessage("all", SensorRf_OnMessage);
428
Module_RegisterToOnMessage("all", SensorRf_OnMessage);
375
 
429