Skip to content

Commit

Permalink
Added two minimal php scripts.
Browse files Browse the repository at this point in the history
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
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ https://github.com/Panzenbaby/Raspberry-Remote-for-Windows-10-IoT-Core

## Usage
Try if all is working with the send program
* Switch on single socket: `./send 00001 1 1`
* Switch on multiple sockets: `./send 00001 1 00001 2 00001 3 1`
* Switch on single socket: `./send 1 00001 1 1`
* Switch on multiple sockets: `./send 1 00001 1 1 00001 2 1 00001 3 1`

### Options
* `-b`, `--binary`: Use binary socket numbering instead of the common "only one switch up"-numbering. See [Binary Mode](#binary-mode) for further details.
Expand Down
43 changes: 43 additions & 0 deletions webinterface/click.php
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";
}

?>
36 changes: 36 additions & 0 deletions webinterface/status.php
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";
}
?>

0 comments on commit fea210a

Please sign in to comment.