'"toggle":{"onoff": 1,"channel": "%d"}', //FBA 'CMD_ON' => '"togglex":{"onoff": 1,"channel": "%d"}', 'CMD_OFF' => '"toggle":{"onoff": 0,"channel": "%d"}', //FBA 'CMD_OFF' => '"togglex":{"onoff": 0,"channel": "%d"}', 'CMD_OPEN' => '"state":{"open": 1,"channel": "%d", "uuid":"%s"}', 'CMD_CLOSE' => '"state":{"open": 0,"channel": "%d", "uuid":"%s"}', 'CMD_ONLED' => '"DNDMode":{"mode": 0}', 'CMD_OFFLED' => '"DNDMode":{"mode": 1}', 'CMD_ON_HUB' => '"togglex":[{"onoff": 1,"channel": "%d","id":"%s"}]', 'CMD_OFF_HUB' => '"togglex":[{"onoff": 0,"channel": "%d","id":"%s"}]', 'CMD_GETBAT_HUB' => '"battery": [{"id":"%s"}]', 'CMD_GETTEMP_HUB' => '"temperature":[{"id":"%s"}]', 'CMD_MODE_HUB' => '"mode": [{"state": %d,"id":"%s"}]', 'CMD_SETTEMP_TARG_HUB' => '"temperature": [{"custom": %d,"id":"%s"}]', 'CMD_SETTEMP_VAC_HUB' => '"temperature": [{"away": %d,"id":"%s"}]', 'CMD_SETTEMP_COMF_HUB' => '"temperature": [{"comfort": %d,"id":"%s"}]', 'CMD_SETTEMP_ECO_HUB' => '"temperature": [{"economy": %d,"id":"%s"}]', 'CMD_GETSENSORS_HUB' => '"all": []', 'CMD_POSITION' => '"position": {"position":%d, "channel":%d}', ); public function SetGroup($group=1) { if ($group<0) $group=0; $this->_ActiveGroup = $group; } public function GetGroup() { return $this->_ActiveGroup; } public function call(){ echo __METHOD__; } public function __construct($Params) { $myRet = new wifilightV2c; $this->_return = $myRet->_return_WFL; $this->_return['Type'] = true; $this->_log = $myRet->_log; $host = $Params['host']; $wait = $Params['wait']; $repeat = $Params['repeat']; $increm = $Params['increm']; $LocalKey = $Params['LocalKey']; $ID = $Params['ID']; $timestamp = $Params['timestamp']; $this->_host = $host; $this->_port = ""; $this->_devId = $ID; $this->_LocalKey =$LocalKey; $this->_LocalId = $Params['subId']; $this->_timestamp = $timestamp; if ($wait < 0) $wait = 0; if ($wait > 100) $wait = 100; $this->_wait = $wait*1000; if ($repeat<1) $repeat =1; if ($repeat>5) $repeat =5; $this->_repeat = $repeat; if ($increm<1) $increm =1; if ($increm>25) $increm =25; $this->_increm = $increm; } public function send($cmd,$path,$namespace,$type,$method) { $url="http://".$this->_host.$path; $strLog = " "; $strLog = $strLog.'Cmd : '.$cmd ; $strLog = $strLog.' - url : '.$url ; $strLog = $strLog.' - type : '.$type; try { $headers =array( 'Content-Type' => 'application/json' ); $body='{"header": {"from": "'.$url.'","messageId": "'.$this->_devId.'","method": "'.$method.'","namespace": "'.$namespace.'","payloadVersion": 1,"sign": "'.$this->_LocalKey.'","timestamp": '.$this->_timestamp.',"triggerSrc": "AndroidLocal"},"payload": {'.$cmd.'}}'; $strLog = $strLog.' - body : '.$body; $strLog = $strLog.' - method: '.$method; $client = new GuzzleHttp\Client(array( 'request.options' => array ( 'timeout' => 1, 'connect_timeout' => 1 ) )); if ($type == 'PUT') $response = $client->put($url, [ 'body' => $body, 'headers' => [ 'Content-Type' => 'application/json', ], 'timeout' => 1 ]); if ($type == 'POST') $response = $client->post($url,[ 'body' => $body, 'headers' => [ 'Content-Type' => 'application/json', ], 'timeout' => 1 ]); if ($type == 'GET') $response = $client->get($url, [ 'headers' => [ 'Content-Type' => 'application/json', ], 'timeout' => 1 ]); $body = $response->getBody(); $strLog = $strLog.' - Status:'. (string) $response->getStatusCode(); if ($response->getStatusCode() == 204) { $strLog = $strLog.' - No response'; log::add($this->_log,'debug',$strLog); return NOSTATE; } $str=""; for($i=0;$i31 && ord($caractere)<127 && ord($caractere)!= 39 && ord($caractere)!= 92 && ord($caractere)!=96) $str=$str.$caractere; else $str=$str."[".ord($caractere)."]"; } log::add($this->_log,'debug',$strLog); $json_decoded_data = json_decode($body, true); log::add($this->_log,'debug'," Receive:".$str); return $json_decoded_data; } catch (Exception $e) { $strLog = $strLog.' - Exception:'.$e->getMessage(); $strLog = $strLog.' - No Meross device @'.$url; log::add($this->_log,'debug',$strLog); } return NOTCONNECTED; } public function getStatus() { $string = ''; $ret = $this->send($string,"/config",'Appliance.System.All','POST','GET'); return $ret; } public function getLedStatus() { $string = ''; $ret = $this->send($string,"/config",'Appliance.System.DNDMode','POST','GET'); return $ret; } public function getPosition() { $string = ''; $ret = $this->send($string,"/config",'Appliance.RollerShutter.Position','POST','GET'); // ob_start(); // var_dump($ret); // $res = ob_get_clean(); // log::add("wifilightV2",'debug'," ret:$res"); return $ret; } public function getPowstatus() { $string = ''; $ret = $this->send($string,"/config",'Appliance.Control.Electricity','POST','GET'); return $ret; } public function getTempHub() { $id = $this->_LocalId; $string = sprintf($this->_commandCodes['CMD_GETTEMP_HUB'],$id); $ret = $this->send($string,"/config",'Appliance.Hub.Mts100.Temperature','POST','GET'); return $ret; } public function getBatHub() { $id = $this->_LocalId; $string = sprintf($this->_commandCodes['CMD_GETBAT_HUB'],$id); $ret = $this->send($string,"/config",'Appliance.Hub.Battery','POST','GET'); return $ret; } public function getTempHumHub() { $id = $this->_LocalId; $string = sprintf($this->_commandCodes['CMD_GETSENSORS_HUB'],$id); $ret = $this->send($string,"/config",'Appliance.Hub.Sensor.All','POST','GET'); return $ret; } public function retStatus($OutStrIn="",$channel=1) { $strLog = ' Meross State:' ; if ($this->_tempHub==true){ if ($OutStrIn == "") $OutStr = $this->getStatus(); else $OutStr = $OutStrIn; $chan = -2; foreach ($OutStr["payload"]["all"]["digest"]["hub"]["subdevice"] as $id => $value) { if ($value["id"] == $this->_LocalId) { $chan = $id; $strLog = $strLog." Hubchan:$id localId:".$value["id"]; break; } } if ($chan == -2) { log::add("wifilightV2",'debug'," localId not found exit"); return BADRESPONSE; } if( isset($OutStr["payload"]["all"]["digest"]["hub"]["subdevice"][$chan]['onoff'])==true ) { if ($OutStr["payload"]["all"]["digest"]["hub"]["subdevice"][$chan]['onoff'] == 1){ $strLog = $strLog.' ON' ; $this->_return['On'] = 1; } else { $strLog = $strLog.' OFF'; $this->_return['On'] = 0; } } else log::add("wifilightV2",'debug'," ON not set-channel:".$chan); if( isset($OutStr["payload"]["all"]["digest"]["hub"]["subdevice"][$chan]["mts100v3"]["mode"])==true ) { $strLog = $strLog.' Mode:'.$OutStr["payload"]["all"]["digest"]["hub"]["subdevice"][$chan]["mts100v3"]["mode"]+1; $this->_return['DiscoNum'] = $OutStr["payload"]["all"]["digest"]["hub"]["subdevice"][$chan]["mts100v3"]["mode"]+1; } else log::add("wifilightV2",'debug'," ON HUB not set-channel:".$chan); } $strLog = $strLog." Chan:$channel"; if ($this->_on === true) { if ($OutStrIn == "") $OutStr = $this->getStatus(); else $OutStr = $OutStrIn; //$OutStr = json_decode('{"header":{"messageId":"db3d461848b613c96a1358f54aab83bb","namespace":"Appliance.System.All","method":"GETACK","payloadVersion":1,"from":"/appliance/1812271310249329088834298f19fc26/publish","timestamp":1610833884,"timestampMs":958,"sign":"0ab01850ad18477bf76e15eb033b307f"},"payload":{"all":{"system":{"hardware":{"type":"mss425f","subType":"us","version":"2.0.0","chipType":"mt7682","uuid":"1812271310249329088834298f19fc26","macAddress":"34:29:8f:19:fc:26"},"firmware":{"version":"2.1.8","compileTime":"2019/11/27 15:15:01 GMT +08:00","wifiMac":"b0:be:76:8e:4f:ce","innerIp":"192.168.0.23","server":"mqtt.meross.com","port":443,"userId":278350},"time":{"timestamp":1610833884,"timezone":"Europe/Paris","timeRule":[[1585443600,7200,1],[1603587600,3600,0],[1616893200,7200,1],[1635642000,3600,0],[1648342800,7200,1],[1667091600,3600,0],[1679792400,7200,1],[1698541200,3600,0],[1711846800,7200,1],[1729990800,3600,0],[1743296400,7200,1],[1761440400,3600,0],[1774746000,7200,1],[1792890000,3600,0],[1806195600,7200,1],[1824944400,3600,0],[1837645200,7200,1],[1856394000,3600,0],[1869094800,7200,1],[1887843600,3600,0]]},"online":{"status":1}},"digest":{"togglex":[{"channel":0,"onoff":1,"lmTime":1610824081},{"channel":1,"onoff":0,"lmTime":1610832512},{"channel":2,"onoff":0,"lmTime":1610832512},{"channel":3,"onoff":0,"lmTime":1610832512},{"channel":4,"onoff":0,"lmTime":1610832512},{"channel":5,"onoff":1,"lmTime":1610829592}],"triggerx":[],"timerx":[]}}}}',true); $chan = $channel; //FBA if (isset($OutStr['payload']['all']['digest']['togglex'][$chan]['onoff'])==true ) { if (isset($OutStr['payload']['all']['digest']['toggle'][$chan]['onoff'])==true ) { //FBA if ($OutStr['payload']['all']['digest']['togglex'][$chan]['onoff'] == 1){ if ($OutStr['payload']['all']['digest']['toggle'][$chan]['onoff'] == 1){ $strLog = $strLog.' ON' ; $this->_return['On'] = 1; } else { $strLog = $strLog.' OFF'; $this->_return['On'] = 0; } } } if ($this->_onZero === true) { if ($OutStrIn == "") $OutStr = $this->getStatus(); else $OutStr = $OutStrIn; //$OutStr = json_decode('{"header":{"messageId":"db3d461848b613c96a1358f54aab83bb","namespace":"Appliance.System.All","method":"GETACK","payloadVersion":1,"from":"/appliance/1812271310249329088834298f19fc26/publish","timestamp":1610833884,"timestampMs":958,"sign":"0ab01850ad18477bf76e15eb033b307f"},"payload":{"all":{"system":{"hardware":{"type":"mss425f","subType":"us","version":"2.0.0","chipType":"mt7682","uuid":"1812271310249329088834298f19fc26","macAddress":"34:29:8f:19:fc:26"},"firmware":{"version":"2.1.8","compileTime":"2019/11/27 15:15:01 GMT +08:00","wifiMac":"b0:be:76:8e:4f:ce","innerIp":"192.168.0.23","server":"mqtt.meross.com","port":443,"userId":278350},"time":{"timestamp":1610833884,"timezone":"Europe/Paris","timeRule":[[1585443600,7200,1],[1603587600,3600,0],[1616893200,7200,1],[1635642000,3600,0],[1648342800,7200,1],[1667091600,3600,0],[1679792400,7200,1],[1698541200,3600,0],[1711846800,7200,1],[1729990800,3600,0],[1743296400,7200,1],[1761440400,3600,0],[1774746000,7200,1],[1792890000,3600,0],[1806195600,7200,1],[1824944400,3600,0],[1837645200,7200,1],[1856394000,3600,0],[1869094800,7200,1],[1887843600,3600,0]]},"online":{"status":1}},"digest":{"togglex":[{"channel":0,"onoff":1,"lmTime":1610824081},{"channel":1,"onoff":0,"lmTime":1610832512},{"channel":2,"onoff":0,"lmTime":1610832512},{"channel":3,"onoff":0,"lmTime":1610832512},{"channel":4,"onoff":0,"lmTime":1610832512},{"channel":5,"onoff":1,"lmTime":1610829592}],"triggerx":[],"timerx":[]}}}}',true); if (isset($OutStr['payload']['all']['digest']['toggle'][0]['onoff'])==true ) { //FBA if (isset($OutStr['payload']['all']['digest']['togglex'][0]['onoff'])==true ) { if ($OutStr['payload']['all']['digest']['toggle'][0]['onoff'] == 1){ //FBA if ($OutStr['payload']['all']['digest']['togglex'][0]['onoff'] == 1){ $strLog = $strLog.' ON1' ; $this->_return['On'] = 1; } else { $strLog = $strLog.' OFF1'; $this->_return['On'] = 0; } } } if ($this->_led === true) { if ($OutStrIn == "") $OutStr = $this->getLedStatus(); else $OutStr = $OutStrIn; //$OutStr = json_decode('{"header":{"messageId":"db3d461848b613c96a1358f54aab83bb","namespace":"Appliance.System.DNDMode","method":"GETACK","payloadVersion":1,"from":"/appliance/1812271310249329088834298f19fc26/publish","timestamp":1610833884,"timestampMs":998,"sign":"0ab01850ad18477bf76e15eb033b307f"},"payload":{"DNDMode":{"mode":1}}}',true); if( isset($OutStr['payload']['DNDMode']['mode'])==true ) { if ($OutStr['payload']['DNDMode']['mode'] == 0){ $strLog = $strLog.' LedON' ; $this->_return['Led'] = 1; } else { $strLog = $strLog.' LedOFF' ; $this->_return['Led'] = 0; } } else log::add("wifilightV2",'debug'," led not set"); } if ($this->_power === true) { if ($OutStrIn == "") $OutStr = $this->getPowStatus(); else $OutStr = $OutStrIn; if( isset($OutStr['payload']['electricity'])==true ) { $strLog = $strLog.' Volt:'.$OutStr['payload']['electricity']['voltage']/10 ; $this->_return['Power'] = $OutStr['payload']['electricity']['power']/1000; $this->_return['Voltage'] = $OutStr['payload']['electricity']['voltage']/10; $this->_return['Current'] = $OutStr['payload']['electricity']['current']/1000; } else log::add("wifilightV2",'debug'," Power not set"); } if ($this->_position === true) { if ($OutStrIn == "") $OutStr = $this->getPosition(); else $OutStr = $OutStrIn; if( isset($OutStr['payload']['position'][0])==true ) { $strLog = $strLog.' position:'.$OutStr['payload']['position'][0]['position']; $this->_return['Position'] = $OutStr['payload']['position'][0]['position']; } else log::add("wifilightV2",'debug'," Position not set"); } if ($this->_tempHub === true) { if ($OutStrIn == "") $OutStr = $this->getTempHub(); else $OutStr = $OutStrIn; //$OutStr = json_decode('{"header":{"messageId":"db3d461848b613c96a1358f54aab83bb","namespace":"Appliance.Hub.Mts100.Temperature","method":"GETACK","payloadVersion":1,"from":"/appliance/1911087675507726280348e1e911485e/publish","timestamp":1610833885,"timestampMs":963,"sign":"95dac3186fc23b1907ceab09ed7d5f7b"},"payload":{"temperature":[{"id":"01008B7F","room":195,"currentSet":80,"custom":200,"comfort":280,"economy":80,"max":350,"min":50,"heating":0,"away":80,"openWindow":0}]}}',true); if( isset($OutStr['payload']['temperature'][0]['room'])==true ) { $strLog = $strLog.' temp:'.$OutStr['payload']['temperature'][0]['room']/10; $this->_return['ValTemp'] = $OutStr['payload']['temperature'][0]['room']/10; } else log::add("wifilightV2",'debug'," Temp not set"); if( isset($OutStr['payload']['temperature'][0]['custom'])==true ) { $strLog = $strLog.' tempCons:'.$OutStr['payload']['temperature'][0]['custom']/10 ; $this->_return['ConsTemp'] = $OutStr['payload']['temperature'][0]['custom']/10; } else log::add("wifilightV2",'debug'," Custom not set"); if( isset($OutStr['payload']['temperature'][0]['away'])==true ) { $strLog = $strLog.' tempCust:'.$OutStr['payload']['temperature'][0]['away']/10 ; $this->_return['ConsTempVac'] = $OutStr['payload']['temperature'][0]['away']/10; } else log::add("wifilightV2",'debug'," Vac not set"); if( isset($OutStr['payload']['temperature'][0]['comfort'])==true ) { $strLog = $strLog.' tempVac:'.$OutStr['payload']['temperature'][0]['comfort']/10 ; $this->_return['ConsTempComf'] = $OutStr['payload']['temperature'][0]['comfort']/10; } else log::add("wifilightV2",'debug'," Comf not set"); if( isset($OutStr['payload']['temperature'][0]['economy'])==true ) { $strLog = $strLog.' tempEco:'.$OutStr['payload']['temperature'][0]['economy']/10 ; $this->_return['ConsTempEco'] = $OutStr['payload']['temperature'][0]['economy']/10; } else log::add("wifilightV2",'debug'," economy not set"); if( isset($OutStr['payload']['temperature'][0]['currentSet'])==true ) { $strLog = $strLog.' ConsTempCurrent:'.$OutStr['payload']['temperature'][0]['currentSet']/10 ; $this->_return['ConsTempCurrent'] = $OutStr['payload']['temperature'][0]['currentSet']/10; } else log::add("wifilightV2",'debug'," currentSet not set"); if( isset($OutStr['payload']['temperature'][0]['openWindow'])==true ) { $strLog = $strLog.' Window:'.$OutStr['payload']['temperature'][0]['openWindow']; $this->_return['PIR'] = $OutStr['payload']['temperature'][0]['openWindow']; } else log::add("wifilightV2",'debug'," PIRWindow not set"); if( isset($OutStr['payload']['temperature'][0]['heating'])==true ) { $strLog = $strLog.' Heat:'.$OutStr['payload']['temperature'][0]['heating']; $this->_return['Open'] = $OutStr['payload']['temperature'][0]['heating']; } else log::add("wifilightV2",'debug'," Heating not set"); if ($OutStrIn == "") { $OutStr = $this->getBatHub(); //$OutStr= json_decode('{"header":{"messageId":"db3d461848b613c96a1358f54aab83bb","namespace":"Appliance.Hub.Battery","method":"GETACK","payloadVersion":1,"from":"/appliance/1911087675507726280348e1e911485e/publish","timestamp":1610833885,"timestampMs":987,"sign":"95dac3186fc23b1907ceab09ed7d5f7b"},"payload":{"battery":[{"id":"01008B7F","value":50}]}}',true); } else $OutStr = $OutStrIn; if( isset($OutStr['payload']['battery'][0]['value'])==true ) { $strLog = $strLog.' bat:'.$OutStr['payload']['battery'][0]['value']; $this->_return['Bat'] = $OutStr['payload']['battery'][0]['value']; } else log::add("wifilightV2",'debug'," Bat not set"); } log::add("wifilightV2",'debug',$strLog); return $this->_return; } public function On() { //log::add($this->_log,'debug',' ON' ); $string = sprintf($this->_commandCodes['CMD_ON'],$this->GetGroup()); //FBA return $this->send($string,"/config",'Appliance.Control.ToggleX','POST','SET'); return $this->send($string,"/config",'Appliance.Control.Toggle','POST','SET'); } public function Off() { //log::add($this->_log,'debug',' OFF' ); $string = sprintf($this->_commandCodes['CMD_OFF'],$this->GetGroup()); //FBA return $this->send($string,"/config",'Appliance.Control.ToggleX','POST','SET'); return $this->send($string,"/config",'Appliance.Control.Toggle','POST','SET'); } public function OnLed() { //log::add($this->_log,'debug',' ON' ); $string = sprintf($this->_commandCodes['CMD_ONLED']); return $this->send($string,"/config",'Appliance.System.DNDMode','POST','SET'); } public function OffLed(){ //log::add($this->_log,'debug',' OFF' ); $string = sprintf($this->_commandCodes['CMD_OFFLED']); return $this->send($string,"/config",'Appliance.System.DNDMode','POST','SET'); } } class W2_MerossGarage extends W2_MerossBase { protected $_power = false; protected $_led = false; protected $_on = true; protected $_onZero = true; public function On() { //log::add($this->_log,'debug',' ON' ); $url="http://".$this->_host."/config"; $string = sprintf($this->_commandCodes['CMD_OPEN'],0,$url); return $this->send($string,"/config",'Appliance.GarageDoor.State','POST','SET'); } public function Off() { //log::add($this->_log,'debug',' OFF' ); $url="http://".$this->_host."/config"; $string = sprintf($this->_commandCodes['CMD_CLOSE'],0,$url); return $this->send($string,"/config",'Appliance.GarageDoor.State','POST','SET'); } } class W2_MerossHubValve extends W2_MerossBase { protected $_power = false; protected $_led = false; protected $_on = false; protected $_onZero = false; protected $_tempHub = true; public function OnDisco($parameters,$speed=0){ $id = $this->_LocalId; $string = sprintf($this->_commandCodes['CMD_MODE_HUB'],$parameters-1,$id); return $this->send($string,"/config",'Appliance.Hub.Mts100.Mode','POST','SET'); } public function On() { //log::add($this->_log,'debug',' ON' ); $id = $this->_LocalId; //$this->retStatus(); $string = sprintf($this->_commandCodes['CMD_ON_HUB'],0,$id); return $this->send($string,"/config",'Appliance.Hub.ToggleX','POST','SET'); } public function Off() { //log::add($this->_log,'debug',' OFF' ); $id = $this->_LocalId; $string = sprintf($this->_commandCodes['CMD_OFF_HUB'],0,$id); return $this->send($string,"/config",'Appliance.Hub.ToggleX','POST','SET'); } public function OnConsTemp($temp) { //log::add($this->_log,'debug',' OFF' ); $id = $this->_LocalId; $string = sprintf($this->_commandCodes['CMD_SETTEMP_TARG_HUB'],$temp*10,$id); return $this->send($string,"/config",'Appliance.Hub.Mts100.Temperature','POST','SET'); } public function OnConsTempVac($temp) { //log::add($this->_log,'debug',' OFF' ); $id = $this->_LocalId; $string = sprintf($this->_commandCodes['CMD_SETTEMP_VAC_HUB'],$temp*10,$id); return $this->send($string,"/config",'Appliance.Hub.Mts100.Temperature','POST','SET'); } public function OnConsTempComf($temp) { //log::add($this->_log,'debug',' OFF' ); $id = $this->_LocalId; $string = sprintf($this->_commandCodes['CMD_SETTEMP_COMF_HUB'],$temp*10,$id); return $this->send($string,"/config",'Appliance.Hub.Mts100.Temperature','POST','SET'); } public function OnConsTempEco($temp) { //log::add($this->_log,'debug',' OFF' ); $id = $this->_LocalId; $string = sprintf($this->_commandCodes['CMD_SETTEMP_ECO_HUB'],$temp*10,$id); return $this->send($string,"/config",'Appliance.Hub.Mts100.Temperature','POST','SET'); } } class W2_MerossHubTempSensor extends W2_MerossBase { public function getBat() {; $string = ''; $ret = $this->send($string,"/config",'Appliance.Hub.Battery','POST','GET'); return $ret; } public function getAlarm() {; $string = ''; $ret = $this->send($string,"/config",'Appliance.Hub.Sensor.Alert','POST','GET'); return $ret; } public function getStatus() {; $string = ''; $ret = $this->send($string,"/config",'Appliance.Hub.Sensor.All','POST','GET'); return $ret; } } class W2_MerossPlugConso extends W2_MerossBase { protected $_power = true; protected $_led = true; protected $_onZero = true; protected $_on = false; public function On() { //log::add($this->_log,'debug',' ON' ); $string = sprintf($this->_commandCodes['CMD_ON'],0); //FBA return $this->send($string,"/config",'Appliance.Control.ToggleX','POST','SET'); return $this->send($string,"/config",'Appliance.Control.Toggle','POST','SET'); } public function Off() { //log::add($this->_log,'debug',' OFF' ); $string = sprintf($this->_commandCodes['CMD_OFF'],0); //FBA return $this->send($string,"/config",'Appliance.Control.ToggleX','POST','SET'); return $this->send($string,"/config",'Appliance.Control.Toggle','POST','SET'); } } class W2_MerossPlugUn extends W2_MerossBase { protected $_power = true; protected $_led = false; protected $_onZero = true; protected $_on = false; public function On() { //log::add($this->_log,'debug',' ON' ); $string = sprintf($this->_commandCodes['CMD_ON'],0); //FBA return $this->send($string,"/config",'Appliance.Control.ToggleX','POST','SET'); return $this->send($string,"/config",'Appliance.Control.Toggle','POST','SET'); } public function Off() { //log::add($this->_log,'debug',' OFF' ); $string = sprintf($this->_commandCodes['CMD_OFF'],0); //FBA return $this->send($string,"/config",'Appliance.Control.ToggleX','POST','SET'); return $this->send($string,"/config",'Appliance.Control.Toggle','POST','SET'); } } class W2_MerossSwitch extends W2_MerossBase { protected $_power = false; protected $_led = false; protected $_onZero = true; protected $_on = false; public function On() { //log::add($this->_log,'debug',' ON' ); $string = sprintf($this->_commandCodes['CMD_ON'],0); return $this->send($string,"/config",'Appliance.Control.ToggleX','POST','SET'); } public function Off() { //log::add($this->_log,'debug',' OFF' ); $string = sprintf($this->_commandCodes['CMD_OFF'],0); return $this->send($string,"/config",'Appliance.Control.ToggleX','POST','SET'); } } class W2_MerossRoller extends W2_MerossBase { protected $_power = false; protected $_led = false; protected $_onZero = true; protected $_on = false; protected $_position = true; public function Position($pos) { $string = sprintf($this->_commandCodes['CMD_POSITION'],$pos,0); return $this->send($string,"/config",'Appliance.RollerShutter.Position','POST','SET'); } public function Up() { return $this->Position(100); } public function Down() { return $this->Position(0); } public function Stop() { return $this->Position(-1); } }