-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
One for pulling a current state of one switch, one for switching the state of one switch. This is for simplifying the usage with other third-party-software like Z-Wave or Homebridge. The Usage is completely optional. Also made a little change to the readme
- Loading branch information
tillepille
committed
Dec 16, 2017
1 parent
c1fa6e3
commit fea210a
Showing
3 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/* | ||
* Raspberry Remote | ||
* http://xkonni.github.com/raspberry-remote/ | ||
* | ||
* webinterface | ||
* | ||
* get configuration | ||
* don't forget to edit config.php | ||
*/ | ||
include("config.php"); | ||
|
||
/* | ||
* get parameters | ||
*/ | ||
if (isset($_GET['sys'])) $nSys=$_GET['sys']; | ||
else $nSys=""; | ||
if (isset($_GET['group'])) $nGroup=$_GET['group']; | ||
else $nGroup=""; | ||
if (isset($_GET['switch'])) $nSwitch=$_GET['switch']; | ||
else $nSwitch=""; | ||
if (isset($_GET['action'])) $nAction=$_GET['action']; | ||
else $nAction=""; | ||
if (isset($_GET['delay'])) $nDelay=$_GET['delay']; | ||
else $nDelay=0; | ||
|
||
/* | ||
* actually send to the daemon | ||
*/ | ||
$output = $nSys.$nGroup.$nSwitch.$nAction.$nDelay; | ||
if (strlen($output) >= 5) { | ||
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die("Could not create socket\n"); | ||
socket_bind($socket, $source) or die("Could not bind to socket\n"); | ||
socket_connect($socket, $target, $port) or die("Could not connect to socket\n"); | ||
socket_write($socket, $output, strlen ($output)) or die("Could not write output\n"); | ||
socket_close($socket); | ||
|
||
echo "Success!"; | ||
}else { | ||
echo "Please set sys group switch action delay"; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/* | ||
* Raspberry Remote | ||
* http://xkonni.github.com/raspberry-remote/ | ||
* | ||
* webinterface | ||
* | ||
* get configuration | ||
* don't forget to edit config.php | ||
*/ | ||
include("config.php"); | ||
|
||
/* | ||
* get parameters | ||
*/ | ||
if (isset($_GET['sys'])) $nSys=$_GET['sys']; | ||
else $nSys=""; | ||
if (isset($_GET['group'])) $nGroup=$_GET['group']; | ||
else $nGroup=""; | ||
if (isset($_GET['switch'])) $nSwitch=$_GET['switch']; | ||
else $nSwitch=""; | ||
|
||
|
||
$output = $iSys.$ig.$is."2"; | ||
if (strlen($output) >= 3) { | ||
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die("Could not create socket\n"); | ||
socket_bind($socket, $source) or die("Could not bind to socket\n"); | ||
socket_connect($socket, $target, $port) or die("Could not connect to socket\n"); | ||
|
||
socket_write($socket, $output, strlen ($output)) or die("Could not write output\n"); | ||
$state = socket_read($socket, 2048); | ||
echo $state; | ||
}else { | ||
echo "Please set sys group switch"; | ||
} | ||
?> |