Skip to content

Commit

Permalink
Added configuration file for the session of SmartHome
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubelbub committed Mar 29, 2014
1 parent f0be2ca commit f0d9c1d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion example.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,31 @@
require_once 'Request/GetAllPhysicalDeviceStatesRequest.php';
require_once 'Request/GetMessageListRequest.php';

$newLine = php_sapi_name() == 'cli' ? "\n" : '<br />';
use \Bubelbub\SmartHomePHP\Request\SetActuatorStatesRequest;

$newLine = php_sapi_name() == 'cli' ? PHP_EOL : '<br />';

$config = new SimpleXMLElement('<SmartHomeConfiguration />');
$configFile = __FILE__ . '.config';
if(file_exists($configFile))
{
try{$config = new SimpleXMLElement($configFile, 0, true);}catch(Exception $ex){}
}

$sh = new \Bubelbub\SmartHomePHP\SmartHome('Hostname or IP address', 'Username', 'Password');

if(!file_exists($configFile))
{
$config->addChild('SessionId', $sh->getSessionId());
$config->addChild('Version', $sh->getVersion());
$config->addChild('ConfigurationVersion', $sh->getConfigVersion());
$config->saveXML($configFile);
}

$sh->setSessionId((string) $config->SessionId);
$sh->setVersion((string) $config->Version);
$sh->setConfigVersion((string) $config->ConfigurationVersion);

// get your current session id
echo 'Your session id is ' . $sh->getSessionId() . $newLine;

Expand Down

0 comments on commit f0d9c1d

Please sign in to comment.