Subversion Repositories HomeAutomation

Rev

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

Rev 2218 Rev 2232
Line 1... Line 1...
1
 
1
 
2
Sensor_ModuleNames    = [ "DS18x20", "FOST02", "BusVoltage", "SimpleDTMF", "DHT11" ];
2
Sensor_ModuleNames    = [ "DS18x20", "FOST02", "BusVoltage", "SimpleDTMF", "DHT11", "VoltageCurrent", "ultrasonic" ];
3
SensorRf_ModuleNames    = [ "rfTransceive" ];
3
SensorRf_ModuleNames    = [ "rfTransceive" ];
4
Sensor_Intervals      = function() { return [ 1, 5, 10, 15, 20 ]; };
4
Sensor_Intervals      = function() { return [ 1, 5, 10, 15, 20 ]; };
5
Sensor_Aliases        = function() { return Module_GetAliasNames(Sensor_ModuleNames); };
5
Sensor_Aliases        = function() { return Module_GetAliasNames(Sensor_ModuleNames); };
6
Sensor_AvailableIds   = function() { return Module_GetAvailableIds(Sensor_ModuleNames); };
6
Sensor_AvailableIds   = function() { return Module_GetAvailableIds(Sensor_ModuleNames); };
7
 
7
 
Line 204... Line 204...
204
          Log("\033[31mDS18x20: Temperature conversion error: " + module_name + ":" + module_id + ", SensorId=" + variables["SensorId"] + "\033[0m");
204
          Log("\033[31mDS18x20: Temperature conversion error: " + module_name + ":" + module_id + ", SensorId=" + variables["SensorId"] + "\033[0m");
205
          break;
205
          break;
206
        }
206
        }
207
      }
207
      }
208
      case "Humidity_Percent":
208
      case "Humidity_Percent":
-
 
209
      case "Percent":
-
 
210
      case "Distance":
209
      {
211
      {
210
        for (var alias_name in aliases_data)
212
        for (var alias_name in aliases_data)
211
        {
213
        {
212
          if (aliases_data[alias_name]["specific"]["SensorId"] != variables["SensorId"])
214
          if (aliases_data[alias_name]["specific"]["SensorId"] != variables["SensorId"])
213
          {
215
          {
Line 560... Line 562...
560
      Storage_SetParameter("PhoneCalls", timestamp, JSON.stringify(lastValue));
562
      Storage_SetParameter("PhoneCalls", timestamp, JSON.stringify(lastValue));
561
    }
563
    }
562
  }
564
  }
563
}
565
}
564
 
566
 
-
 
567
function Sensor_SetUltrasonicMode(alias_name, BottomLimit, TopLimit, mode)
-
 
568
{
-
 
569
    if (arguments.length < 4)
-
 
570
    {
-
 
571
        Log("\033[31mNot enough parameters given.\033[0m\n");
-
 
572
        return false;
-
 
573
    }
-
 
574
 
-
 
575
    var aliases_data = Module_ResolveAlias(alias_name, Sensor_ModuleNames);
-
 
576
    var found = false;
-
 
577
 
-
 
578
    for (var name in aliases_data)
-
 
579
    {
-
 
580
        var variables = {   "0Percent"     : BottomLimit,
-
 
581
                    "100Percent"   : TopLimit,
-
 
582
                    "SensorMode"   : mode,
-
 
583
                    "SensorId"  : aliases_data[name]["specific"]["Channel"],
-
 
584
        };
-
 
585
        if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "UltrasonicConfig", variables))
-
 
586
        {
-
 
587
            Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n");
-
 
588
        }
-
 
589
        else
-
 
590
        {
-
 
591
            Log("\033[31mFailed to send command to " + name + ".\033[0m\n");
-
 
592
        }
-
 
593
 
-
 
594
        found = true;
-
 
595
    }
-
 
596
 
-
 
597
    if (!found)
-
 
598
    {
-
 
599
        Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n");
-
 
600
        return false;
-
 
601
    }
-
 
602
 
-
 
603
    return true;
-
 
604
}
-
 
605
Console_RegisterCommand(Sensor_SetUltrasonicMode, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, Sensor_Aliases()); });