Пример #1
0
 private function SetValueInteger($Ident, $value)
 {
     $id = $this->GetIDForIdent($Ident);
     if (GetValueInteger($id) != $value) {
         SetValueInteger($id, $value);
         return true;
     }
     return false;
 }
Пример #2
0
 protected function SetValueInteger($Ident, $Value)
 {
     $ID = $this->GetIDForIdent($Ident);
     if (GetValueInteger($ID) != $Value) {
         SetValueInteger($ID, intval($Value));
         return true;
     }
     return false;
 }
Пример #3
0
 protected function GetValueInteger($Ident)
 {
     $ID = is_numeric($Ident) ? $Ident : $this->GetIDForIdent($Ident);
     return GetValueInteger($ID);
 }
Пример #4
0
 private function getDeviceAddress($deviceName)
 {
     $ret = IPS_GetInstanceListByModuleID("{44D8BE09-743E-484F-A64D-154C4235BE94}");
     $DeviceURL = "";
     $AccessToken = "";
     $retArray = "";
     $SecChannelExp = 0;
     if ($ret == null) {
         echo "Error: ips4WinDeviceRegistration is not implemented! Please create a new instance of ips4WinDeviceRegistration!\n";
     } else {
         if (count($ret) > 1) {
             echo "Error: multiple ips4WinDeviceRegistration found, unsupported installation! Please make sure you have only one instance of ips4WinDeviceRegistration!\n";
         } else {
             $id = $ret[0];
             $objList = IPS_GetChildrenIDs($id);
             //print_r($objList);
             $i = count($objList);
             for ($j = 0; $j < $i; $j++) {
                 $vid = @IPS_GetObjectIDByName("deviceName", $objList[$j]);
                 if ($vid !== false) {
                     if ($deviceName == null) {
                         $device = GetValueString($vid);
                         $vid = @IPS_GetObjectIDByName("SecChannel", $objList[$j]);
                         if ($vid !== false) {
                             $DeviceURL = GetValueString($vid);
                         }
                         $vid = @IPS_GetObjectIDByName("AccessToken", $objList[$j]);
                         if ($vid !== false) {
                             $AccessToken = GetValueString($vid);
                         }
                         $vid = @IPS_GetObjectIDByName("SecChannelExp", $objList[$j]);
                         if ($vid !== false) {
                             $SecChannelExp = GetValueInteger($vid);
                         }
                         if ($retArray == "") {
                             $retArray[0] = explode("###", $device . "###" . $DeviceURL . "###" . $AccessToken . "###" . $SecChannelExp);
                         } else {
                             $retArray[count($retArray)] = explode("###", $device . "###" . $DeviceURL . "###" . $AccessToken . "###" . $SecChannelExp);
                         }
                         $DeviceURL = "";
                         $AccessToken = "";
                         $SecChannelExp = 0;
                     } else {
                         if (strtolower($deviceName) == strtolower(GetValueString($vid))) {
                             $vid = @IPS_GetObjectIDByName("SecChannel", $objList[$j]);
                             if ($vid !== false) {
                                 $DeviceURL = GetValueString($vid);
                             }
                             $vid = @IPS_GetObjectIDByName("AccessToken", $objList[$j]);
                             if ($vid !== false) {
                                 $AccessToken = GetValueString($vid);
                             }
                             $vid = @IPS_GetObjectIDByName("SecChannelExp", $objList[$j]);
                             if ($vid !== false) {
                                 $SecChannelExp = GetValueInteger($vid);
                             }
                             $retArray = array(explode("###", $deviceName . "###" . $DeviceURL . "###" . $AccessToken . "###" . $SecChannelExp));
                             $j = $i;
                         }
                     }
                 }
             }
         }
     }
     return $retArray;
 }
Пример #5
0
 public function SetDefaultGroupVolume()
 {
     if (!$this->ReadPropertyBoolean("GroupCoordinator")) {
         die("This function is only allowed for GroupCoordinators");
     }
     $groupMembers = GetValueString(IPS_GetObjectIDByName("GroupMembers", $this->InstanceID));
     $groupMembersArray = array();
     if ($groupMembers) {
         $groupMembersArray = array_map("intval", explode(",", $groupMembers));
     }
     $groupMembersArray[] = $this->InstanceID;
     foreach ($groupMembersArray as $key => $ID) {
         try {
             SNS_SetDefaultVolume($ID);
         } catch (Exception $e) {
         }
     }
     $GroupVolume = 0;
     foreach ($groupMembersArray as $key => $ID) {
         $GroupVolume += GetValueInteger(IPS_GetObjectIDByName("Volume", $ID));
     }
     SetValueInteger(IPS_GetObjectIDByName("GroupVolume", $this->InstanceID), intval(round($GroupVolume / sizeof($groupMembersArray))));
 }
 /**
  * Get status variable RecCount
  * Indicates history records readed up to now
  * @return Integer
  */
 public function GetHistoryCount()
 {
     $id = @$this->GetIDForIdent('RecCount');
     $val = GetValueInteger($id);
     return $val;
 }
Пример #7
0
<?php

include_once "../modules/SymconSonos/Sonos/sonosAccess.php";
// Nothing to do if Instance is Group Coordinator
if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "GroupCoordinator")) {
    return;
}
$groupForcing = IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "GroupForcing");
$rinconMapping = array();
$allSonosInstances = IPS_GetInstanceListByModuleID("{F6F3A773-F685-4FD2-805E-83FD99407EE8}");
$MemberOfGroupID = @IPS_GetObjectIDByName("MemberOfGroup", IPS_GetParent($_IPS["SELF"]));
$MemberOfGroup = 0;
if ($MemberOfGroupID) {
    $MemberOfGroup = GetValueInteger($MemberOfGroupID);
}
//ensure that all rincons are known
foreach ($allSonosInstances as $key => $SonosID) {
    $rincon = IPS_GetProperty($SonosID, "RINCON");
    if (!$rincon) {
        // Get RINCON
        // Not sure why, but when executed in ApplyChanges of module.php RINCON is not alway set
        $ipAddress = IPS_GetProperty($SonosID, "IPAddress");
        if ($ipAddress) {
            $curl = curl_init();
            curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => "http://" . $ipAddress . ":1400/xml/device_description.xml"));
            $result = curl_exec($curl);
            if (!curl_exec($curl)) {
                continue;
            }
            $xmlr = new SimpleXMLElement($result);
            $rincon = str_replace("uuid:", "", $xmlr->device->UDN);
 /**
  * Query Sensors
  * @param $branch string
  * @param $url string
  * @param $map array
  */
 private function Query($branch, $url, $map)
 {
     $last_id = @$this->GetIDForIdent('LastUpdate');
     $max = 0;
     if ($last_id) {
         $max = GetValueInteger($last_id);
     }
     $answer = chop(@file_get_contents($url));
     $response = $http_response_header[0];
     if (preg_match("/200\\s+OK\$/", $response) && strlen($answer) > 0) {
         $json = preg_replace('/list\\((\\{.*\\})\\)/s', '\\1', $answer);
         $data = json_decode($json);
         switch ($branch) {
             case 'Sensor':
                 $data = $data->{'sensor'};
                 break;
             case 'Actor':
                 $data = $data->{'actuator'};
                 break;
         }
         if (!$data) {
             IPS_LogMessage("XS1", "no sensor data returned");
             return;
         }
         $n = 0;
         foreach ($data as $dev) {
             $n++;
             //xs1 number parameter is serialno of sensor list
             $data = array();
             $caps = '';
             $type = $dev->{'type'};
             if ($type == 'disabled') {
                 continue;
             }
             if (isset($map[$type])) {
                 $mod = $map[$type]['typ'];
                 $cap = $map[$type]['cap'];
             } else {
                 IPS_LogMessage(__CLASS__, __FUNCTION__ . "::{$branch}: Unsupported type {$type}");
                 continue;
             }
             $devname = $dev->{'name'};
             $val = $dev->{'value'};
             $unit = utf8_decode($dev->{'unit'});
             $utime = $dev->{'utime'};
             //id needs protocol V15+
             $id = isset($dev->{'id'}) ? $dev->{'id'} : $n;
             //get ips varids
             $data['Branch'] = $branch;
             $data['Id'] = $n;
             $data['Name'] = utf8_encode($devname);
             $data['Typ'] = $type;
             $data['TS'] = $utime;
             $data[$cap] = $val;
             //actur functions
             if ($branch == "Actor") {
                 $fun = '';
                 $fl = array();
                 $fl[$cap] = 0;
                 if (isset($dev->{'function'})) {
                     $fun = 'Functions:';
                     foreach ($dev->{'function'} as $f) {
                         $ft = $f->{'type'};
                         switch ($ft) {
                             case 'off_wait_on':
                             case 'on_wait_off':
                                 //$fl["Timer"]=1; //timer not implemented yet
                                 break;
                             case 'on':
                             case 'off':
                                 $fl["Switch"] = 1;
                                 break;
                             case 'dimmer':
                                 //$fl["Dimmer"]=1; //dimmer not implemented yet
                                 break;
                             case 'long_on':
                             case 'long_off':
                                 //$fl["Shutter"]=1; //shutter not implemeted yet
                                 break;
                             case 'disabled':
                                 break;
                             default:
                                 $this->debug(__FUNCTION__, "Unimplemented function '{$ft}''");
                         }
                         $fun .= "{$ft},";
                     }
                     //collect caps
                     foreach ($fl as $ft => $val) {
                         $caps .= "{$ft}";
                         if ($val == 1) {
                             $caps .= ':1';
                         }
                         $caps .= ";";
                     }
                 }
                 $this->debug(__FUNCTION__, "{$branch}: {$n}({$id}) Name: {$devname}, Type: {$type}, Val: {$val}, {$fun}");
             } elseif ($branch == "Sensor") {
                 $caps = "{$cap};TS";
                 $this->debug(__FUNCTION__, "{$branch}: {$n}({$id}) Name: {$devname}, Type: {$type}, Val: {$val}, Unit: '{$unit}'");
             }
             $this->debug(__FUNCTION__, "{$branch}: {$n} Mod:{$mod}, Caps: {$caps}");
             switch ($mod) {
                 case 'WSDEV':
                     $this->SendWSData($caps, $data);
                     break;
                 case 'EnergyDev':
                     $this->SendENData($caps, $data);
                     break;
                 case 'SwitchDev':
                     $this->SendSwitchData($caps, $data);
                     break;
                 default:
                     IPS_LogMessage(__CLASS__, __FUNCTION__ . "::{$branch}: Unsupported Mod '{$mod}''");
             }
             //store max timestamp value
             if ($utime > $max) {
                 $max = $utime;
             }
         }
         //for
         //set max timestamp info
         SetValueInteger($last_id, $max);
     } else {
         IPS_LogMessage(__CLASS__, __FUNCTION__ . "::Error Answer calling {$url}");
     }
 }
Пример #9
0
  public function SetValue($key, $value) {
    $stateId = IPS_GetObjectIDByIdent('STATE', $this->InstanceID);
    $cmId = IPS_GetObjectIDByIdent('COLOR_MODE', $this->InstanceID);
    $ctId = @IPS_GetObjectIDByIdent('COLOR_TEMPERATURE', $this->InstanceID);
    $briId = IPS_GetObjectIDByIdent('BRIGHTNESS', $this->InstanceID);
    $satId = @IPS_GetObjectIDByIdent('SATURATION', $this->InstanceID);
    $hueId = @IPS_GetObjectIDByIdent('HUE', $this->InstanceID);
    $colorId = @IPS_GetObjectIDByIdent('COLOR', $this->InstanceID);

    $stateValue = GetValueBoolean($stateId);
    $cmValue = $cmId ? GetValueInteger($cmId) : 0;
    $ctValue = $ctId ? (500 - round(347 * GetValueInteger($ctId) / 100)) : 0;
    $briValue = round(GetValueInteger($briId)*2.54);
    $satValue = $satId ? round(GetValueInteger($satId)*2.54) : 0;
    $hueValue = $hueId ? GetValueInteger($hueId) : 0;
    $colorValue = $colorId ? GetValueInteger($colorId) : 0;

    switch ($key) {
      case 'STATE':
        $stateNewValue = $value;
        break;
      case 'COLOR':
        $colorNewValue = $value;
        $stateNewValue = true;
        $hex = str_pad(dechex($value), 6, 0, STR_PAD_LEFT);
        $hsv = $this->HEX2HSV($hex);
        SetValueInteger($colorId, $value);
        $hueNewValue = $hsv['h'];
        $briNewValue = $hsv['v'];
        $satNewValue = $hsv['s'];
        $cmNewValue = 0;
        break;
      case 'BRIGHTNESS':
        $briNewValue = $value;
        $stateNewValue = true;
        if (IPS_GetProperty($this->InstanceID, 'LightFeatures') != 3) {
          if ($cmValue == '0') {
            $newHex = $this->HSV2HEX($hueValue, $satValue, $briNewValue);
            SetValueInteger($colorId, hexdec($newHex));
            $hueNewValue = $hueValue;
            $satNewValue = $satValue;
          } else {
            $ctNewValue = $ctValue;
          }
        }
        break;
      case 'SATURATION':
        $cmNewValue = 0;
        $satNewValue = $value;
        $stateNewValue = true;
        $newHex = $this->HSV2HEX($hueValue, $satNewValue, $briValue);
        SetValueInteger($colorId, hexdec($newHex));
        $hueNewValue = $hueValue;
        $briNewValue = $briValue;
        break;
      case 'COLOR_TEMPERATURE':
        $cmNewValue = 1;
        $ctNewValue = $value;
        $briNewValue = $briValue;
        break;
      case 'COLOR_MODE':
        $cmNewValue = $value;
        $stateNewValue = true;
        if ($cmNewValue == 1) {
          $ctNewValue = $ctValue;
          IPS_SetHidden($colorId, true);
          IPS_SetHidden($ctId, false);
          IPS_SetHidden($satId, true);
        } else {
          $hueNewValue = $hueValue;
          $satNewValue = $satValue;
          $briNewValue = $briValue;
          $newHex = $this->HSV2HEX($hueValue, $satValue, $briValue);
          SetValueInteger($colorId, hexdec($newHex));
          IPS_SetHidden($colorId, false);
          IPS_SetHidden($ctId, true);
          IPS_SetHidden($satId, false);
        }
        break;
    }

    $changes = array();
    if (isset($stateNewValue)) {
      SetValueBoolean($stateId, $stateNewValue);
      $changes['on'] = $stateNewValue;
    }
    if (isset($hueNewValue)) {
      SetValueInteger($hueId, $hueNewValue);
      $changes['hue'] = $hueNewValue;
    }
    if (isset($satNewValue)) {
      SetValueInteger($satId, round($satNewValue * 100 / 254));
      $changes['sat'] = $satNewValue;
    }
    if (isset($briNewValue)) {
      SetValueInteger($briId, round($briNewValue * 100 / 254));
      $changes['bri'] = $briNewValue;
    }
    if (isset($ctNewValue)) {
      SetValueInteger($ctId, 100 - round(($ctNewValue - 153) * 100 / 347));
      $changes['ct'] = $ctNewValue;
    }
    if (isset($cmNewValue)) {
      SetValueInteger($cmId, $cmNewValue);
      $changes['colormode'] = $cmNewValue == 1 ? 'ct' : 'hs';
    }

    $lightId = $this->ReadPropertyInteger("LightId");
    return HUE_Request($this->GetBridge(), "/lights/$lightId/state", $changes);
  }
 /**
  * parses an record string
  * 
  * @param $data string
  * @param $status string
  * @return array
  */
 private function Parse($data, $status)
 {
     /**
      * @par Status
      * @code
      * #----Status (te923con -s -i '')
      * 0x29 :0x17 :0x14 :0x10 :0x26 :1   :1   :1   :1   :1   :1   :1   :1
      * SYSSW:BARSW:EXTSW:RCCSW:WINSW:BATR:BATU:BATW:BAT5:BAT4:BAT5:BAT2:BAT1
      * @endcode
      * - SYSSW  - software version of system controller
      * - BARSW  - software version of barometer
      * - EXTSW  - software version of UV and channel controller
      * - RCCSW  - software version of rain controller
      * - WINSW  - software version of wind controller
      * - BATR   - battery of rain sensor (1-good (not present), 0-low)
      * - BATU   - battery of UV sensor (1-good (not present), 0-low)
      * - BATW   - battery of wind sensor (1-good (not present), 0-low)
      * - BAT5   - battery of sensor 5 (1-good (not present), 0-low)
      * - BAT4   - battery of sensor 4 (1-good (not present), 0-low)
      * - BAT3   - battery of sensor 3 (1-good (not present), 0-low)
      * - BAT2   - battery of sensor 2 (1-good (not present), 0-low)
      * - BAT1   - battery of sensor 1 (1-good (not present), 0-low)
      *
      * @par Data
      * @code
      * #------Data (te923con -i 'i')
      *
      * 1356207784:22.95:41:7.70:91:8.00:83:i :i :i :i :i :i :1001.9:i :3 :0    :9 :0.1:0.0:7.2:356
      * T0   :H0:T1  :H1:T2  :H2:T3:H3:T4:H4:T5:H5:PRESS :UV:FC:STORM:WD:WS :WG :WC :RC
      * @endcode
      * -  T0    - temperature from internal sensor in °C
      * -  H0    - humidity from internal sensor in % rel
      * -  T1..5 - temperature from external sensor 1..4 in °C
      * -  H1..5 - humidity from external sensor 1...4 in % rel
      * -  PRESS - air pressure in mBar
      * -  UV    - UV index from UV sensor
      * -  FC    - station forecast, see below for more details
      * -  STORM - stormwarning; 0 - no warning, 1 - fix your dog
      * -  WD    - wind direction in n x 22.5°; 0 -> north
      * -  WS    - wind speed in m/s
      * -  WG    - wind gust speed in m/s
      * -  WC    - windchill temperature in °C
      * -  RC    - rain counter (maybe since station starts measurement) as value
      *
      *
      * weather forecast means (as precisely as possible)
      * - 0 - heavy snow
      * - 1 - little snow
      * - 2 - heavy rain
      * - 3 - little rain
      * - 4 - cloudy
      * - 5 - some clouds
      * - 6 - sunny
      */
     $te_data = array();
     $status = explode(":", $status);
     $data = explode(":", $data);
     $cdata = count($data);
     $cstatus = count($status);
     $this->debug(__FUNCTION__, "Entered: Data:{$cdata},Status: {$cstatus}");
     //if (($cdata == 22) && ($cstatus == 13)) {
     $date = $data[0];
     $tsid = @$this->GetIDForIdent('TimeStamp');
     if ($tsid > 0) {
         SetValueInteger($tsid, $date);
     }
     $te_data['date'] = $date;
     //Indoor and Sensor1-5 T/H
     for ($s = 0; $s < self::MAXSENSORS; $s++) {
         $f = $s * 2 + 1;
         if (trim($data[$f]) == 'i') {
             continue;
         }
         $te_data[$s]['Id'] = "{$s}";
         $te_data[$s]['Temp'] = (double) $data[$f];
         if ($s > 0) {
             $batf = 13 - $s;
             if (isset($status[$batf])) {
                 $stat = $status[$batf] == '0' ? 'LOW' : 'OK';
                 $te_data[$s]['Battery'] = $stat;
             }
         }
         if (trim($data[$f + 1]) != 'i') {
             $te_data[$s]['Hum'] = (int) $data[$f + 1];
         }
         //todo
         $te_data[$s]['Typ'] = 'T/F';
         if ($s == 0) {
             $te_data[$s]['Typ'] = 'Indoor';
         } else {
             if (!isset($te_data[$s]['Hum'])) {
                 $te_data[$s]['Typ'] = 'T';
             }
         }
     }
     //indoor specioa
     if (trim($data[13]) != 'i') {
         $te_data[0]['Press'] = (int) $data[13];
     }
     if (trim($data[15]) != 'i') {
         $te_data[0]['Forecast'] = (int) $data[15];
     }
     //uv
     if (trim($data[14]) != 'i') {
         $te_data['UV']['UV'] = $data[14];
         $te_data['UV']['Bat'] = $status[6];
     }
     //wind
     if (trim($data[18]) != 'i') {
         $te_data['Wind']['Wind'] = $data[18] * self::ms_to_kmh;
         $te_data['Wind']['Storm'] = $data[16] != 0 ? 'YES' : 'No';
         $te_data['Wind']['WindDir'] = $data[17] * 22.5;
         $te_data['Wind']['WindGust'] = $data[19] * self::ms_to_kmh;
         $te_data['Wind']['WindChill'] = (double) $data[20];
         $te_data['Wind']['Bat'] = $status[7];
     }
     //rain
     if (trim($data[21]) != 'i') {
         $new = (int) $data[21];
         $factor = $this->GetRainPerCount() / 1000;
         $rcid = @$this->GetIDForIdent('LastRainCounter');
         $dailyid = @$this->GetIDForIdent('NewDayRainCounter');
         $old = GetValueInteger($rcid);
         $daily = GetValueInteger($dailyid);
         $diff = $new - $old;
         $dailydiff = $new - $daily;
         $rain = $diff * $factor;
         $raindaily = $dailydiff * $factor;
         $te_data['Rain']['RainLastDay'] = '';
         $dailyvar = IPS_GetVariable($dailyid);
         $dailyupdated = $dailyvar['VariableUpdated'];
         if (is_new_day($dailyupdated)) {
             //set last day sum
             SetValueInteger($dailyid, $old);
             //calculate rain last day
             $lastday = ($old - $daily) * $factor;
             if ($lastday < 0 or $lastday > 500) {
                 $lastday = 0;
             }
             $te_data['Rain']['RainLastDay'] = $lastday;
             $this->debug(__FUNCTION__, "::NewDay, Store old Counter({$old}) and Daily({$lastday})");
         }
         if ($new > $old) {
             SetValueInteger($rcid, $new);
         }
         if ($rain < 0 or $rain > 100) {
             $rain = 0;
         }
         $te_data['Rain']['Rain'] = $rain;
         if ($raindaily < 0 or $raindaily > 500) {
             $raindaily = 0;
         }
         $te_data['Rain']['RainDaily'] = $raindaily;
         $te_data['Rain']['Bat'] = $status[5];
     }
     //fill standard fields
     foreach (array('Wind', 'Rain', 'UV', 'Indoor') as $dev) {
         if (isset($te_data[$dev])) {
             $te_data[$dev]['Typ'] = $dev . "Sensor";
             $te_data[$dev]['Id'] = $dev;
             if (isset($te_data[$dev]['Bat'])) {
                 $stat = trim($te_data[$dev]['Bat']) == '0' ? 'LOW' : 'OK';
                 $te_data[$dev]['Battery'] = $stat;
                 unset($te_data[$dev]['Bat']);
             }
         }
     }
     $this->debug(__FUNCTION__, 'OK');
     /*
     } else {
         $this->debug(__FUNCTION__, "Field Error (22 data and 14 status fields expected");
     }
     */
     $this->debug(__FUNCTION__, " Parsed Data:" . print_r($te_data, true));
     if (count($te_data) == 0) {
         IPS_LogMessage(__CLASS__, __FUNCTION__ . " Error: Parsing returned no data");
     }
     return $te_data;
 }
 /**
  * inc Error counter
  */
 private function incError()
 {
     $vid = $this->GetIDForIdent('Errors');
     if ($vid) {
         $val = GetValueInteger($vid);
         SetValueInteger($vid, $val + 1);
     }
 }
Пример #12
0
 private function WaitForResponse()
 {
     $TransmitStatusID = $this->GetIDForIdent('TransmitStatus');
     for ($i = 0; $i < 500; $i++) {
         if (GetValueInteger($TransmitStatusID) == 0xff) {
             IPS_Sleep(10);
         } else {
             if ($this->lock('TransmitStatus')) {
                 $ret = GetValueInteger($TransmitStatusID);
                 $this->unlock('TransmitStatus');
                 return $ret;
             }
             return false;
         }
     }
     return false;
 }
Пример #13
0
 protected function DoBlutdruck($ModulID, $data)
 {
     $diastolic = 0;
     $systolic = 0;
     $pulse = 0;
     $CatID = @IPS_GetCategoryIDByName("Blutdruck", $ModulID);
     if ($CatID === false) {
         return;
     }
     $time = @$data['measuregrps'][0]['date'];
     $data = @$data['measuregrps'][0]['measures'];
     if (count($data) != 3) {
         $this->Logging("Fehler bei DoBlutdruck " . count($data));
         //return;
     }
     $id = @IPS_GetVariableIDByName("DatumUhrzeit", $CatID);
     if ($id > 0) {
         $old = GetValueInteger($id);
         if ($old == $time) {
             // keine neue Daten
             return false;
         }
         SetValueInteger($id, $time);
     }
     foreach ($data as $messung) {
         $val = $messung['value'];
         if ($messung['type'] == 9) {
             $diastolic = $val;
         }
         if ($messung['type'] == 10) {
             $systolic = $val;
         }
         if ($messung['type'] == 11) {
             $pulse = $val;
         }
     }
     $id = IPS_GetVariableIDByName("Diastolic", $CatID);
     if ($id > 0) {
         SetValueInteger($id, $diastolic);
     }
     $id = IPS_GetVariableIDByName("Systolic", $CatID);
     if ($id > 0) {
         SetValueInteger($id, $systolic);
     }
     $id = IPS_GetVariableIDByName("Puls", $CatID);
     if ($id > 0) {
         SetValueInteger($id, $pulse);
     }
 }
 /**
  * handle incoming data along capabilities
  * @param array $data
  */
 private function ParseData($data)
 {
     //
     $this->debug(__FUNCTION__, 'Parse');
     $caps = $this->GetCaps();
     foreach (array_keys($caps) as $cap) {
         $ident = $caps[$cap];
         $vid = @$this->GetIDForIdent($ident);
         if ($vid == 0) {
             $this->debug(__FUNCTION__, "Cap {$cap} Ident {$ident}: Variable missed");
             continue;
         }
         if (!isset($data[$cap])) {
             continue;
         }
         $s = $data[$cap];
         $this->debug(__FUNCTION__, "Handle {$cap} ({$vid}) = {$s}");
         switch ($cap) {
             //boolean types
             case 'Alert':
                 //Status
                 $state = $s != 'YES';
                 //reversed display
                 SetValueBoolean($vid, $state);
                 break;
                 //Counter types with factor
             //Counter types with factor
             case 'Counter':
                 $iv = (int) $s;
                 switch ($this->GetType()) {
                     case 'EMWZ':
                         $last = GetValueInteger($vid);
                         $opid = $this->GetIDForIdent('OCounter');
                         if ($opid) {
                             $offset = GetValueInteger($opid);
                             if ($last > $iv) {
                                 $offset += 65535;
                                 $this->debug(__FUNCTION__, "EMWZ:Increase Offset by 65535: {$offset}");
                                 SetValueInteger($opid, $offset);
                             }
                             $iv = $iv + $offset;
                         } else {
                             $this->debug(__FUNCTION__, "EMWZ:No vid for OCounter");
                         }
                         $pvid = $this->GetIDForIdent('TPower');
                         if ($pvid) {
                             $factor = $this->GetCounterFactor();
                             if ($factor == 0) {
                                 $factor = 150;
                             }
                             $val = $iv * (1 / $factor);
                             //counter%ticks pro kw
                             SetValueFloat($pvid, $val);
                             $this->debug(__FUNCTION__, "EMWZ:TPower:({$pvid})=" . $val . "F:{$factor}(" . $this->GetCounterFactor() . ")");
                         } else {
                             $this->debug(__FUNCTION__, "EMWZ:No vid for TPower");
                         }
                         break;
                     case 'EMEM':
                         $last = GetValueInteger($vid);
                         $opid = $this->GetIDForIdent('OCounter');
                         if ($opid) {
                             $offset = GetValueInteger($opid);
                             if ($last > $iv) {
                                 $offset += 65535;
                                 $this->debug(__FUNCTION__, "EMEM:Increase Offset by 65535: {$offset}");
                                 SetValueInteger($opid, $offset);
                             }
                             $iv = $iv + $offset;
                         } else {
                             $this->debug(__FUNCTION__, "EMEM:No vid for OCounter");
                         }
                         $pvid = $this->GetIDForIdent('TPower');
                         if ($pvid) {
                             $factor = $this->GetCounterFactor();
                             if ($factor == 0) {
                                 $factor = 100;
                             }
                             $val = $iv * (1 / $factor);
                             //counter%ticks pro kw
                             SetValueFloat($pvid, $val);
                             $this->debug(__FUNCTION__, "EMEM:TPower:({$pvid})=" . $val . "F:{$factor}(" . $this->GetCounterFactor() . ")");
                         } else {
                             $this->debug(__FUNCTION__, "EMEM:No vid for TPower");
                         }
                         break;
                     case 'EMGZ':
                         $pvid = $this->GetIDForIdent('TGas');
                         if ($pvid) {
                             $factor = $this->GetCounterFactor();
                             if ($factor == 0) {
                                 $factor = 100;
                             }
                             $val = $iv * (1 / $factor);
                             //Counter%ticks pro m3
                             SetValueFloat($pvid, $val);
                             $this->debug(__FUNCTION__, "EMGZ:TGas:({$pvid})=" . $val . "F:{$factor}(" . $this->GetCounterFactor() . ")");
                         } else {
                             $this->debug(__FUNCTION__, "EMGZ:No vid for TGas");
                         }
                         break;
                 }
                 SetValueInteger($vid, $iv);
                 break;
             case 'ACounter':
                 $iv = (int) $s;
                 switch ($this->GetType()) {
                     case 'EMWZ':
                         $pvid = $this->GetIDForIdent('APower');
                         if ($pvid) {
                             $factor = $this->GetCounterFactor();
                             if ($factor == 0) {
                                 $factor = 150;
                             }
                             $val = $iv * (1 / $factor) * 1000;
                             //W statt KW
                             SetValueFloat($pvid, $val);
                             $this->debug(__FUNCTION__, "EMWZ:APower:({$pvid})=" . $val . "F:{$factor}(" . $this->GetCounterFactor() . ")");
                         } else {
                             $this->debug(__FUNCTION__, "EMWZ:No vid for APower");
                         }
                         break;
                     case 'EMEM':
                         $pvid = $this->GetIDForIdent('APower');
                         if ($pvid) {
                             $factor = $this->GetCounterFactor();
                             if ($factor == 0) {
                                 $factor = 100;
                             }
                             $val = $iv * (1 / $factor) * 1000;
                             //W statt KW
                             SetValueFloat($pvid, $val);
                             $this->debug(__FUNCTION__, "EMEM:APower:({$pvid})=" . $val . "F:{$factor}(" . $this->GetCounterFactor() . ")");
                         } else {
                             $this->debug(__FUNCTION__, "EMEM:No vid for APower");
                         }
                         break;
                     case 'EMGZ':
                         $pvid = $this->GetIDForIdent('AGas');
                         if ($pvid) {
                             $factor = $this->GetCounterFactor();
                             if ($factor == 0) {
                                 $factor = 100;
                             }
                             $val = $iv * (1 / $factor);
                             //m3
                             SetValueFloat($pvid, $val);
                             $this->debug(__FUNCTION__, "EMGZ:AGas:({$pvid})=" . $val . " F:{$factor}(" . $this->GetCounterFactor() . ")");
                         } else {
                             $this->debug(__FUNCTION__, "EMGZ:No vid for AGas");
                         }
                         break;
                 }
                 SetValueInteger($vid, $iv);
                 break;
             case 'PCounter':
                 $iv = (int) $s;
                 switch ($this->GetType()) {
                     case 'EMWZ':
                         $pvid = $this->GetIDForIdent('PPower');
                         if ($pvid) {
                             $factor = $this->GetCounterFactor();
                             if ($factor == 0) {
                                 $factor = 150;
                             }
                             $val = $iv * (1 / $factor) * 1000;
                             //W statt KW
                             SetValueFloat($pvid, $val);
                             $this->debug(__FUNCTION__, "EMWZ:PPower:({$pvid})=" . $val . "F:{$factor}(" . $this->GetCounterFactor() . ")");
                         } else {
                             $this->debug(__FUNCTION__, "EMWZ:No vid for PPower");
                         }
                         break;
                     case 'EMEM':
                         $pvid = $this->GetIDForIdent('PPower');
                         if ($pvid) {
                             $factor = $this->GetCounterFactor();
                             if ($factor == 0) {
                                 $factor = 100;
                             }
                             $val = $iv * (1 / $factor) * 1000;
                             //W statt KW
                             SetValueFloat($pvid, $val);
                             $this->debug(__FUNCTION__, "EMEM:PPower:({$pvid})=" . $val . " F:{$factor}(" . $this->GetCounterFactor() . ")");
                         } else {
                             $this->debug(__FUNCTION__, "EMEM:No vid for PPower");
                         }
                         break;
                     case 'EMGZ':
                         $pvid = $this->GetIDForIdent('PGas');
                         if ($pvid) {
                             $factor = $this->GetCounterFactor();
                             if ($factor == 0) {
                                 $factor = 100;
                             }
                             $val = $iv * (1 / $factor);
                             //m3
                             SetValueFloat($pvid, $val);
                             $this->debug(__FUNCTION__, "EMGZ:PGas:({$pvid})=" . $val . " F:{$factor}(" . $this->GetCounterFactor() . ")");
                         } else {
                             $this->debug(__FUNCTION__, "EMGZ:No vid for PGas");
                         }
                         break;
                 }
                 SetValueInteger($vid, $iv);
                 break;
                 //int types
             //int types
             case 'Signal':
                 //RSSI
             //RSSI
             case 'LoadPct':
                 //Load in Pct
             //Load in Pct
             case 'Charged':
                 //Charged in Pct
             //Charged in Pct
             case 'OCounter':
                 //old counter
             //old counter
             case 'TS':
                 //Timestamp
                 $iv = (int) $s;
                 SetValueInteger($vid, $iv);
                 break;
                 //float types with factor
             //float types with factor
             case 'AGas':
                 //Actual
             //Actual
             case 'TGas':
                 //Total
             //Total
             case 'PGas':
                 //Peak
             //Peak
             case 'APower':
                 //Actual
             //Actual
             case 'PPower':
                 //Peak
             //Peak
             case 'TPower':
                 //Total
             //Total
             case 'AWater':
                 //Actual
             //Actual
             case 'TWater':
                 //Total
             //Total
             case 'PWater':
                 //Peak
                 $fv = (double) $s;
                 $factor = $this->GetCounterFactor();
                 $val = $fv * $factor;
                 SetValueFloat($vid, $val);
                 break;
                 //float types
             //float types
             case 'VoltIn':
                 //InputVolt
             //InputVolt
             case 'VoltOut':
                 //Output Volt
             //Output Volt
             case 'Nominal':
                 //Nominal Power
             //Nominal Power
             case 'Watt':
                 //Absolute Load
             //Absolute Load
             case 'Freq':
                 //Frequency
             //Frequency
             case 'TimeLeft':
                 //TimeLeft
                 $fv = (double) $s;
                 SetValueFloat($vid, $fv);
                 break;
                 //string types
             //string types
             case 'Name':
             case 'Status':
                 $st = utf8_decode($s);
                 SetValueString($vid, $st);
                 break;
             default:
                 $this->debug(__FUNCTION__, "{$cap} not handled");
         }
         //switch
         $this->debug(__FUNCTION__, "{$cap}:({$vid})=" . $s);
     }
     //for
 }
Пример #15
0
	/**
	* This functions will be available automatically after the module is imported with the module control.
	* Using the custom prefix this function will be callable from PHP and JSON-RPC through:
	*
	* e.g. MILIGHT_SetSatte($id,$state);
	*
	*/

	public function SetState(integer $State)
	{
		//$OldState = GetValueInteger($this->GetIDForIdent('STATE'));

		switch ($State) {
		case 0: // aus
			$this->SetBrightness(0);
			break;
		case 1: // weiß
			$Brightness = GetValueInteger($this->GetIDForIdent('Brightness'));
			$this->SetBrightness($Brightness);
			break;
		case 2: // Farbe
			$Color = GetValueInteger($this->GetIDForIdent('Color'));
			$this->SetColor($Color);
			break;
		}
		$this->SetVisibility($State);
	}
Пример #16
0
            if ($sleeptimer) {
                $SleeptimerArray = explode(":", $sonos->GetSleeptimer());
                $SleeptimerMinutes = $SleeptimerArray[0] * 60 + $SleeptimerArray[1];
                if ($SleeptimerArray[2]) {
                    $SleeptimerMinutes = $SleeptimerMinutes + 1;
                }
            } else {
                $SleeptimerMinutes = 0;
            }
            SetValueInteger(IPS_GetObjectIDByName("Sleeptimer", IPS_GetParent($_IPS["SELF"])), $SleeptimerMinutes);
        }
    }
    $nowPlaying = GetValueString(IPS_GetObjectIDByName("nowPlaying", IPS_GetParent($_IPS["SELF"])));
    if ($actuallyPlaying != $nowPlaying) {
        SetValueString(IPS_GetObjectIDByName("nowPlaying", IPS_GetParent($_IPS["SELF"])), $actuallyPlaying);
    }
}
// Set Group Volume
if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "GroupCoordinator")) {
    $groupMembers = GetValueString(IPS_GetObjectIDByName("GroupMembers", IPS_GetParent($_IPS["SELF"])));
    $groupMembersArray = array();
    if ($groupMembers) {
        $groupMembersArray = array_map("intval", explode(",", $groupMembers));
    }
    $groupMembersArray[] = IPS_GetParent($_IPS["SELF"]);
    $GroupVolume = 0;
    foreach ($groupMembersArray as $key => $ID) {
        $GroupVolume += GetValueInteger(IPS_GetObjectIDByName("Volume", $ID));
    }
    SetValueInteger(IPS_GetObjectIDByName("GroupVolume", IPS_GetParent($_IPS["SELF"])), intval(round($GroupVolume / sizeof($groupMembersArray))));
}
 /**
  * handle incoming data along capabilities
  * @param array $data
  */
 private function ParseData($data)
 {
     //
     $caps = $this->GetCaps();
     //$this->debug(__FUNCTION__,print_r($this->all_caps,true));
     foreach (array_keys($caps) as $cap) {
         $ident = $caps[$cap];
         $vid = @$this->GetIDForIdent($ident);
         if ($vid == 0) {
             $this->debug(__FUNCTION__, "Cap {$cap} Ident {$ident}: Variable missed");
             continue;
         }
         if (!isset($data[$cap])) {
             continue;
         }
         $s = $data[$cap];
         switch ($cap) {
             //integer
             case 'TS':
                 //Timestamp
             //Timestamp
             case 'Signal':
                 //RSSI
             //RSSI
             case 'Timer':
                 //Duration code
             //Duration code
             case 'Dimmer':
                 //intensity 100%
             //intensity 100%
             case 'Shutter':
                 //intensity 100%
                 $iv = (int) $s;
                 SetValueInteger($vid, $iv);
                 break;
                 //String
             //String
             case 'Name':
                 //Duration code
                 $st = utf8_decode($s);
                 SetValueString($vid, $st);
                 break;
                 //special
             //special
             case 'Switch':
                 //Status
                 $state = $this->SwitchStatus($s);
                 SetValueBoolean($vid, $state);
                 break;
             case 'Lock':
                 //Status
                 $state = preg_match("/YES|CLOSE|OK/i", $s);
                 //reversed
                 SetValueBoolean($vid, $state);
                 break;
             case 'Alert':
                 //Status
                 $state = !preg_match("/YES|ALERT/i", $s);
                 //reversed
                 SetValueBoolean($vid, $state);
                 break;
             case 'Battery':
                 //battery
                 $state = !preg_match("/LOW|WARN/i", $s);
                 //reversed
                 SetValueBoolean($vid, $state);
                 break;
             case 'FS20':
                 //fs20 mode decoding
                 $state = false;
                 $intensity = 0;
                 $timer = 0;
                 $acode = '';
                 $actioncode = '';
                 $code = utf8_decode($s);
                 $this->debug(__FUNCTION__, "FS20 Code " . strToHex($code));
                 $action = $code[0];
                 $ext = ord($code[1]);
                 $tvid = @$this->GetIDForIdent($caps['Timer']);
                 $dvid = @$this->GetIDForIdent($caps['Dimmer']);
                 $swid = @$this->GetIDForIdent($caps['Switch']);
                 $avid = @$this->GetIDForIdent($caps['TimerActionCode']);
                 $this->debug(__FUNCTION__, "FS20 Vars S:{$swid},D:{$dvid},T:{$tvid},A:{$avid}");
                 if ($dvid) {
                     $intensity = GetValueInteger($dvid);
                 }
                 if ($swid) {
                     $state = GetValueBoolean($swid);
                 }
                 if ($tvid) {
                     $timer = GetValueInteger($tvid);
                 }
                 if ($avid) {
                     $acode = GetValueString($avid);
                 }
                 $ac = ord($action) & 0x1f;
                 $timed = ($action & 0x20) > 0;
                 $this->debug(__FUNCTION__, "FS20 AC:" . $ac . "PrevD:{$intensity}, PrevS:" . ($state ? "On" : "Off"));
                 switch ($ac) {
                     case 0:
                         //off
                         if ($timed) {
                             $actioncode = 'Switch:Off';
                         } else {
                             $state = false;
                         }
                         break;
                     case $ac < 0xf:
                         //Dim to value
                         $intensity = FHZ_helper::fs20_intensity_percent($action & 0xf);
                         $state = true;
                         if ($timed) {
                             $actioncode = 'Switch:Off';
                         }
                         break;
                     case 0x10:
                         //on full
                         $state = true;
                         $intensity = 100;
                         if ($timed) {
                             $actioncode = 'Switch:Off';
                         }
                         break;
                     case 0x11:
                         //on with old value
                         $state = true;
                         if ($intensity == 0) {
                             $intensity = 100;
                         }
                         if ($timed) {
                             $actioncode = 'Switch:Off';
                         }
                         break;
                     case 0x12:
                         $state = !GetValueBoolean($swid);
                         //toggle
                         break;
                     case 0x13:
                         //dimup
                         $steps = FHZ_helper::fs20_intensity_steps($intensity);
                         $intensity = FHZ_helper::fs20_intensity_percent($steps + 1);
                         $state = true;
                         break;
                     case 0x14:
                         //dimdown
                         if ($intensity == 0) {
                             $intensity = 100;
                         }
                         $steps = FHZ_helper::fs20_intensity_steps($intensity);
                         $intensity = FHZ_helper::fs20_intensity_percent($steps - 1);
                         if ($intensity == 0) {
                             $state = false;
                         }
                         break;
                     case 0x18:
                         //off-for-timer
                         $state = 'Off';
                         $actioncode = 'Switch:On';
                         break;
                     case 0x19:
                         //on-for-timer than out
                         $state = true;
                         $actioncode = 'Switch:Off';
                         break;
                     case 0x1a:
                         //on-old-for-timer than out
                         $state = true;
                         $actioncode = 'Switch:Off';
                         break;
                     case 0x1c:
                         //ramp-on-time (time to reach the desired dim value on dimmers)
                         $state = true;
                         $actioncode = "Dimmer:{$intensity}";
                         break;
                     case 0x1d:
                         //ramp-off-time (time to reach the off state on dimmers)
                         $actioncode = 'Switch:Off;Dimmer:0';
                         break;
                     case 0x1e:
                         //on-old-for-timer-prev", // old val for timer, then go to prev. state
                         $actioncode = "Switch:" . ($state ? 'On' : 'Off');
                         $state = true;
                         break;
                     case 0x1f:
                         //on-100-for-timer-prev", // 100% for timer, then go to previous state
                         //new intensity will be the old one
                         $action = "Switch:" . ($state ? 'On' : 'Off') . ";Dimmer:{$intensity}";
                         $intensity = 100;
                         $state = true;
                         break;
                     case 0x15:
                         //dimupdown, no value changes
                     //dimupdown, no value changes
                     case 0x16:
                         //Set Timer
                     //Set Timer
                     case 0x17:
                         //nop
                     //nop
                     case 0x1b:
                         //rese
                         break;
                 }
                 $new_timer = FHZ_helper::fs20_times($ext);
                 $this->debug(__FUNCTION__, "State:" . ($state ? "ON" : "OFF") . ", Dimmer:{$intensity}%,Timer: {$new_timer},ActionCode: '{$actioncode}'");
                 //state
                 if ($swid) {
                     SetValueBoolean($swid, $state);
                 }
                 //dimmer
                 if ($dvid) {
                     SetValueInteger($dvid, $intensity);
                 }
                 //timer
                 if ($tvid) {
                     $this->SetTimerInterval('DeviceTimer', $new_timer * 1000);
                     SetValueInteger($tvid, $new_timer);
                 }
                 //action
                 if ($avid && $acode != $actioncode) {
                     SetValueString($avid, $actioncode);
                 }
                 //log
                 $actiontext = FHZ_helper::$fs20_codes[strToHex($action)];
                 if ($ext > 0) {
                     $actiontext .= ', Timer:' . $timer;
                 }
                 $text = sprintf('%s (%s)', $actiontext, strToHex($code));
                 if ($vid) {
                     SetValueString($vid, $text);
                 }
                 $this->debug(__FUNCTION__, "Action:" . $text);
                 break;
             default:
                 $this->debug(__FUNCTION__, "{$cap} not handled");
         }
         $this->debug(__FUNCTION__, "{$cap}:({$vid})" . $s);
     }
 }
Пример #18
0
 private function SetValueInteger($Ident, $value)
 {
     $id = $this->GetIDForIdent($Ident);
     if (GetValueInteger($id) != $value) {
         SetValueInteger($id, $value);
     }
 }
Пример #19
0
 private function SendCommand(TXB_Command_Data $ATData)
 {
     if (!$this->HasActiveParent()) {
         throw new Exception("Instance has no active Parent.");
     }
     //        $ReplayATData = new TXB_Command_Data();
     $FrameID = $this->GetIDForIdent('FrameID');
     $ReplyATDataID = $this->GetIDForIdent('ReplyATData');
     if (!$this->lock('RequestSendData')) {
         throw new Exception('RequestSendData is locked');
     }
     $Frame = GetValueInteger($FrameID);
     if ($Frame == 255) {
         $Frame = 1;
     } else {
         $Frame++;
     }
     SetValueInteger($FrameID, $Frame);
     if (!$this->lock('ReplyATData')) {
         $this->unlock('RequestSendData');
         throw new Exception('ReplyATData is locked');
     }
     SetValueString($ReplyATDataID, '');
     $this->unlock('ReplyATData');
     $ATData->FrameID = $Frame;
     try {
         $this->SendDataToParent($ATData);
     } catch (Exception $exc) {
         $this->unlock('RequestSendData');
         throw new Exception($exc);
     }
     $ReplayATData = $this->WaitForResponse();
     //        IPS_LogMessage('ReplayATData:'.$this->InstanceID,print_r($ReplayATData,1));
     if ($ReplayATData === false) {
         //          Senddata('TX_Status','Timeout');
         $this->unlock('RequestSendData');
         throw new Exception('Send Data Timeout');
     }
     if ($ReplayATData->Status == TXB_Command_Status::XB_Command_OK) {
         //            Senddata('TX_Status','OK')
         $this->unlock('RequestSendData');
         return $ReplayATData;
     }
     //        Senddata('TX_Status','Error: '+ XB_Transmit_Status_to_String(fTransmitStatus));
     $this->unlock('RequestSendData');
     throw new Exception('Error on Transmit:' . ord($ReplayATData->Status));
 }
 /**
  * parses an record string
  * 
  * @param $txt string Output from ws2500 program
  * @return array
  */
 private function Parse($txt)
 {
     /*
      # Sensorname[-number] (drop outs): values of sensor
      ## Blocknumber: Block(1)
      ## Date: Cal(date), time(sec)
      ## Station: Id(1)
      ## THS(Temp/humidity): Temperatur(�C), Humidity(%), New(1)
      ## PS(Pressure): Pressure-relativ(hPa), New
      ## RS(Rain): Counter(1), OneCount(mm/1000), Rain(mm/1000), Tol(1), New(1)
      ## WS(Wind): Speed(Km/h), Direction(�), Variance(�), New(1)
      ## LS(Light): Light(lux), Factor(1), Flag(1), Duration(h), DeltaDuration(min), New(1)
      ## PYS(Pyranometer): Energy(W/m), Factor(1)
      #
      Blocknumber: 348
      Date: Sun May  8 06:56:17 2016, 1462690577
      Station: 1
      THS-1 (0): 24.9, 20, h
      THS-2 (1): 20.4, 44, 1
      THS-3 (0): 23.7, 21, 1
      THS-4 (0): 23.0, 31, 1
      THS-5 (0): 22.1, 32, 1
      THS-6 (0): 24.5, 28, 1
      THS-7 (1): 17.3, 45, 1
      THS-8 (1): 17.0, 51, 1
      THS-17 (0): 23.2, 32, 1
      PS     (0): 1009, 1
      LS    (0): 479, 100, 0, 52.27, -1, 1
     */
     $lines = explode("\n", $txt);
     if (count($lines) < 4) {
         $this->debug(__FUNCTION__, 'Not enough data');
         return;
     }
     foreach ($lines as $line) {
         if (!isset($line[0])) {
             continue;
         }
         if ($line[0] == '#') {
             continue;
         }
         if ($line[0] == '+') {
             continue;
         }
         $result = array();
         $datum = date('Y-m-d H:i:s');
         if (preg_match_all("/^([\\w-]+).*?:\\s+(.*)\$/", $line, $result)) {
             $dev = $result[1][0];
             $typ = $dev;
             $id = 0;
             $p = strpos($dev, '-');
             if ($p > 0) {
                 $typ = substr($dev, 0, $p);
                 $id = substr($dev, $p + 1);
             }
             $values = $result[2][0];
             //$values=str_replace(" ",'',$values);
             $data = array();
             $data['Id'] = $dev;
             $caps = '';
             switch ($typ) {
                 case 'Date':
                     list($d, $ts) = explode(',', $values);
                     $tsid = @$this->GetIDForIdent('TimeStamp');
                     if ($tsid > 0) {
                         $old = GetValueInteger($tsid);
                         if ($ts > $old) {
                             SetValueInteger($tsid, $ts);
                         }
                     }
                     $datum = date('Y-m-d H:i:s', $ts);
                     $this->debug(__FUNCTION__, "Date: {$d}, TS {$ts}, Datum {$datum}");
                     break;
                 case 'Blocknumber':
                     $block = $values;
                     $blid = @$this->GetIDForIdent('Block');
                     if ($blid > 0) {
                         $old = GetValueInteger($blid);
                         if ($block != $old) {
                             SetValueInteger($blid, $block);
                         } else {
                             $this->debug(__FUNCTION__, "BlockNumber ({$block}) is the same, skipping");
                             return;
                         }
                     }
                     $this->debug(__FUNCTION__, "Blocknumber: {$block}");
                     break;
                 case 'Station':
                     break;
                 case 'THS':
                     $values = str_replace(" ", "", $values);
                     list($temp, $hum, $new) = explode(',', $values);
                     $new = trim($new);
                     if ($new != '0') {
                         $data['Date'] = $datum;
                         $data['Typ'] = 'T/F';
                         $caps .= 'Temp;Hum;';
                         if ($id == 17) {
                             $data['Typ'] = 'Indoor';
                             $data['Id'] = 'Indoor';
                             $caps .= 'Press;';
                         }
                         $data['Temp'] = $temp;
                         $data['Hum'] = $hum;
                         $this->debug(__FUNCTION__, "{$dev}: Temp:{$temp}, Hum:{$hum}");
                         $this->SendWSData($data, $caps);
                     }
                     break;
                 case 'RS':
                     $values = str_replace(" ", "", $values);
                     list($rc, $cf, $rain, $tol, $new) = explode(',', $values);
                     if ($new == 1) {
                         $rcid = @$this->GetIDForIdent('LastRainCounter');
                         $dailyid = @$this->GetIDForIdent('NewDayRainCounter');
                         //build diffs
                         $old = GetValueInteger($rcid);
                         $daily = GetValueInteger($dailyid);
                         $diff = $new - $old;
                         //counter overflow 4096
                         if ($diff < 0) {
                             $diff += 4096;
                         }
                         $dailydiff = $new - $daily;
                         if ($dailydiff < 0) {
                             $dailydiff += 4096;
                         }
                         $crain = $diff * $this->GetRainPerCount() / 1000;
                         if ($crain != $rain) {
                             $this->debug(__FUNCTION__, "Rain different c:{$crain},d:{$rain} ");
                         }
                         $raindaily = $dailydiff * $this->GetRainPerCount() / 1000;
                         $dailyvar = IPS_GetVariable($dailyid);
                         $dailyupdated = $dailyvar['VariableUpdated'];
                         if (is_new_day($dailyupdated)) {
                             //new day routine,set
                             //$rcvar=IPS_GetVariable($rcid);
                             //$updated=$rcvar['VariableUpdated'];
                             //if($updated<$date) {
                             //set last day sum
                             $this->debug(__FUNCTION__, 'NewDay, Store old Counter');
                             SetValueInteger($dailyid, $old);
                             //}
                         }
                         if ($new > $old) {
                             SetValueInteger($rcid, $new);
                         }
                         if ($rain < 0 or $rain > 100) {
                             $rain = 0;
                         }
                         if ($raindaily < 0 or $raindaily > 500) {
                             $raindaily = 0;
                         }
                         $data['Date'] = $datum;
                         $data['Typ'] = 'Rain';
                         $data['Rain'] = $rain;
                         $data['RainCounter'] = $rc;
                         $data['RainDaily'] = $raindaily;
                         $data['CounterFactor'] = $cf;
                         $caps .= 'RainCounter;Rain;RainDaily;';
                         $this->debug(__FUNCTION__, "Rain Counter:{$rc}, Rain:{$rain}, cf: {$cf}, daily: {$raindaily} ,TOL:{$tol}");
                         $this->SendWSData($data, $caps);
                     }
                     break;
                 case 'WS':
                     $values = str_replace(" ", "", $values);
                     list($speed, $dir, $var, $new) = explode(',', $values);
                     if ($new == 1) {
                         $data['Date'] = $datum;
                         $data['Typ'] = 'Wind';
                         $data['WindSpeed'] = $speed;
                         $data['WindDir'] = $dir;
                         $data['WindVar'] = $var;
                         $caps .= 'WindSpeed;WindDir;WindVar';
                         $this->debug(__FUNCTION__, "Wind Speed:{$speed}, Dir:{$dir}, Var: {$var}");
                         $this->SendWSData($data, $caps);
                     }
                     break;
                 case 'LS':
                     $values = str_replace(" ", "", $values);
                     list($light, $factor, $flag, $dur, $deltadur, $new) = explode(',', $values);
                     if ($new == 1) {
                         $data['Date'] = $datum;
                         $data['Typ'] = 'Light';
                         $data['Light'] = $light * $factor;
                         $caps .= 'Light;';
                         $this->debug(__FUNCTION__, "Light {$light} factor: {$factor}, Flag:{$flag}, Dur:{$dur}, Deltadur:{$deltadur}");
                         $this->SendWSData($data, $caps);
                     }
                     break;
                 case 'PYS':
                     $values = str_replace(" ", "", $values);
                     list($light, $factor, $new) = explode(',', $values);
                     if ($new == 1) {
                         $data['Date'] = $datum;
                         $data['Typ'] = 'Pyrano';
                         $data['UV'] = $light * $factor;
                         $caps .= 'UV;';
                         $this->debug(__FUNCTION__, "PYR {$light} factor: {$factor} ");
                         $this->SendWSData($data, $caps);
                     }
                     break;
                 case 'PS':
                     $values = str_replace(" ", "", $values);
                     list($press, $new) = explode(',', $values);
                     if ($new == 1) {
                         $data['Date'] = $datum;
                         $data['Typ'] = 'Indoor';
                         $data['Id'] = 'Indoor';
                         $data['Press'] = $press;
                         $caps .= 'Press;';
                         $this->debug(__FUNCTION__, "Press {$press}");
                         $this->SendWSData($data, $caps);
                     }
                     break;
                 default:
                     $this->debug(__FUNCTION__, "Unknown type '{$typ}'");
                     break;
             }
             //switch
         }
         //match  line
     }
     //for lines
 }