=1s) as well as individual signal decoding (fast operation 0.1s or "onChange event") // This solution do not contains Direct Events (Command Editor) it must be copied from external "Advanced Event Creators" for individual systems. // // Please refer to comments and descriptions in the file // we want make this constants global for individual access from outside class $EHOUSE_WIFI_MAX_ADC=4; //Analogue to digital converters - measurement inputs $EHOUSE_WIFI_MAX_INPUTS=8; //digital inputs $EHOUSE_WIFI_MAX_OUTPUTS=8; //digital outputs $EHOUSE_WIFI_MAX_DIMMERS=4; //PWM DIMMERS $nrdim=1; //for commands nr range (1...max) //please refer to eHouse LAN TCP/UDP protocol for full stats frame and event codes. //this binary status addresses/offsets can be used for individual query of single bit signals with eH(start_address,$nr), Sat(start_address,$nr) //or executed directly with Get*Status($nr); //$STATUS_TCP_OFFSET =2; //offset in current status for data $MCP9700_Offset=-500.0; //Offset voltage at 0 C [mV] global setting can be replace for array for individual calibration $MCP9701_Offset=-400.0; //Offset voltage at 0 C [mV] global setting can be replace for array for individual calibration $MCP9700x=10000.0; // uV/C global setting can be replace for array for individual calibration $MCP9701x=19500.0; //Ehouse1 under CommManager supervisor //in reference to STATUS_COMMMANAGER_OFFSET each ethernet controllers class eHouseWiFiC { // Class Functions //function __construct($str);//validate eHouse WiFi hex coded status + load to $TextStatus and convert to binary (array of integers) $Bin //public function eH($TempOffset,$k);//get bit field value for specified eHouse signal type $k index 0..n, $TempOffset - first address of the signal *_ADDR //public function hexi(); //convert $TextStatus to binary Status $Bin //function Display();//Display Decoded status - for debuging only //function DecodeEhouseLanStatus();//Decode full eHouseLan Devices Status (when no ultra-fast operation is required) into all class fields/arrays //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////FAST USAGE function without performing whole eHouseLAN Devices status - only indvidual items//////////////////////////////////////////// //public function eH($TempOffset,$k);//fast usage for eHouse.Lan without storing data to arrays eg $o11=eH($EHOUSE_LAN_OUTPUTS_ADDR,10); //state of 11th binary output //public function GetInStatus($nr); //Get Binary Input Status 0...max //public function GetOutStatus($nr); //Get Binary Output Status 0...max //public function GetDimmerStatus($nr); //Get Dimmer Status 0...max //public function GetADCStatus($nr); //Get ADC Input Status 0...max //public function GetAdcHStatus($nr) //Get ADC HighLevel Status 0...max //public function GetAdcLStatus($nr) //Get ADC LowLevel Status 0...max //public function GetMCP9701Status($nr) //Get MCP9701 temp sensor Status 0...max //public function GetMCP9700Status($nr) //Get MCP9700 temp sensor Status 0...max //public function GetTempHStatus($nr) //Get mcp9700 temp high level calculated 0...max //public function GetTempLStatus($nr) //get mcp9700 temp low level calculated 0...max //public function GetLM35Status($nr) //Get LM35 temp sensor Status 0...max //public function GetInvPercentStatus($nr) //Get ADC inverted scale Status 0...max //public function GetPercentStatus($nr) //Get ADC Percent Status 0...max //public function GetTempLMStatus($nr) //Get LM335 temp sensor Status 0...max //public ExecCommand($cmd); //prints (echo) direct command/event to be captured by eHouse.PRO Server /////=== === Event creators //function ExecInputWiFi($nr,$invin,$alarmin,$alarmdelay,$rememberstate,$disableevent); //public function ExecRGBDimmerWiFi($nr,$modedim,$valuedima,$valuedimb,$valuedimc,$valuedimd,$vgroup=0,$hgroup=0,$Rcont=0,$Gcont=0,$Bcont=0,$Wcont=0); //function ExecDimmerWiFi($nr,$invertdimm,$admin,$disable,$mindim,$valuedim,$modedim,$stepdim,$maxdim,$vgroup=0,$hgroup=0); //function ExecADCWiFi($nr,$invertadc,$alarmadcl,$alarmadch,$alarmdelayadc,$lleveladc,$hleveladc,$adcdis,$admin); //public function ExecDriveWiFi( $nr,$admin,$stateout,$repeat,$timeonout,$timeoffout,$timedisabledrv,$disabledrv,$somfy=0,$vgroup=0,$hgroup=0); //public function ExecOutputWiFi($nr,$stateout,$disableout,$adminout,$repeatouts,$timeonout,$timeoffout,$vgroup,$hgroup); //function ExecInputWiFi($nr,$invin,$alarmin,$alarmdelay,$rememberstate,$disableevent); //public function ExecADCLevels($nr,$min,$max,$admin=0,$invert=0,$alarmL=0,$alarmH=0,$disablevent=0); //public function ExecOut($nr,$state=2,$time=0) //public function ExEv($cmd,$arg1=0,$arg2=0,$arg3=0,$arg4=0,$arg5=0,$arg6=0,$arg7=0) //exec all events //public function ExecProgram($nr) exec out+dimm program //public function ExecRGBDimmerWiFi($nr,$modedim,$valuedima,$valuedimb,$valuedimc,$valuedimd,$vgroup=0,$hgroup=0,$Rcont=0,$Gcont=0,$Bcont=0,$Wcont=0) //function ExecDimmerWiFi($nr,$invertdimm,$admin,$disable,$mindim,$valuedim,$modedim,$stepdim,$maxdim,$vgroup=0,$hgroup=0) //public function ExecADCLevels($nr,$min,$max) set adc levels //public function ExecOut($nr,$state=2,$time=0) set output //public function ExecIncDecProgram($dir) inc/dec program //public function ExecADCProgram($nr) set adc program //public function ExecSecuProgram($nr) set rollers programs //public function ExecZoneChange($nr,$delay) set security zone //public function ExecRoller($nr,$mode) set single roller/drive/servo //public function ExecMultiRoller($arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7) set multiple rollers //public function ExecBatch($nr,$count) exec batch commands //public function ExecDecLights($nr,$step) decrement dimm light //public function ExecIncLights($nr,$step) increment dimm light //public function ExecStopLights($nr,$step) stop dimm light //public function ExecSetLight($nr,$value) set light //public function ExecToggleLights($nr,$step) stop if moving else oposite direction //public function ExecDecOnceLights($nr,$step) decrement one step //public function ExecIncOnceLights($nr,$step) increment one step //public function ExecSetSingleLight($nr,$level) set dimmer light //public function ExecDecDMX($nr,$step=1) decrement dmx light //public function ExecIncDMX($nr,$step=1) increment dmx light //public function ExecStopDMX($nr,$step=5) stop dmx light //public function ExecSetDMX($nr,$step) set dmx light //public function ExecSetRGBDMX($nr,$R,$G,$B) set rgb dmx light //public function ExecSendDaliCMD($msb,$lsb) send dali command //public function ExecSetDaliLight($nr,$mode,$step) set dali light //public function ExecSetDaliScene($nr) set dali scene //public function ExecSetDMXScene($nr) set dmx scene //public function ExecSubmitToStatus($arg1=0,$arg2=0,$arg3=0,$arg4=0,$arg5=0,$arg6=0,$arg7=0) //submit data to the status //public function ExecSendTCPLog($arg1=0,$arg2=0,$arg3=0,$arg4=0,$arg5=0,$arg6=0,$arg7=0) //Send Data to the Log via tcp/ip //public function ExecSendUDP($arg1=0,$arg2=0,$arg3=0,$arg4=0,$arg5=0,$arg6=0,$arg7=0) //send data via udp //public function ExecSendLog($arg1=0,$arg2=0,$arg3=0,$arg4=0,$arg5=0,$arg6=0,$arg7=0) //Send Data to the Log //public function ExecSendIR($irmode,$arg1=0,$arg2=0,$arg3=0,$arg4=0,$arg5=0,$arg6=0) //Send Infrared remote contoller code //public function ExecScanIR() //Send IR Scan Command //public function ExecRestart() //Send Data to the Log //public function ExecSendIRAlias($cmdadr1=0,$cmdadr2=0,$cmdadr3=0,$cmdadr4=0) //// // /////////////////////////////////////////////////////////////////////////////////////////////////////////// /// please copy-paste direct event from external event creators for desired eHouse systems public $NrFromOne=1; //if $NrFromOne=1 number in events are sterted from 1, If $NrFromOne=0 numbers starts from 0 public $ProcessChangedOnly=1; //only modified statuses are performed (containing * at the end of status public $WasChanged=0; //data was changed flag public $TotalOffset=4; //offset in status for data status fields public $ExtendedStatus=0; //Long status detected automatically public $DisplayToFileOnly=1; //display() do not echo to the screen public $ADC_OFFSET_WIFI=0; //relative offset in the status data + TotalOffset public $DIMM_OFFSET_WIFI=8; public $OUT_OFFSET_WIFI=12; public $IN_OFFSET_WIFI=13; public $OUT_PROGRAM_OFFSET_WIFI=14; public $MODE_OFFSET_WIFI=14; public $ADCPRG_OFFSET_WIFI=15; public $MOD2_OFFSET_WIFI=15; public $ADCL_OFFSET_WIFI=16; public $ADCH_OFFSET_WIFI=24; public $RSSI_OFFSET_WIFI=32; public $QSI_OFFSET_WIFI=33; public $SINCE_OFFSET_WIFI=34; public $TextStatus; //captured hex decoded string of status public $results; //to store display out for written to file (Display function() public $AutoDecode=0; //run automatic decode on data reception public $Bin=array(0,0,0); //status converted to array of integers public $ALARM_ENABLED=1; //we can disable processing some of data for speed public $DIMMERS_ENABLED=1; //public $DMX_DALI_DIMMERS_ENABLED=1; public $ADCS_ENABLED=1; public $HALF_ADC=4; //if 1 all inputs taken if 2 => half (EHOUSE_WIFI_MAX_ADC/HALF_ADC) public $HALF_INPUTS=2; //if 1 all inputs taken if 2 => half (EHOUSE_WIFI_MAX_INPUTS/HALF_INPUTS) public $HALF_OUTPUTS=2; //if 1 all inputs taken if 2 => half (EHOUSE_WIFI_MAX_OUTPUTS/HALF_OUTPUTS) public $HALF_DIMMERS=1; //if 1 all dimmers taken if 2 => half (EHOUSE_WIFI_MAX_DIMMERS/HALF_DIMMERS) public $StatusReceived=0; //flag that status was received public $StatusDecoded=0; //set flag that valid eHouse.PRO status received and decoded // status fields of eHouse WiFi Controllers status fields public $AdrH=0; //eHouse WiFi address 192.168.AdrH.AdrL public $AdrL=0; public $adc=array(4); //ADC 2B fields public $PresetH=array(4); //High Level Preset for ADC public $PresetL=array(4); //Low Level Preset for ADC public $SensorTemps=array(4); public $SensorPercents=array(4); public $SensorLights=array(4); public $SensorTempsLM35=array(4); public $SensorTempsMCP9700=array(4); public $SensorTempsMCP9701=array(4); public $SensorVolts=array(4); public $out=array(8); //Binary Optputs public $in=array(8); //Binary Inputs //public $Alarm=array(8); //Binary Inputs which activate Alarm Signal in current security zone public $Dimmer=array(4); //Dimmers 1B results (0..100%) //public $DimmerDali=array(46); //Dimmers 1B results (0..100%) //public $DimmerDMX=array(32); //Dimmers 1B results (0..100%) // Calibration for calculating ADC for MCP9700 public $Calibration=array(-500.0,-500.0,-500.0,-500.0); //Calibration for calculating ADC public $VCC=1000; //Supply Voltage for ADC calculation (if not refference source is used - otherwise assign 2096) public $ProgramNr; //1B - current program/scene for Outputs public $AdcProgramNr; //1B - current Regulation Program for ADCs public $RollerProgram; //1B - current Drives Program for servos, gates, Doprs, windows public $SecuZone; //1B - current Security Zone //////////////////////////////////////////////////////////////////////////////// public function eH($TempOffset,$k) //return individual bitwise status value of eHouse signal { $d=intdiv($k,8); return ((($this->Bin[$TempOffset+$d]>>($k%8))&0x01)); } //////////////////////////////////////////////////////////////////////////////// //convert text status to binary int array public function hexi() { $str=$this->TextStatus; $in=array(0,0,0); $k=0; for ($i=0;$iBin=$in; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //display text and append to log public function e($str) { $this->results.=$str; if (!$this->DisplayToFileOnly) {echo $str;} } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Get***Status() reads directly from $Bin status aray (no total conversion "Decode***" is required) //Get input Status Dire public function GetInStatus($nr) //0...max { return $this->eH($this->TotalOffset + $this->IN_OFFSET_WIFI,$nr); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public function GetOutStatus($nr) //0...max { return $this->eH($this->TotalOffset + $this->OUT_OFFSET_WIFI ,$nr); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // get dimer value 0..100% public function GetDimmerStatus($nr) //0...max { return $this->Bin[$this->TotalOffset+$nr + $this->DIMM_OFFSET_WIFI];//result already 0..100% //return (($this->Bin[$this->TotalOffset+$nr + $this->DIMM_OFFSET_WIFI]&0xff)/0xff)*100);//if result 0..255 } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //get adc/regulation program NR public function GetADCPgmStatus() { return $this->Bin[$this->TotalOffset + $this->ADCPGM_OFFSET_WIFI]&0b011111; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Get Outs/Dimm Program public function GetPgmStatus() { return $this->Bin[$this->TotalOffset + $this->PGM_OFFSET_WIFI]&0b011111; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public function GetModStatus() { return $this->Bin[$this->TotalOffset + $this->MOD_OFFSET_WIFI]>>3; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public function GetModStatus2() { return $this->Bin[$this->TotalOffset + $this->MOD2_OFFSET_WIFI]>>3; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Get WiFi Signal Level in dBm public function GetRSSIStatus() { $rssi=$this->Bin[$this->TotalOffset + $this->RSSI_OFFSET_WIFI]; if ($rssi<128) {return $rssi;} else {return ($rssi-256);} } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Get time from reboot the controller in minutes public function GetActiveTimeStatus() { $since=$this->Bin[$this->TotalOffset + $this->SINCE_OFFSET_WIFI]; $since=$since<<8; $since+=$this->Bin[$this->TotalOffset + $this->SINCE_OFFSET_WIFI+1]; return $since; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ADC values (0..1024) - result ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public function GetADCStatus($nr) //0...max { $temppp=(($this->Bin[$this->TotalOffset+$this->ADC_OFFSET_WIFI + $nr * 2 ]&0x03)); $temppp=$temppp<<8; $temppp+= $this->Bin[$this->TotalOffset+$this->ADC_OFFSET_WIFI + $nr * 2 +1 ]&0xff; return $temppp; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Calculated Temperature for LM335 temp sensor from ADC result public function GetTempLMStatus($nr) //0...max { $temppp= $this->GetADCStatus($nr); return ($this->gettemplm($temppp, $this->Calibration[$nr], 10, $this->VCC)); } //////////////////////////////////////////////////////////////////////////////////// //Calculated percent voltage value comparing to VCC or reference source from ADC result public function GetPercentStatus($nr) //0...max { $temppp= $this->GetADCStatus($nr); return (round($this->calculate_percent($temppp))*10)/10; } ///////////////////////////////////////////////////////////////////////////////////// // Calculated inverted percent 100%-x public function GetInvPercentStatus($nr) //0...max { return 100-GetPercentStatus($nr); } ///////////////////////////////////////////////////////////////////////////////////// // Calculated Temperature for LM35 temp sensor from ADC result public function GetLM35Status($nr) //0...max { $temppp= $this->GetADCStatus($nr); return $this->gettemplm35($temppp,$this->VCC,$this->Calibration[$nr]); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Calculated Temperature for MCP9700 temp sensor from ADC result public function GetMCP9700Status($nr) //0...max { $temppp= $this->GetADCStatus($nr); return $this->calculate_MCP9700Eth($temppp,$this->VCC,$this->Calibration[$nr]); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Calculated Temperature for MCP9701 temp sensor from ADC result public function GetMCP9701Status($nr) //0...max { $temppp= $this->GetADCStatus($nr); return calculate_MCP9701Eth($temppp,$this->VCC,$this->Calibration[$nr]); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ADC Low Level Threshold - Preset (0..1024) public function GetAdcLStatus($nr) //0...max { $Offset=$this->TotalOffset + $this->ADCL_OFFSET_WIFI; $adcl=(($this->Bin[$Offset+($nr<<1) ]&0xff)); $adcl=$adcl<<8; $adcl|=$this->Bin[$Offset+($nr<<1)+1]&0xff; return $adcl; } /////////////////////////////////////////////////////////////////////////////////////////////////////////// // ADC High Level Threshold - Preset (0..1024) public function GetAdcHStatus($nr) //0...max { $Offset=$this->TotalOffset + $this->ADCH_OFFSET_WIFI; $adch=(($this->Bin[$Offset+($nr<<1) ]&0xff)); $adch=$adch<<8; $adch|=$this->Bin[$Offset+($nr<<1) + 1]&0xff; return $adch; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Get High Threshold for ADC calculated for MCP temp sensor public function GetTempHStatus($nr) //0...max { $adch=$this->GetAdcHStatus($nr); return $this->calculate_MCP9700Eth($adch,$this->VCC,$this->Calibration[$nr]); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Get Low Threshold for ADC calculated for MCP temp sensor public function GetTempLStatus($nr) //0...max { $adcl=$this->GetAdcLStatus($nr); return $this->calculate_MCP9700Eth($adcl,$this->VCC,$this->Calibration[$nr]); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // For debug only - manual execution (display all decoded data and store to the file public function Display() { global $EHOUSE_WIFI_MAX_ADC, $EHOUSE_WIFI_MAX_INPUTS, $EHOUSE_WIFI_MAX_OUTPUTS, $EHOUSE_WIFI_MAX_DIMMERS; ///$this->e("\r\n=========================================================================================\r\n"); if (($this->ProcessChangedOnly>0) && ($this->WasChanged===0)) {return;} //process only when data changed if (!$this->StatusReceived) {echo "\r\nNoData to display\n";return;} //status is loaded if (!$this->StatusDecoded) {$this->DecodeEhouseWiFiStatus();} //if not decoded, we do it now $resfil=$this->AdrH."_".$this->AdrL."."; //output file to store the result we add to file for WiFi //$this->e("WiFi:".$this->AdrH.".".$this->AdrL." ".date("Y:m:d H:i:s")." "); $this->e(date("Y-m-d H:i:s")."\t"); if ($this->ADCS_ENABLED) { //$size=$EHOUSE_WIFI_MAX_ADC/$this->HALF_ADC; $size=1; for ($i=0;$i<$size;$i++) { if (($this->ExtendedStatus)) { $this->e("a$i=" . $this->adc[$i].' ('.$this->PresetL[$i].','. $this->PresetH[$i].")" .""); } else { $this->e("a$i=" . $this->adc[$i]); } $this->e("=>"); for ($i=0;$i<$size;$i++) { $low=$this->calculate_MCP9700Eth($this->PresetL[$i],$this->VCC,$this->Calibration[$i]); $high=$this->calculate_MCP9700Eth($this->PresetH[$i],$this->VCC,$this->Calibration[$i]); $ranges=""; if ($this->ExtendedStatus) {$ranges=" (".$low.",".$high.")";} $this->e("t$i=" . $this->SensorTempsMCP9700[$i] .$ranges.""); } $this->e(" "); } } $size=$EHOUSE_WIFI_MAX_OUTPUTS/$this->HALF_OUTPUTS; $this->e(" Outs:");// for ($i=0;$i<$size;$i++) {$this->e(/*"o$i=" .*/ $this->out[$i] /* .","*/);} $this->e(", "); $this->e(" Inputs:"); $size=$EHOUSE_WIFI_MAX_INPUTS/$this->HALF_INPUTS; for ($i=0;$i<$size;$i++) {$this->e(/*"i$i=" .*/ $this->in[$i] /*.","*/);} $this->e(", "); if (($this->ALARM_ENABLED)) //no alarm functionality available now { //for ($i=0;$i<$size;$i++) {$this->e("A$i=" . $this->Alarm[$i]."\t");} $this->e("\r\n\r\n"); } $this->e("Dimmers:"); if ($this->DIMMERS_ENABLED) {for ($i=0;$i<$EHOUSE_WIFI_MAX_DIMMERS/$this->HALF_DIMMERS;$i++) {$this->e(/*"D$i=" .*/ $this->Dimmer[$i].",");} $this->e(" ");} /*if ($this->DMX_DALI_DIMMERS_ENABLED) //no dali/dmx functionality available now might be implemented in future revision { for ($i=0;$i<46;$i++) {$this->e("Dali$i=" . $this->DimmerDali[$i]."\t");} $this->e("\r\n\r\n"); for ($i=0;$i<32;$i++) {$this->e("DMX$i=" . $this->DimmerDMX[$i]."\t");} $this->e("\r\n\r\n"); } */ $this->e("Pgm=" . $this->CurrentProgram); $this->e(", AdcPgm=" . $this->CurrentADCProgram); //$this->e("\r\nDRVProgramNr =" . $this->CurrentSecuProgram); //$this->e("\r\nZoneNr =" . $this->CurrentZone); //$this->e("\r\nHW Outs =" . $this->HWStates); if (($this->ExtendedStatus)) { $this->e(", RSSI=" . $this->RSSI); $this->e(", QSI=" . $this->Quality); $this->e(", Connected=" . $this->Since."m"); //$this->e("\r\nExt. Status=1"); } $this->e("\r\n"); // file_put_contents("$resfil", $this->results); if (!is_dir('AI-Stat')) {mkdir ('AI-Stat' );} //$fn=$resfil.date("H_i_s"); $fn=$resfil."txt"; if (filesize("AI-Stat/".$this->AdrH."-".$this->AdrL.".txt")>100000) unlink("AI-Stat/".$this->AdrH."-".$this->AdrL.".txt"); file_put_contents("AI-Stat/".$this->AdrH."-".$this->AdrL.".txt", $this->results."",FILE_APPEND); } ////////////////////////////////////////////////////////////////////////////////////// // Decode complete eHouse WiFi status ////////////////////////////////////////////////////////////////////////////////////// public function DecodeEhouseWiFiStatus() { global $EHOUSE_WIFI_MAX_ADC, $EHOUSE_WIFI_MAX_INPUTS, $EHOUSE_WIFI_MAX_OUTPUTS, $EHOUSE_WIFI_MAX_DIMMERS; if (($this->ProcessChangedOnly>0) && ($this->WasChanged===0)) {return;} //we process only when changed if (strlen($this->TextStatus)>100) {return;} //too long for eHouse WiFi $i=0; $k=0; $ind=0; $Max_ADC = $EHOUSE_WIFI_MAX_ADC/$this->HALF_ADC; $this->size=$this->Bin[$ind++]; $this->AdrH=$this->Bin[$ind++]; $this->AdrL=$this->Bin[$ind++]; if ($this->size>22) //extended status since 2021 controllers firmware { $this->ExtendedStatus=1; $this->ADC_OFFSET_WIFI=0; $this->DIMM_OFFSET_WIFI=8; $this->OUT_OFFSET_WIFI=$this->DIMM_OFFSET_WIFI+4; $this->IN_OFFSET_WIFI=$this->OUT_OFFSET_WIFI+1; $this->OUT_PROGRAM_OFFSET_WIFI=$this->IN_OFFSET_WIFI+1; $this->MODE_OFFSET_WIFI=$this->IN_OFFSET_WIFI+1; $this->ADCPRG_OFFSET_WIFI=$this->MODE_OFFSET_WIFI+1; $this->MOD2_OFFSET_WIFI=$this->MODE_OFFSET_WIFI+1; $this->ADCL_OFFSET_WIFI=$this->MOD2_OFFSET_WIFI+1; $this->ADCH_OFFSET_WIFI=$this->ADCL_OFFSET_WIFI+8; $this->RSSI_OFFSET_WIFI=$this->ADCH_OFFSET_WIFI+8; $this->QSI_OFFSET_WIFI=$this->RSSI_OFFSET_WIFI+1; $this->SINCE_OFFSET_WIFI=$this->QSI_OFFSET_WIFI+1; } else { $this->ExtendedStatus=0; $this->ADC_OFFSET_WIFI=0; $this->DIMM_OFFSET_WIFI=8; $this->OUT_OFFSET_WIFI=$this->DIMM_OFFSET_WIFI+4; $this->IN_OFFSET_WIFI=$this->OUT_OFFSET_WIFI+1; $this->OUT_PROGRAM_OFFSET_WIFI=$this->IN_OFFSET_WIFI+1; $this->MODE_OFFSET_WIFI=$this->IN_OFFSET_WIFI+1; $this->ADCPRG_OFFSET_WIFI=$this->MODE_OFFSET_WIFI+1; $this->MOD2_OFFSET_WIFI=$this->MODE_OFFSET_WIFI+1; $this->ADCL_OFFSET_WIFI=$this->MOD2_OFFSET_WIFI+1; //we do not have this values here $this->ADCL_OFFSET_WIFI=0;//$this->$MOD2_OFFSET_WIFI+1; $this->ADCH_OFFSET_WIFI=0;//$this->$ADCL_OFFSET_WIFI+8; $this->RSSI_OFFSET_WIFI=0;//$this->$ADCH_OFFSET_WIFI+8; $this->QSI_OFFSET_WIFI=0;//$this->$RSSI_OFFSET_WIFI+1; $this->SINCE_OFFSET_WIFI=0;//$this->$QSI_OFFSET_WIFI+8; } $toind=$EHOUSE_WIFI_MAX_OUTPUTS/$this->HALF_OUTPUTS; //WiFi outputs amount for ($k=0;$k<$toind;$k++) { $this->out[$k]=$this->eH($this->TotalOffset+$this->OUT_OFFSET_WIFI,$k); } $toind=$EHOUSE_WIFI_MAX_INPUTS/$this->HALF_INPUTS; //WiFi inputs amount for ($k=0;$k<$toind;$k++) { $this->in[$k]=$this->eH($this->TotalOffset+$this->IN_OFFSET_WIFI,$k); } if ($this->ADCS_ENABLED) { $i=0; while ($i < $Max_ADC) { /* $ind=$this->TotalOffset+$this->ADC_OFFSET_WIFI; $temppp = (($this->Bin[$ind + $i * 2 ]&0xff)&0x3); $this->adc[$i] = ($temppp<<8) + $this->Bin[$ind + $i * 2 + 1 ]&0xff;*/ $temppp=$this->GetADCStatus($i); $this->adc[$i]=$temppp; $this->SensorTemps[$i] = $this->gettemplm($temppp, $this->Calibration[$i], 10, $this->VCC); $this->SensorPercents[$i] = $this->calculate_percent($temppp); $temdp=$this->SensorPercents[$i]; $this->SensorLights[$i] = round((100-$temdp) * 10) / 10; $this->SensorTempsLM35[$i]=$this->gettemplm35($temppp,$this->VCC,$this->Calibration[$i]); $this->SensorTempsMCP9700[$i]=$this->calculate_MCP9700Eth($temppp,$this->VCC,$this->Calibration[$i]); $this->SensorTempsMCP9701[$i]=$this->calculate_MCP9701Eth($temppp,$this->VCC,$this->Calibration[$i]); $this->SensorVolts[$i]=$this->calculate_voltage($temppp,$this->VCC); if (($this->ExtendedStatus)) { $ind=$this->TotalOffset + $this->ADCH_OFFSET_WIFI + ($i<<1); $adch=(($this->Bin[$ind] & 0xff)); $adch=$adch<<8; $adch|=$this->Bin[$ind + 1] & 0xff; $ind=$this->TotalOffset + $this->ADCL_OFFSET_WIFI + ($i<<1); $adcl=(($this->Bin[$ind] & 0xff));// >> 6)&0x3; $adcl=$adcl<<8; $adcl|=$this->Bin[$ind + 1] & 0xff; $this->PresetH[$i]=$adch; $this->PresetL[$i]=$adcl; } else { $this->PresetL[$i]=0; $this->PresetH[$i]=1023; } $i++; } } if ($this->DIMMERS_ENABLED) { $i=0; $ind=$this->TotalOffset + $this->DIMM_OFFSET_WIFI; while ($i < $EHOUSE_WIFI_MAX_DIMMERS/$this->HALF_DIMMERS) { $this->Dimmer[$i]=round((($this->Bin[$ind + $i]&0xff))); ////already 0..100% //$this->Dimmer[$i]=round((($this->Bin[$ind + $i]&0xff)/0xff)*100);//for 0..255 range output $i++; } } $this->CurrentProgram=$this->Bin[$this->TotalOffset+$this->OUT_PROGRAM_OFFSET_WIFI] & 0b00011111; $this->CurrentADCProgram=$this->Bin[$this->TotalOffset+$this->ADCPRG_OFFSET_WIFI] & 0b00011111; $this->CurrentZone=$this->Bin[$this->TotalOffset+$this->OUT_PROGRAM_OFFSET_WIFI]; $this->Mode=$this->Bin[$this->TotalOffset+$this->MODE_OFFSET_WIFI]>>3; $this->Mode2=$this->Bin[$this->TotalOffset+$this->MOD2_OFFSET_WIFI]>>3; $this->RSSI=$this->Bin[$this->TotalOffset+$this->RSSI_OFFSET_WIFI]; if ($this->RSSI>127) {$this->RSSI-=256;} $this->Quality=$this->Bin[$this->TotalOffset+$this->QSI_OFFSET_WIFI]; $this->Since=$this->Bin[$this->TotalOffset+$this->SINCE_OFFSET_WIFI]; $this->Since=$this->Since<<8; $this->Since+=$this->Bin[$this->TotalOffset+$this->SINCE_OFFSET_WIFI+1]; $this->StatusDecoded=1; //complete status decoded flag } //////////////////////////////////////////////////////////////////////////////// // Constructor - feeding data with hexcoded textstatus for decoder // Verify status for eHouseWiFi Controllers if valid => store to TextStatus, convert to binary array of integers function __construct($str) { if (strlen($str)>100) {return;} $siz=hexdec(substr(trim($str),0,2)); if ($siz>50) {return;} //invalid size for WiFi //we start modifying data $this->StatusDecoded=0; //reset validity flags that of status received and decoded $this->StatusReceived=0; $this->TextStatus=trim($str); if (stripos($this->TextStatus,"*")!==FALSE) //changed flag set by eHouse Pro server { $this->WasChanged=1; $this->TextStatus=substr($this->TextStatus,0,strlen($this->TextStatus)-1); } $this->hexi(); //convert Hex TextStatus to binary array of integer $this->AdrH=$this->Bin[1]; $this->AdrL=$this->Bin[2]; {$this->StatusReceived=1;} //set flag that valid eHouse.PRO status received if ($this->AutoDecode) {$this->DecodeEhouseWiFiStatus();} //if AutoDecode is enabled we process complete data } ///////////////////////////////////////////////////////////////////////////////// //send direct event to via eHousePro Server 10B hex coded (string size 20) //events syntax are: [DevAddrH,DevAddrL,CommandCode,SignalNR,State,Arg1,Arg2,Arg3,Arg4,Arg5]; //eg 00652103020000000000 // | adres 0,101 - eHouse WiFi device 192.168.0.101 // | command "set output" // | nr=4 (starts from 1) // | state=2 (toggle), no advanced arguments //Only Direct Event are performed here other are ignored public function ExecCommand($cmd) { $str=trim($cmd); if (strlen($str)===20) {echo "$str\n";} } ///////////////////////////////////////////////////////////////////////////////// //Get templm35 temperature sensor value conversion public function gettemplm35($dta,$VCC) { $temp=($dta*$VCC/(1023*10)); $temp = round($temp*10); $temp/=10; return $temp; } /////////////////////////////////////////////////////////////////////////////// public function calculate_MCP9701Eth($dta,$VCC,$Calibration) { global $MCP9701x; $tmp = ((($dta * $VCC ) / 1023))+$Calibration; //MCP9701_Offset ; //get temp in [C] $tmp=(round(($tmp/$MCP9701x)*10*1000)*1.0)/10; return $tmp; } ///////////////////////////////////////////////////////////////////////////////// //calculate voltage comparing to VCC public function calculate_voltage($dta,$VCC) { $tmp = round((($dta * $VCC ) / 1023)*100); //up ot 2 decimal fractional digits $tmp=$tmp/100000; return $tmp; } //////////////////////////////////////////////////////////////////////////////// ////Calculate Temperature for MCP9700 sensor for Ethernet eHouse controllers public function calculate_MCP9700Eth($dta,$VCC,$Calibration) { global $MCP9700x; $tmp = ((($dta * $VCC ) / 1023))+$Calibration; //get temp in [C] $tmp=(round(($tmp/$MCP9700x)*10*1000)*1.0)/10; return $tmp; } /////////////////////////////////////////////////////////////////////////////////// //calculate lm335 sensor value public function gettemplm($dta, $calibration, $k, $VCC) { $temp=($dta*$VCC/(1023*$k))+$calibration/100; return (((round($temp*10))*1.0)/10); } //////////////////////////////////////////////////////////////////////////////// // calculate percent value public function calculate_percent($dta) { $percent=(round((($dta * 10 ) / 1023)*10)); return $percent/10; //rounding to 1 digits of fractional part } //////////////////////////////////////////////////////////////////////////////// public function Hex($int) { $ad=dechex($int); while (strlen($ad)<2) {$ad='0'.$ad;} return $ad; } //////////////////////////////////////////////////////////////////////////////// // EVENT Senders //// Compose and Exec complete Direct Event (10B)=>20B str hex coded //// local adrH,adrL is added automatically as prefix //////////////////////////////////////////////////////////////////////////////// public function ExEv($cmd,$arg1=0,$arg2=0,$arg3=0,$arg4=0,$arg5=0,$arg6=0,$arg7=0) { $str=$this->Hex($this->AdrH&0xff). $this->Hex($this->AdrL&0xff). $this->Hex($cmd&0xff). $this->Hex($arg1&0xff). $this->Hex($arg2&0xff). $this->Hex($arg3&0xff). $this->Hex($arg4&0xff). $this->Hex($arg5&0xff). $this->Hex($arg6&0xff). $this->Hex($arg7&0xff); echo $str."\n"; //echo -> will be captured by eHouse.Pro if launched from it return $str; //return value } ////////////////////////////////////////////////////////////////////////////////// // Exec Output Program 0...n public function ExecProgram($nr) { $this->ExEv(2,$nr,0,0,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// //Set all dimmers states - LAN /*public function ExecRGB($nr,$R,$G,$B,$grouping,$cont) { ExEv(4,$nr,$R,$G,$B,0,0,0); }*/ //////////////////////////////////////////////////////////////////////////////////// public function ExecRGBDimmerWiFi($nr,$modedim,$valuedima,$valuedimb,$valuedimc,$valuedimd,$vgroup=0,$hgroup=0,$Rcont=0,$Gcont=0,$Bcont=0,$Wcont=0) { $RGB_DIMMER_EVENT=8; $group=0; $opts=0; if (($vgroup>0) || ($hgroup>0)) { $group=1; $opts|=0x08; } //Bit options // Continuous mode for each chanell if ($Rcont) {$opts|=0x80;} if ($Gcont) {$opts|=0x40;} if ($Bcont) {$opts|=0x20;} if ($Wcont) {$opts|=0x10;} $Radv=$Gadv=$Badv=$Wadv=0; //future advanced rgb options if ($Radv) {$opts|=0x8;} if ($Gadv) {$opts|=0x4;} if ($Badv) {$opts|=0x2;} if ($Wadv) {$opts|=0x1;} if ($group>0) {$this->ExEv($RGB_DIMMER_EVENT,$hgroup,$modedim,$valuedima,$valuedimb,$valuedimc,$vgroup,$opts);} else {$this->ExEv($RGB_DIMMER_EVENT,$nr,$modedim,$valuedima,$valuedimb,$valuedimc,$valuedimd,$opts);} } //////////////////////////////////////////////////////////////////////////////// //Run Dimmer settings public function ExecDimmerWiFi($nr,$invertdimm,$admin,$disable,$mindim,$valuedim,$modedim,$stepdim,$maxdim,$vgroup=0,$hgroup=0) { //global $NrFromOne; $DIMMER_EVENT=4; $MODIFY_LIGHT_EVENT=105; $opts=0; $group=0; //bit options if ($invertdimm) //inverted scale (100-x) {$opts|=0x40;} if ($admin) //admin option {$opts|=0x80;} if ($disable) //disable dimm events {$opts|=0x20;} if (($vgroup>0) || ($hgroup>0)) { $group=1; $opts|=0x08; } if ($modedim<5) { if ($group>0) {$this->ExEv($DIMMER_EVENT,$nr-$this->NrFromOne,$modedim,$valuedim,$stepdim,$vgroup,$hgroup,$opts);} else {$this->ExEv($DIMMER_EVENT,$nr-$this->NrFromOne,$modedim,$valuedim,$stepdim,$mindim,$maxdim,$opts);} } else { $mod=$modedim-1; $opts=0; if ($group>0) {$this->ExEv($MODIFY_LIGHT_EVENT,$nr-$this->NrFromOne,$mod,$valuedim,$stepdim,$vgroup,$hgroup,$opts|0x08);} else {$this->ExEv($MODIFY_LIGHT_EVENT,$nr-$this->NrFromOne,$mod,$valuedim,$stepdim,0,0,$opts);} } } ////////////////////////////////////////////////////////////////////////////////// //Ad-hoc ADC configuration command public function ExecADCWiFi($nr,$invertadc,$alarmadcl,$alarmadch,$alarmdelayadc,$lleveladc,$hleveladc,$adcdis,$admin) { $SETADC_EVENT=12; $opts=0; //bit options if ($invertadc) //inverted scale (100%-x) {$opts|=0x08;} if ($admin) //admin for changing settings {$opts|=0x80;} if ($alarmadcl) //enable alarm low {$opts|=0x20;} if ($alarmadch) //enable alarm high {$opts|=0x40;} if ($adcdis) //disable adc threshold events {$opts|=0x10;} $this->ExEv($SETADC_EVENT,$nr-$this->NrFromOne,$lleveladc>>8,$lleveladc&0xff,$hleveladc>>8,$hleveladc&0xff,$alarmdelayadc,$opts); } //////////////////////////////////////////////////////////////////////////////////// //run servos/drives - pair of outputs control public function ExecDriveWiFi( $nr,$admin,$stateout,$repeat,$timeonout,$timeoffout,$timedisabledrv,$disabledrv,$somfy=0,$vgroup=0,$hgroup=0) { $opts=0; $group=0; if ($admin) {$opts|=0x80;} if ($disabledrv) {$opts|=0x40;} if ($somfy) {$opts|=0x20;} if (($vgroup>0) || ($hgroup>0)) { $group=1; $opts|=0x10; $repeatimes=0; } else {$repeatimes =$repeat;} $repeatimes=$repeatimes<<3; $repeatimes|=$stateout; $opts|=$nr-$this->NrFromOne; if ($group>0) { $repeatimes&=7; $this->ExEv(100,$opts,$repeatimes,$timeonout>>8,$timeonout&0xff,$vgroup, $hgroup, $timedisabledrv); } else {$this->ExEv(100,$opts,$repeatimes,$timeonout>>8,$timeonout&0xff,$timeoffout>>8,$timeoffout&0xff,$timedisabledrv);} } ////////////////////////////////////////////////////////////////////////////////// //Setting Single Outputs public function ExecOutputWiFi($nr,$stateout,$disableout,$adminout,$repeatouts,$timeonout,$timeoffout,$vgroup,$hgroup) { $opts=0; $group=0; if ($adminout) {$opts|=0x80;} if ($disableout) {$opts|=0x40;} if (($vgroup>0) ||($hgroup>0)) {$group=1;} if ($group>0) {$repeatimes =0;} else {$repeatimes = $repeatouts;} $opts|=$stateout; if ($group>0) {$this->ExEv(0x21,$nr-$this->NrFromOne,$opts,$timeonout>>8,$timeonout&0xff,$vgroup,$hgroup,$repeatimes);} else {$this->ExEv(0x21,$nr-$this->NrFromOne,$opts,$timeonout>>8,$timeonout&0xff,$timeoffout>>8,$timeoffout&0xff,$repeatimes);} } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Set Ad-hoc input settings public function ExecInputWiFi($nr,$invin,$alarmin,$alarmdelay,$rememberstate,$disableevent) { $opts=0; if ($invin) { $opts|=0x04; } if ($alarmin) { $opts|=0x01; } if ($disableevent) { $opts|=0x02; } $this->ExEv(0x20,$nr-$this->NrFromOne,$opts,$rememberstate>>8,$rememberstate&0xff,$alarmdelay>>8,$alarmdelay&0xff,0); } //////////////////////////////////////////////////////////////////////////////// //Set ADC Low, High Threshold for regulation public function ExecADCLevels($nr,$min,$max,$admin=0,$invert=0,$alarmL=0,$alarmH=0,$disablevent=0) { $opts=0; if ($admin) { $opts|=0x80; if ($invert) {$opts|=0x08;} if ($alarmH) {$opts|=0x04;} if ($alarmL) {$opts|=0x08;} if ($disablevent) {$opts|=0x10;} } $this->ExEv(12,$nr-$this->NrFromOne,$this->Hex($min>>8),$this->Hex($min&0xff),$this->Hex($max>>8),$this->Hex($max&0xff),0,$opts); } ////////////////////////////////////////////////////////////////////////////////// //// Output Event/Command creator example - 10B converted to hex text format // Please reffer to https://www.isys.pl/download/ehouse-lan-protocol-en.pdf //Ehouse LAN controller only (limited functionality for eHouse WiFi) public function ExecOut($nr,$state=2,$time=0) { //// $state 0=OFF, 1=ON, 2=TOGGLE ////// $nr range (0..max) $nrinc=1; //for commands nr range (1...max) $ad=trim($state); //Time-out for turning-on output (for ON,Toggle state) in [s] up to 18h //Field Description Byte Location $str=$this->Hex($this->AdrH). //address H (1B) $this->Hex($this->AdrL). //Address L (2B) $this->Hex(33). //Set Output Command 0x21 (3B) $this->Hex($nr+$nrinc). //Output No. (4B) $this->Hex($state). //State (5B) $this->Hex($time&0xff). //Time Low nibble (6B) $this->Hex($time>>8). //Time High nibble (7B) $this->Hex(0). //Additions to 10B (8B) $this->Hex(0). //Additions to 10B (9B) $this->Hex(0); //Additions to 10B (10B) echo $str."\n"; return $str; } ////////////////////////////////////////////////////////////////////////////////// ///Increment/Decrement Program Outs+Dimm $dir=>1 (inc) | 2 (dec) - eHouse LAN (ERM only) public function ExecIncDecProgram($dir) { $this->ExEv(96,$dir,0,0,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// //Set ADC/Regulation program - eHouseLAN public function ExecADCProgram($nr) { $this->ExEv(97,$nr,0,0,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// //Exec Security Program (drives+secu zone) - eHouse LAN - CM/LM (ONLY) public function ExecSecuProgram($nr) { $this->ExEv(98,$nr,0,0,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// //Change security zone with delay - eHouse Lan - CM/LM Only public function ExecZoneChange($nr,$delay) { $this->ExEv(99,$nr,$delay&0xff,0,0,0,0,0); } ///////////////////////////////////////////////////////////////////////////////// // Control single Drive/Servo - eHouse LAN limited functionality for eHouse WiFi public function ExecRoller($nr,$mode) {//$mode => 0=n/a, 1=odd output, 2=even output,3=stop (both for somfy, none for other) $this->ExEv(100,$nr,$mode,0,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// // Control Multi-Drive/Servo bitwise operation for each outputs - CM/LM only public function ExecMultiRoller($arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7) { $this->ExEv(101,$arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7); } ////////////////////////////////////////////////////////////////////////////////// //Execute preprogrammed macro of events in the controller - eHouse LAN public function ExecBatch($nr,$count) { $this->ExEv(104,$nr,$count,0,0,0,0,0); } ///////////////////////////////////////////////////////////////////////////////// //$nr 0...max - eHouse LAN public function ExecDecLights($nr,$step) {global $nrdim; $this->ExEv(105,$nr+$nrdim,0,$step,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// //$nr 0...max eHouse LAN public function ExecIncLights($nr,$step) {global $nrdim; $this->ExEv(105,$nr+$nrdim,1,$step,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// // eHouse LAN public function ExecStopLights($nr,$step) {global $nrdim; $this->ExEv(105,$nr+$nrdim,2,$step,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// // eHouse LAN public function ExecSetLight($nr,$value) {global $nrdim; $this->ExEv(105,$nr+$nrdim,3,$value,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// // eHouse LAN public function ExecToggleLights($nr,$step) { global $nrdim; $this->ExEv(105,$nr+$nrdim,4,$step,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// // eHouse LAN public function ExecDecOnceLights($nr,$step) { global $nrdim; $this->ExEv(105,$nr+$nrdim,5,$step,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// // eHouse LAN public function ExecIncOnceLights($nr,$step) { global $nrdim; $this->ExEv(105,$nr+$nrdim,6,$step,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// //$nr 0...max //public function ModifyLights($nr,$cmd,$step) //{global $nrdim; //ExEv(105,$nr+$nrdim,$cmd,$step,0,0,0,0); //} ////////////////////////////////////////////////////////////////////////////////// // eHouse LAN public function ExecSetSingleLight($nr,$level) {global $nrdim; $this->ExEv(106,$nr+$nrdim,$level,0,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// // eHouse LAN - ERM public function ExecDecDMX($nr,$step=1) { $this->ExEv(108,$nr,0,$step,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// // eHouse LAN - ERM public function ExecIncDMX($nr,$step=1) { $this->ExEv(108,$nr,1,$step,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// // eHouse LAN - ERM public function ExecStopDMX($nr,$step=5) { $this->ExEv(108,$nr,2,$step,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// // eHouse LAN - ERM public function ExecSetDMX($nr,$step) { $this->ExEv(108,$nr,3,$step,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// //eHouse LAN - ERM public function ExecSetRGBDMX($nr,$R,$G,$B) { $this->ExEv(109,$nr,$R,$G,$B,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// //eHouse LAN - ERM public function ExecSendDaliCMD($msb,$lsb) { $this->ExEv(242,$msb,$lsb,0,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// //eHouse LAN - ERM public function ExecSetDaliLight($nr,$mode,$step) {// mode 0 dec, 1 inc, 2 stop, 3 stop $this->ExEv(243,$nr,$mode,$step,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// //eHouse LAN - ERM public function ExecSetDaliScene($nr) { $this->ExEv(246,$nr,0,0,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// // eHouse LAN - ERM public function ExecSetDMXScene($nr) { $this->ExEv(247,$nr,0,0,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// //add values to the status - eHouse LAN - ERM public function ExecSubmitToStatus($arg1=0,$arg2=0,$arg3=0,$arg4=0,$arg5=0,$arg6=0,$arg7=0) { $this->ExEv(248,$arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7); } ////////////////////////////////////////////////////////////////////////////////// //Send Data to the Log via tcp/ip - eHouse LAN public function ExecSendTCPLog($arg1=0,$arg2=0,$arg3=0,$arg4=0,$arg5=0,$arg6=0,$arg7=0) { $this->ExEv(249,$arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7); } ///////////////////////////////////////////////////////////////////////////////////// //Send Data via UDP public function ExecSendUDP($arg1=0,$arg2=0,$arg3=0,$arg4=0,$arg5=0,$arg6=0,$arg7=0) { $this->ExEv(250,$arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7); } ////////////////////////////////////////////////////////////////////////////////// //Send Data to the Log - eHouse LAN only public function ExecSendLog($arg1=0,$arg2=0,$arg3=0,$arg4=0,$arg5=0,$arg6=0,$arg7=0) { $this->ExEv(251,$arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7); } ////////////////////////////////////////////////////////////////////////////////// //Send Infrared remote contoller codes aliases stored in eeprom locations public function ExecSendIRAlias($cmdadr1=0,$cmdadr2=0,$cmdadr3=0,$cmdadr4=0) { $this->ExEv(39,$cmdadr1,$cmdadr2,$cmdadr3,$cmdadr4,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// //Send Infrared remote contoller code public function ExecSendIR($irmode,$arg1=0,$arg2=0,$arg3=0,$arg4=0,$arg5=0,$arg6=0) { $this->ExEv(252,$irmode,$arg1,$arg2,$arg3,$arg4,$arg5,$arg6); } ////////////////////////////////////////////////////////////////////////////////// //Send IR Scan Command - eHouse LAN public function ExecScanIR() { $this->ExEv(253,0,0,0,0,0,0,0); } ////////////////////////////////////////////////////////////////////////////////// //Restart eHouse Wifi controller public function ExecRestart() { $this->ExEv(254,0x55,0,0,0,0,0,0); } } //class //examples //creator and feeding with status invalid are ignored not writing data to the Status locations /* Test statuses for wifi $eHouseWiFi=new eHouseWiFiC("2A00657303441FEC013D03315A145000010A000000000000000000000000000000000000C100013D048E"); $eHouseWiFi=new eHouseWiFiC("2A006673037621D5016E03625A145000050A000000000000000000000000000000000000C60001E205BB"); $eHouseWiFi=new eHouseWiFiC("16006773034B2030014403380A1464000A0A000002A2"); $eHouseWiFi=new eHouseWiFiC("2A006873033A1F8A0133032700000000000A000000000000000000000000000000000000C200000F0321"); $eHouseWiFi=new eHouseWiFiC("2A00697303441FEC013D03315A145000010A000000000000000000000000000000000000C100013D048E"); $eHouseWiFi=new eHouseWiFiC("2A006a7303441FEC013D03315A145000010A000000000000000000000000000000000000C100013D048E");*/ //$eHouseWiFi=new eHouseWiFiC("2A006b73037621D5016E03625A145000050A000000000000000000000000000000000000C60001E205BB*"); //echo $eHouseWiFi->GetADCStatus(0)."\r\n"; //$eHouseWiFi->Display(); //$eHouseLan=new eHouseLanC("B400C97314D70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049523030303230300017001800190301001800190018001900E103FF001A03FF03FF03FF03FF03FF4501000080000000000000000000000000000000FF0F1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080E39"); //$eHouseLan=new eHouseLanC("B400C97314D700000000000000000000000000000000000000FF00FFCACD00FFCACDC7CAD3D4CACDC7CAFAF2C7CA00FF00FF00FF00FF00FF00000000000000004952303030323030C017C0180019C301001800190019001900E1F3FF001AC3FFC3FFC3FFC3FFC3FF4501003C80000000000000000000000000000000FF0F1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000082A6B"); //$eHouseLan=new eHouseLanC("B400C97314D700000000000000000000000000000000000000FF00FFE3E600FFCACDE3E6E6E9D3D6E0E3F9F1E0E300FF00FF00FF00FF00FF00000000000000004952303030323030C017C017001AC300001900180018001900E0F3FF001AC3FFC3FFC3FFC3FFC3FF450100BC80000000000000000000000000000000FF0F1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000082BED"); //$out5=$eHouseLan->GetOutStatus(4); //Individual signal decoding (binary output nr 5 (starts from 0) fast - without complete status decoding //$in15=$eHouseLan->GetInStatus(14); //Individual signal decoding (binary input nr 15 (starts from 0) fast - without complete status decoding // We can disable processing of subsystems we don't use for bigger speed and lower processor utilization /* $ALARM_ENABLED=0; //local security system (Horn, Silent, Warning, EarlyWarning, Monitoring, Alarm Flags) $DIMMERS_ENABLED=0; //External Dimmers $ADCS_ENABLED=0; //1-Wire temperature sensors or other linked //if we have smaller amount of inputs/outputs we can limit processing $HALF_ADC=1; //if 1 all inputs taken if 2 => half (EHOUSE_WIFI_MAX_ADC/HALF_ADC) $HALF_INPUTS=2; //if 1 all inputs taken if 2 => half (EHOUSE_WIFI_MAX_INPUTS/HALF_INPUTS) $HALF_OUTPUTS=2; //if 1 all inputs taken if 2 => half (EHOUSE_WIFI_MAX_OUTPUTS/HALF_OUTPUTS) $HALF_DIMMERS=1; //if 1 all dimmers taken if 2 => half (EHOUSE_WIFI_MAX_DIMMERS/HALF_DIMMERS) */ //////$eHouseWiFi->DecodeEhouseWiFiStatus(); //Full status decoding - no results displays in case of valid status //$eHouseWiFi->Display(); //debug only information - fully decoded status written on the screen and write to the file /*echo "\r\nExamples/Tests without full data processing \r\n"; echo "ADC: MCP9700:".$eHouseWiFi->GetMCP9700Status(0); //0...max echo "\r\nTemp H Level:".$eHouseWiFi->GetTempHStatus(0); //0...max echo "\r\nTemp L Level:".$eHouseWiFi->GetTempLStatus(0); //0...max echo "\r\nADC:".$eHouseWiFi->GetADCStatus(0); //0...max echo "\r\nADC H Level:".$eHouseWiFi->GetAdcHStatus(0); //0...max echo "\r\nADC L Level:".$eHouseWiFi->GetAdcLStatus(0); //0...max echo "\r\n"; echo "\r\nOuts:".$eHouseWiFi->GetOutStatus(0).",".$eHouseWiFi->GetOutStatus(1).",".$eHouseWiFi->GetOutStatus(2).",".$eHouseWiFi->GetOutStatus(3); echo "\r\nInputs:".$eHouseWiFi->GetInStatus(0).",".$eHouseWiFi->GetInStatus(1).",".$eHouseWiFi->GetInStatus(2).",".$eHouseWiFi->GetInStatus(3); echo "\r\nDimmer:".$eHouseWiFi->GetDimmerStatus(0).",".$eHouseWiFi->GetDimmerStatus(1).",".$eHouseWiFi->GetDimmerStatus(2).",".$eHouseWiFi->GetDimmerStatus(3); echo "\r\nRSSI:".$eHouseWiFi->GetRSSIStatus(); echo "\r\nActive:".$eHouseWiFi->GetActiveTimeStatus(); //echo $eHouseWiFi->GetADCStatus(0); //0...max //echo "\r\n"; //echo $eHouseWiFi->GetADCStatus(2); //0...max echo "\r\n";*/ /*Just for local tests and evaluation $eHouseWiFi=new eHouseWiFiC("2A006b73037621D5016E03625A145000050A000000000000000000000000000000000000C60001E205BB"); $mode=1;$level=100;$delay=1000;$nr=1;$step=1;$R=100;$G=30;$B=20;$time=100;$state=2;$dir=1;$arg1=$arg2=$arg3=$arg4=$arg5=$arg6=$arg7=0x55;$irmode=13; $vgroup=0;$hgroup=0;$Rcont=0;$Gcont=0;$Bcont=0;$Wcont=0;$min=100;$max=800;$invin=0;$alarmin=0;$alarmdelay=0;$rememberstate=10;$disableevent=0; $stateout=1;$repeat=2;$timeonout=10;$timeoffout=5;$timedisabledrv=3;$disabledrv=1;$somfy=1; $modedim=1;$valuedima=10;$valuedimb=20;$valuedimc=30;$valuedimd=10;$rgbwdimm=1; $invertdimm=0;$disable=1;$mindim=0;$valuedim=90;$stepdim=10;$maxdim=100; $invertadc=0;$alarmadcl=1;$alarmadch=1;$alarmdelayadc=10;$lleveladc=100;$hleveladc=400;$adcdis=0; $admin=1;$stateout=2;$disableout=0;$adminout=1;$repeatouts=2;$timeonout=10;$timeoffout20;$count=3;$value=99;$msb=10;$lsb=3; $eHouseWiFi->ExecADCWiFi($nr,$invertadc,$alarmadcl,$alarmadch,$alarmdelayadc,$lleveladc,$hleveladc,$adcdis,$admin); $eHouseWiFi->ExecDriveWiFi( $nr,$admin,$stateout,$repeat,$timeonout,$timeoffout,$timedisabledrv,$disabledrv,$somfy,$vgroup,$hgroup); $eHouseWiFi->ExecOutputWiFi($nr,$stateout,$disableout,$adminout,$repeatouts,$timeonout,$timeoffout,$vgroup,$hgroup); $eHouseWiFi->ExecOutputWiFi($nr,$stateout,$disableout,$adminout,$repeatouts,$timeonout,$timeoffout,$vgroup,$hgroup); $eHouseWiFi->ExecProgram($nr); //exec program out+dim $eHouseWiFi->ExEv(0x21); //exec all events $eHouseWiFi->ExecProgram($nr);// exec out+dimm program $eHouseWiFi->ExecADCLevels($nr,$min,$max);// set adc levels $eHouseWiFi->ExecOut($nr,$state,$time);// set output $eHouseWiFi->ExecIncDecProgram($dir);// inc/dec program $eHouseWiFi->ExecADCProgram($nr);// set adc program $eHouseWiFi->ExecSecuProgram($nr);// set rollers programs $eHouseWiFi->ExecZoneChange($nr,$delay);// set security zone $eHouseWiFi->ExecRoller($nr,$mode);// set single roller/drive/servo $eHouseWiFi->ExecMultiRoller($arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7);// set multiple rollers $eHouseWiFi->ExecBatch($nr,$count);// exec batch commands $eHouseWiFi->ExecDecLights($nr,$step);// decrement dimm light $eHouseWiFi->ExecIncLights($nr,$step);// increment dimm light $eHouseWiFi->ExecStopLights($nr,$step);// stop dimm light $eHouseWiFi->ExecSetLight($nr,$value);// set light $eHouseWiFi->ExecToggleLights($nr,$step);// stop if moving else oposite direction $eHouseWiFi->ExecDecOnceLights($nr,$step);// decrement one step $eHouseWiFi->ExecIncOnceLights($nr,$step);// increment one step $eHouseWiFi->ExecSetSingleLight($nr,$level);// set dimmer light $eHouseWiFi->ExecDecDMX($nr,$step);// decrement dmx light $eHouseWiFi->ExecIncDMX($nr,$step);// increment dmx light $eHouseWiFi->ExecStopDMX($nr,$step);// stop dmx light $eHouseWiFi->ExecSetDMX($nr,$step);// set dmx light $eHouseWiFi->ExecSetRGBDMX($nr,$R,$G,$B);// set rgb dmx light $eHouseWiFi->ExecSendDaliCMD($msb,$lsb);// send dali command $eHouseWiFi->ExecSetDaliLight($nr,$mode,$step);// set dali light $eHouseWiFi->ExecSetDaliScene($nr);// set dali scene $eHouseWiFi->ExecSetDMXScene($nr);// set dmx scene $eHouseWiFi->ExecSubmitToStatus($arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7); //submit data to the status $eHouseWiFi->ExecSendTCPLog($arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7); //Send Data to the Log via tcp/ip $eHouseWiFi->ExecSendUDP($arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7); //send data via udp $eHouseWiFi->ExecSendLog($arg1,$arg2,$arg3,$arg4,$arg5,$arg6,$arg7); //Send Data to the Log $eHouseWiFi->ExecSendIR($irmode,$arg1,$arg2,$arg3,$arg4,$arg5,$arg6); //Send Infrared remote contoller code $eHouseWiFi->ExecScanIR(); //Send IR Scan Command $eHouseWiFi->ExecRestart(); //Send Data to the Log $eHouseWiFi->ExecSendIRAlias($cmdadr1=0,$cmdadr2=0,$cmdadr3=0,$cmdadr4=0); $eHouseWiFi->ExecInputWiFi($nr,$invin,$alarmin,$alarmdelay,$rememberstate,$disableevent); $eHouseWiFi->ExecRGBDimmerWiFi($nr,$modedim,$valuedima,$valuedimb,$valuedimc,$valuedimd,$vgroup,$hgroup,$Rcont,$Gcont,$Bcont,$Wcont); $eHouseWiFi->ExecDimmerWiFi($nr,$invertdimm,$admin,$disable,$mindim,$valuedim,$modedim,$stepdim,$maxdim,$vgroup,$hgroup); $eHouseWiFi->ExecADCWiFi($nr,$invertadc,$alarmadcl,$alarmadch,$alarmdelayadc,$lleveladc,$hleveladc,$adcdis,$admin); $eHouseWiFi->ExecDriveWiFi( $nr,$admin,$stateout,$repeat,$timeonout,$timeoffout,$timedisabledrv,$disabledrv,$somfy,$vgroup,$hgroup); $eHouseWiFi->ExecOutputWiFi($nr,$stateout,$disableout,$adminout,$repeatouts,$timeonout,$timeoffout,$vgroup,$hgroup); $eHouseWiFi->ExecInputWiFi($nr,$invin,$alarmin,$alarmdelay,$rememberstate,$disableevent); $eHouseWiFi->ExecADCLevels($nr,$min,$max,$admin=0,$invert=0,$alarmL=0,$alarmH=0,$disablevent=0); $eHouseWiFi->ExecOut($nr,$state,$time); */ ?>