本文整理汇总了PHP中IPS_VariableProfileExists函数的典型用法代码示例。如果您正苦于以下问题:PHP IPS_VariableProfileExists函数的具体用法?PHP IPS_VariableProfileExists怎么用?PHP IPS_VariableProfileExists使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IPS_VariableProfileExists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Create
public function Create() {
parent::Create();
$this->RegisterPropertyInteger("LightId", 0);
$this->RegisterPropertyString("Type", "");
$this->RegisterPropertyInteger("LightFeatures", 0); // 0=HUE+CT, 1=HUE, 2=CT, 3=BRI
$this->RegisterPropertyString("ModelId", "");
$this->RegisterPropertyString("UniqueId", "");
if (!IPS_VariableProfileExists('ColorModeSelect.Hue')) IPS_CreateVariableProfile('ColorModeSelect.Hue', 1);
IPS_SetVariableProfileAssociation('ColorModeSelect.Hue', 0, 'Farbe', '', 0x000000);
IPS_SetVariableProfileAssociation('ColorModeSelect.Hue', 1, 'Farbtemperatur', '', 0x000000);
}
示例2: UpdateInputsProfile
protected function UpdateInputsProfile($inputs = array())
{
if (!IPS_VariableProfileExists("YAVR.Inputs{$this->InstanceID}")) {
IPS_CreateVariableProfile("YAVR.Inputs{$this->InstanceID}", 1);
}
IPS_SetVariableProfileAssociation("YAVR.Inputs{$this->InstanceID}", 0, "Auswahl", '', 0x0);
if (count($inputs) > 0) {
foreach ($inputs as $key => $name) {
IPS_SetVariableProfileAssociation("YAVR.Inputs{$this->InstanceID}", $key, $name, '', 0x0);
}
}
}
示例3: RegisterProfile
protected function RegisterProfile($Name, $VariablenTyp, $Icon, $Prefix, $Suffix, $MinValue, $MaxValue, $StepSize)
{
if (!IPS_VariableProfileExists($Name)) {
IPS_CreateVariableProfile($Name, $VariablenTyp);
} else {
$profile = IPS_GetVariableProfile($Name);
if ($profile['ProfileType'] != $VariablenTyp) {
throw new Exception("Variable profile type does not match for profile " . $Name);
}
}
IPS_SetVariableProfileIcon($Name, $Icon);
IPS_SetVariableProfileText($Name, $Prefix, $Suffix);
IPS_SetVariableProfileValues($Name, $MinValue, $MaxValue, $StepSize);
}
示例4: ApplyChanges
public function ApplyChanges()
{
// Diese Zeile nicht löschen
parent::ApplyChanges();
//Variablenprofil anlegen
if (!IPS_VariableProfileExists("Megabyte")) {
IPS_CreateVariableProfile("Megabyte", 2);
IPS_SetVariableProfileValues("Megabyte", 0, 0, 2);
IPS_SetVariableProfileText("Megabyte", "", " MB");
}
if ($this->ReadPropertyString("IPS_Pfad") != "" and $this->ReadPropertyString("Netzwerkkarte") != "") {
//Variablen erstellen
$this->RegisterVariableFloat("CPU_idle", "CPU-Auslastung", "Humidity.F", 1);
$this->RegisterVariableFloat("CPU_volts", "CPU-Spannung", "Volt", 2);
$this->RegisterVariableFloat("CPU_temp", "CPU-Temperatur", "Temperature", 3);
$this->RegisterVariableFloat("HDD_total", "Gesamt Speicherplatz", "Megabyte", 4);
$this->RegisterVariableFloat("HDD_used", "Belegter Speicherplatz", "Megabyte", 5);
$this->RegisterVariableFloat("HDD_percent", "HDD-Belegung", "Humidity.F", 6);
$this->RegisterVariableFloat("HDD_symcon", "IPS-Speicherbelegung", "Megabyte", 7);
$this->RegisterVariableFloat("RAM_total", "Gesamt RAM", "Megabyte", 8);
$this->RegisterVariableFloat("RAM_used", "Benutzer RAM", "Megabyte", 9);
$this->RegisterVariableFloat("RAM_percent", "RAM-Auslastung", "Humidity.F", 10);
$this->RegisterVariableString("System_Info", "System Informationen", "HTMLBox", 11);
//Timer zeit setzen
$this->SetTimerInterval("Update", $this->ReadPropertyInteger("UpdateInterval") * 1000);
} else {
//Instanz ist inaktiv
$this->SetStatus(104);
}
//Variablen Logging Aktivieren / Deaktivieren
$archiveHandlerID = IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}')[0];
AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_idle"), $this->ReadPropertyBoolean("logCPU_idle"));
AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_volts"), $this->ReadPropertyBoolean("logCPU_volts"));
AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_temp"), $this->ReadPropertyBoolean("logCPU_temp"));
AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_total"), $this->ReadPropertyBoolean("logHDD_total"));
AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_used"), $this->ReadPropertyBoolean("logHDD_used"));
AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_percent"), $this->ReadPropertyBoolean("logHDD_percent"));
AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_symcon"), $this->ReadPropertyBoolean("logHDD_symcon"));
AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_total"), $this->ReadPropertyBoolean("logRAM_total"));
AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_used"), $this->ReadPropertyBoolean("logRAM_used"));
AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_percent"), $this->ReadPropertyBoolean("logRAM_percent"));
IPS_ApplyChanges($archiveHandlerID);
copy(IPS_GetKernelDir() . "modules/IPS_PI_Monitor/PI_Monitor/Raspi-PGB001.png", IPS_GetKernelDir() . "webfront/user/Raspi-PGB001.png");
}
示例5: Create
public function Create()
{
// Diese Zeile nicht löschen.
parent::Create();
//Config Form
$this->RegisterPropertyInteger("TimerEventObject");
$this->RegisterPropertyInteger("TimerEventObjectOff");
$this->RegisterPropertyInteger("DiffTimeOff", 30);
//Variablenprofil anlegen
if (!IPS_VariableProfileExists("Timer.Time")) {
IPS_CreateVariableProfile("Timer.Time", 1);
IPS_SetVariableProfileIcon("Timer.Time", "Clock");
IPS_SetVariableProfileAssociation("Timer.Time", 0, "00:00");
IPS_SetVariableProfileAssociation("Timer.Time", 1, "00:15");
IPS_SetVariableProfileAssociation("Timer.Time", 2, "00:30");
IPS_SetVariableProfileAssociation("Timer.Time", 3, "00:45");
IPS_SetVariableProfileAssociation("Timer.Time", 4, "01:00");
}
//Variablen anlegen
$this->RegisterVariableInteger("CreateEventTime", "Zeitpunkt", "Clock");
}
示例6: Create
public function Create()
{
// Diese Zeile nicht löschen.
parent::Create();
$this->RegisterPropertyString("API", "");
$this->RegisterPropertyString("Location", "Menden");
$this->RegisterPropertyInteger("UpdateInterval", 300);
//Variablenprofil anlegen
//$this->RegisterProfileFloat("WindSpeed.Kph", "WindSpeed", "", " kn", 0, 100, 1);
//$this->RegisterProfileInteger("Distance.km", "Distance", "", " km", 0, 150, 1);
if (!IPS_VariableProfileExists("WindSpeed.kt")) {
IPS_CreateVariableProfile("WindSpeed.kt", 2);
// 2 = Float
IPS_SetVariableProfileIcon("WindSpeed.kt", "WindSpeed");
IPS_SetVariableProfileValues("WindSpeed.kt", 0, 100, 1);
IPS_SetVariableProfileText("WindSpeed.kt", "", " kn");
}
if (!IPS_VariableProfileExists("Distance.km")) {
IPS_CreateVariableProfile("Distance.km", 1);
// 1 = Integer
IPS_SetVariableProfileIcon("Distance.km", "Distance");
IPS_SetVariableProfileValues("Distance.km", 0, 999, 1);
IPS_SetVariableProfileText("Distance.km", "", " km");
}
//Eigenschaften festlegen
$this->RegisterVariableString("Condition", "Wetterbedingung");
$this->RegisterVariableString("WindDirectionString", "Windrichtung");
$this->RegisterVariableInteger("AirPressure", "Luftdruck", "AirPressure");
$this->RegisterVariableInteger("Visibility", "Sichtweite", "Distance.km");
$this->RegisterVariableInteger("Humidity", "Luftfeuchtigkeit", "Humidity");
$this->RegisterVariableInteger("WindDirection", "Windrichtung", "WindDirection");
$this->RegisterVariableFloat("Temperature", "Temperatur", "Temperature");
$this->RegisterVariableFloat("Windchill", "Windchill", "Temperature");
$this->RegisterVariableFloat("Dewpoint", "Taupunkt", "Temperature");
$this->RegisterVariableFloat("WindSpeed", "Wind", "WindSpeed.kt");
$this->RegisterVariableFloat("WindSpeedGust", "Wind in Böen", "WindSpeed.kt");
$this->RegisterVariableFloat("UV", "UV Index");
}
示例7: RegisterProfileIntegerEx
protected function RegisterProfileIntegerEx($Name, $Icon, $Prefix, $Suffix, $Associations)
{
if (sizeof($Associations) === 0) {
$MinValue = 0;
$MaxValue = 0;
} else {
$MinValue = $Associations[0][0];
$MaxValue = $Associations[sizeof($Associations) - 1][0];
}
if (!IPS_VariableProfileExists($Name)) {
IPS_CreateVariableProfile($Name, 1);
} else {
$profile = IPS_GetVariableProfile($Name);
if ($profile['ProfileType'] != 1)
throw new Exception("Variable profile type does not match for profile " . $Name);
}
IPS_SetVariableProfileIcon($Name, $Icon);
IPS_SetVariableProfileText($Name, $Prefix, $Suffix);
IPS_SetVariableProfileValues($Name, $MinValue, $MaxValue, 0);
foreach ($Associations as $Association) {
IPS_SetVariableProfileAssociation($Name, $Association[0], $Association[1], $Association[2], $Association[3]);
}
}
示例8: create
/**
* create the variable profile in symcon if it does not exist
*
* @param string $name name of the variable profile
* @param int $type IPS datatype
* @param string $prefix name prefix
* @param string $suffix variable suffix (usually the value unit)
* @param array $assoc value to format associations
* @access private
*/
private function create($name, $type, $prefix = "", $suffix = "", $assoc = NULL)
{
if (!IPS_VariableProfileExists($name)) {
if ($this->debug) {
echo "INFO - variable profile {$name} does not exist. It will be created.\n";
}
IPS_CreateVariableProfile($name, $type);
IPS_SetVariableProfileText($name, $prefix, $suffix);
if (isset($assoc)) {
foreach ($assoc as $a) {
if ($this->debug) {
echo "INFO - variable profile association for variable {$name} and value " . $a["name"] . " does not exist and will be created\n";
}
IPS_SetVariableProfileAssociation($name, $a["val"], $a["name"], $a["icon"], $a["color"]);
}
}
}
}
示例9: RegisterProfileLEDGateway
protected function RegisterProfileLEDGateway($Name, $Icon, $Prefix, $Suffix)
{
if (!IPS_VariableProfileExists($Name)) {
IPS_CreateVariableProfile($Name, 1);
} else {
$profile = IPS_GetVariableProfile($Name);
if ($profile['ProfileType'] != 1) {
throw new Exception("Variable profile type does not match for profile " . $Name);
}
}
$MinValue = 0;
$MaxValue = 4;
$StepSize = 1;
IPS_SetVariableProfileIcon($Name, $Icon);
IPS_SetVariableProfileText($Name, $Prefix, $Suffix);
IPS_SetVariableProfileValues($Name, $MinValue, $MaxValue, $StepSize);
// boolean IPS_SetVariableProfileAssociation ( string $ProfilName, float $Wert, string $Name, string $Icon, integer $Farbe ) Farbwert im HTML Farbcode (z.b. 0x0000FF für Blau). Sonderfall: -1 für transparent
IPS_SetVariableProfileAssociation($Name, 0, "Weiß", "", 0xfffffff);
IPS_SetVariableProfileAssociation($Name, 1, "Blau", "", 0x13adf);
IPS_SetVariableProfileAssociation($Name, 2, "Grün", "", 0x88a08);
IPS_SetVariableProfileAssociation($Name, 3, "Rot", "", 0xfe2e2e);
IPS_SetVariableProfileAssociation($Name, 4, "Aus", "", 0x585858);
}
示例10: RegisterProfileColor
protected function RegisterProfileColor($Name, $Icon, $Prefix, $Suffix)
{
if (!IPS_VariableProfileExists($Name)) {
IPS_CreateVariableProfile($Name, 1);
} else {
$profile = IPS_GetVariableProfile($Name);
if ($profile['ProfileType'] != 1) {
throw new Exception("Variable profile type does not match for profile " . $Name);
}
}
$MinValue = 0;
$MaxValue = 7;
$StepSize = 1;
IPS_SetVariableProfileIcon($Name, $Icon);
IPS_SetVariableProfileText($Name, $Prefix, $Suffix);
IPS_SetVariableProfileValues($Name, $MinValue, $MaxValue, $StepSize);
// boolean IPS_SetVariableProfileAssociation ( string $ProfilName, float $Wert, string $Name, string $Icon, integer $Farbe ) Farbwert im HTML Farbcode (z.b. 0x0000FF für Blau). Sonderfall: -1 für transparent
IPS_SetVariableProfileAssociation($Name, 0, "Rot", "", 0xfe2e2e);
IPS_SetVariableProfileAssociation($Name, 1, "Orange", "", 0xffbf00);
IPS_SetVariableProfileAssociation($Name, 2, "Gelb", "", 0xf7fe2e);
IPS_SetVariableProfileAssociation($Name, 3, "Grün", "", 0x64fe2e);
IPS_SetVariableProfileAssociation($Name, 4, "Cyan", "", 0x81f7f3);
IPS_SetVariableProfileAssociation($Name, 5, "Blau", "", 0xff);
IPS_SetVariableProfileAssociation($Name, 6, "Lila", "", 0xda81f5);
IPS_SetVariableProfileAssociation($Name, 7, "Weiß", "", 0xffffff);
}
示例11: RegisterProfileBoolean
protected function RegisterProfileBoolean($Name, $Icon)
{
if (!IPS_VariableProfileExists($Name)) {
IPS_CreateVariableProfile($Name, 0);
} else {
$profile = IPS_GetVariableProfile($Name);
if ($profile['ProfileType'] != 0) {
throw new Exception("Variable profile type does not match for profile " . $Name);
}
}
IPS_SetVariableProfileIcon($Name, $Icon);
IPS_SetVariableProfileAssociation("{$Name}", 1, "Lueften erlaubt", "", 0xff00);
IPS_SetVariableProfileAssociation("{$Name}", 0, "Lueften verboten", "", 0xff0000);
}
示例12: Variable_GetOrSet
function Variable_GetOrSet($name, $parent, $value)
{
global $Logging;
$VarID = @IPS_GetVariableIDByName($name, $parent);
if (!$VarID) {
if ($name == "Name" or $name == "Marke" or $name == "ID" or $name == "Anschrift") {
$VarID = IPS_CreateVariable(3);
} elseif ($name == "Geöffnet_von" or $name == "Geöffnet_bis") {
$VarID = IPS_CreateVariable(3);
$ProfilName = "GeoffnetVonBis_Tankstelle_TK";
if (!IPS_VariableProfileExists($ProfilName)) {
IPS_CreateVariableProfile($ProfilName, 3);
IPS_SetVariableProfileText($ProfilName, "", " Uhr");
IPS_SetVariableProfileIcon($ProfilName, "Clock");
}
IPS_SetVariableCustomProfile($VarID, $ProfilName);
} elseif ($name == "Geöffnet") {
$VarID = IPS_CreateVariable(0);
$ProfilName = "Geoeffnet_Tankstelle_TK";
if (!IPS_VariableProfileExists($ProfilName)) {
IPS_CreateVariableProfile($ProfilName, 0);
IPS_SetVariableProfileAssociation($ProfilName, 0, "Geschlossen", "", -1);
IPS_SetVariableProfileAssociation($ProfilName, 1, "Geöffnet", "", -1);
IPS_SetVariableProfileIcon($ProfilName, "Information");
}
IPS_SetVariableCustomProfile($VarID, $ProfilName);
} elseif ($name == "Distanz") {
$VarID = IPS_CreateVariable(2);
$ProfilName = "Distanz_Tankstelle_TK";
if (!IPS_VariableProfileExists($ProfilName)) {
IPS_CreateVariableProfile($ProfilName, 2);
IPS_SetVariableProfileText($ProfilName, "", "km");
IPS_SetVariableProfileDigits($ProfilName, 1);
IPS_SetVariableProfileIcon($ProfilName, "Distance");
}
IPS_SetVariableCustomProfile($VarID, $ProfilName);
} elseif ($name == "Preis" or $name == "Preis_E5" or $name == "Preis_E10" or $name == "Preis_Diesel") {
if ($value === NULL) {
return;
}
$VarID = IPS_CreateVariable(2);
$ProfilName = "Euro_Tankstelle_TK";
if (!IPS_VariableProfileExists($ProfilName)) {
IPS_CreateVariableProfile($ProfilName, 2);
IPS_SetVariableProfileText($ProfilName, "", "€");
IPS_SetVariableProfileDigits($ProfilName, 3);
IPS_SetVariableProfileIcon($ProfilName, "Euro");
}
IPS_SetVariableCustomProfile($VarID, $ProfilName);
if ($Logging) {
$ArchiveHandlerID = IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}')[0];
AC_SetLoggingStatus($ArchiveHandlerID, $VarID, true);
IPS_ApplyChanges($ArchiveHandlerID);
}
}
IPS_SetName($VarID, $name);
IPS_SetParent($VarID, $parent);
}
SetValue($VarID, $value);
}
示例13: ApplyChanges
public function ApplyChanges()
{
// get instance id
$instanceid = IPS_GetInstance($this->InstanceID)['InstanceID'];
// rename instance
$room = $this->ReadPropertyString("Room");
if ($room != "") {
IPS_SetName($instanceid, $room);
}
// check device
$deviceip = $this->ReadPropertyString("DeviceIP");
$timeout = $this->ReadPropertyString("Timeout");
if ($deviceip != "") {
// check device availability
if ($timeout && Sys_Ping($deviceip, $timeout) != true) {
// throw new Exception("Device ".$deviceip." is not available");
die("Unable to connect to device {$deviceip}");
}
include_once __DIR__ . "/bose_soundtouch_api.php";
$bosedevice = new BoseSoundTouchAPI($deviceip);
$result = $bosedevice->getDeviceNowPlayingAPI();
// get device id for multiroom
$deviceid = $this->ReadPropertyString("DeviceID");
if ($deviceid == "" and $deviceip != "") {
$deviceid = $result['deviceid'];
IPS_SetProperty($instanceid, "DeviceID", "" . $deviceid . "");
if (IPS_HasChanges($instanceid)) {
IPS_ApplyChanges($instanceid);
}
}
}
// never delete this line!
parent::ApplyChanges();
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// create profiles
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//create zone profiles for multiroom
$allboseinstances = IPS_GetInstanceListByModuleID("{4836EF46-FF79-4D6A-91C9-FE54F1BDF2DB}");
// create profile for each instance / device
foreach ($allboseinstances as $key => $instanceid) {
$multiroomprofilename = "bose.Device" . $instanceid . "MasterZones";
// delete zone profiles
if (IPS_VariableProfileExists($multiroomprofilename)) {
IPS_DeleteVariableProfile($multiroomprofilename);
}
IPS_CreateVariableProfile($multiroomprofilename, 1);
// set values for profile
foreach ($allboseinstances as $key => $value) {
if ($instanceid == $value) {
IPS_SetVariableProfileAssociation($multiroomprofilename, "0", "Off", "", 0xff);
} else {
$instancename = IPS_GetName($value);
if ($instancename != "") {
IPS_SetVariableProfileAssociation($multiroomprofilename, "" . ($key + 1) . "", "" . $instancename . "", "", 0xff);
}
}
}
}
// create volume slider profile
$volumesliderprofilename = "bose.VolumeSlider";
if (!IPS_VariableProfileExists($volumesliderprofilename)) {
IPS_CreateVariableProfile($volumesliderprofilename, 1);
}
IPS_SetVariableProfileValues($volumesliderprofilename, 0, 100, 1);
IPS_SetVariableProfileText($volumesliderprofilename, "", "%");
IPS_SetVariableProfileIcon($volumesliderprofilename, "Speaker");
// play pause preset
$playpauseprofilename = "bose.PlayPause";
if (!IPS_VariableProfileExists($playpauseprofilename)) {
IPS_CreateVariableProfile($playpauseprofilename, 1);
}
IPS_SetVariableProfileAssociation($playpauseprofilename, "0", "Pause", "", 0xff);
IPS_SetVariableProfileAssociation($playpauseprofilename, "1", "Play", "", 0xff);
IPS_SetVariableProfileIcon($playpauseprofilename, "HollowArrowRight");
// create presets and radiolocations profiles
$instanceid = IPS_GetInstance($this->InstanceID)['InstanceID'];
$radiostationsprofilename = "bose.Device" . $instanceid . "RadioStations";
if (!IPS_VariableProfileExists($radiostationsprofilename)) {
IPS_CreateVariableProfile($radiostationsprofilename, 1);
}
$radiolocationsprofilename = "bose.Device" . $instanceid . "RadioLocations";
if (!IPS_VariableProfileExists($radiolocationsprofilename)) {
IPS_CreateVariableProfile($radiolocationsprofilename, 1);
}
// get device presets
if ($deviceip != "") {
include_once __DIR__ . "/bose_soundtouch_api.php";
$bosedevice = new BoseSoundTouchAPI($deviceip);
$result = $bosedevice->getDevicePresetsAPI();
for ($i = 0; $i < 6; $i++) {
$value = $i + 1;
$radiostationname = $result->preset[$i]->ContentItem->itemName;
$radiostationlocation = $result->preset[$i]->ContentItem["location"];
IPS_SetVariableProfileAssociation($radiostationsprofilename, "" . $value . "", "" . $radiostationname . "", "", 0xff);
IPS_SetVariableProfileAssociation($radiolocationsprofilename, "" . $value . "", "" . $radiostationlocation . "", "", 0xff);
}
IPS_SetVariableProfileIcon($radiostationsprofilename, "Cloud");
}
// create timer hour profile
$timerhourprofilename = "bose.TimerHour";
//.........这里部分代码省略.........
示例14: CreateFloatProfile
/**
* CreateFloatProfile
* @param string $ProfileName
* @param string $Icon
* @param string $Präfix
* @param string $Suffix
* @param float $MinValue
* @param float $MaxValue
* @param integer $StepSize
* @param integer $Digits
*/
private function CreateFloatProfile($ProfileName, $Icon, $Präfix, $Suffix, $MinValue, $MaxValue, $StepSize, $Digits)
{
$Profile = IPS_VariableProfileExists($ProfileName);
if ($Profile === FALSE) {
IPS_CreateVariableProfile($ProfileName, 2);
IPS_SetVariableProfileIcon($ProfileName, $Icon);
IPS_SetVariableProfileText($ProfileName, $Präfix, $Suffix);
IPS_SetVariableProfileValues($ProfileName, $MinValue, $MaxValue, $StepSize);
IPS_SetVariableProfileDigits($ProfileName, $Digits);
}
}
示例15: Create
/**
* overload internal IPS_Create($id) function
*/
public function Create()
{
// Diese Zeile nicht löschen.
parent::Create();
//Hint: $this->debug will not work in this stage! must use IPS_LogMessage
//props
$this->RegisterPropertyString('Category', 'WS300PC Devices');
$this->RegisterPropertyInteger('ParentCategory', 0);
//parent cat is root
$this->RegisterPropertyInteger('RecordInterval', 5);
$this->RegisterPropertyInteger('WS300PCInterval', 300);
$this->RegisterPropertyString('LogFile', '');
//$this->RegisterPropertyString('WSWinFile', '');
$this->RegisterPropertyInteger('Altitude', 0);
$this->RegisterPropertyInteger('RainPerCount', 295);
$this->RegisterPropertyBoolean('AutoCreate', true);
$this->RegisterPropertyBoolean('Debug', false);
$this->RegisterPropertyBoolean('Active', false);
//willi profile
if (!IPS_VariableProfileExists('WS300_Willi')) {
IPS_CreateVariableProfile('WS300_Willi', 1);
//integer
IPS_SetVariableProfileAssociation('WS300_Willi', 0, 'Sunny', 'Sun', -1);
IPS_SetVariableProfileAssociation('WS300_Willi', 1, 'some Clouds', 'Cloud', -1);
IPS_SetVariableProfileAssociation('WS300_Willi', 2, 'Cloudy', 'Cloud', -1);
IPS_SetVariableProfileAssociation('WS300_Willi', 3, 'Rainy', 'Drops', -1);
}
//Vars
$this->RegisterVariableInteger('RecCount', 'History Record Count');
$this->RegisterVariableString('Last', 'Last History Record');
$this->RegisterVariableString('Buffer', 'Buffer', "", -1);
IPS_SetHidden($this->GetIDForIdent('Buffer'), true);
$this->RegisterVariableBoolean('isPolling', 'isPolling', "", -2);
IPS_SetHidden($this->GetIDForIdent('isPolling'), true);
$this->RegisterVariableString('Config', 'Config Record', "", -3);
IPS_SetHidden($this->GetIDForIdent('Config'), true);
$this->RegisterVariableString('LastUpdate', 'Last Update', "", -4);
IPS_SetHidden($this->GetIDForIdent('LastUpdate'), true);
//Timers
$this->RegisterTimer('ReInit', 60000, $this->module_data["prefix"] . '_ReInitEvent($_IPS[\'TARGET\']);');
$this->RegisterTimer('Update', 0, $this->module_data["prefix"] . '_UpdateEvent($_IPS[\'TARGET\']);');
//Connect Parent
$this->RequireParent($this->module_interfaces['SerialPort']);
$pid = $this->GetParent();
if ($pid) {
$name = IPS_GetName($pid);
if ($name == "Serial Port") {
IPS_SetName($pid, __CLASS__ . " Port");
}
}
//call init if ready and activated
if (IPS_GetKernelRunlevel() == self::KR_READY) {
if ($this->isActive() && $this->HasActiveParent()) {
$this->SetStatus(self::ST_AKTIV);
$i = $this->GetWS300pcInterval();
$this->SetTimerInterval('Update', $i * 1000);
//ms
$this->SetTimerInterval('ReInit', 60000);
$this->init();
SetValueInteger($this->GetIDForIdent('RecCount'), 0);
$this->GetWS300pcInterval();
} else {
$this->SetStatus(self::ST_INACTIV);
$this->SetTimerInterval('ReInit', 0);
$this->SetTimerInterval('Update', 0);
}
}
}