• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP class using pilight socket connection
#1
Wink 
Hi,

I have spent some time writing a PHP class using the pilight socket connection, which allows a PHP (web) app residing anywhere on the LAN shared with the pilight machine to send control commands.
It is a first version with limited functionality and definitely not finished, nor am I a seasoned PHP developer. Just wanted to share this as I spent considerable time, and hopefully this can be a time saver for others.
Using this script assumes you have a properly running pilight daemon using a fixed control port (e.g. 5000).


$url - Needs to point to the IP or address of your pilight machine
$control_port - needs to be set to the control port on which your pilight daemon is listening.

Example of a calling function turning a switch on or set a dimmer level (off is easily modified)

function on($device)
{
    pilight:ConfusedetAction(pilight::CONTROL);
    pilight:ConfusedetDevice($device); // Name of device as defined in config.json
    pilight:ConfusedetState(pilight::ON); // Can be either ON or OFF

    return pilight:ConfusedendControl();
}

function dim($device, $level = 10)
{
   pilight:ConfusedetAction(pilight::CONTROL);
   pilight:ConfusedetDevice($device);
   pilight:ConfusedetState(pilight::ON);
   pilight:ConfusedetDimLevel($level); // Provide numeric value to set dimlevel
   return pilight:ConfusedendControl();
}
 

Just my two bits,

Dan


Attached Files
.php   class_pilight.php (Size: 2.81 KB / Downloads: 28)
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  Does piSchedule work with pilight 8.1.1-nightly Peter S 0 1,410 06-29-2018, 07:57 PM
Last Post: Peter S
  pilight-console - an LCD / keypad interface for pilight frenchie71 3 1,159 11-21-2017, 11:15 PM
Last Post: curlymo
  Connect pilight to your hue bridge hannemann 3 2,418 01-03-2017, 11:26 PM
Last Post: hannemann
  piScheduler -- A pilight extension for the daily switch plan gneandr 159 60,762 08-09-2016, 04:33 PM
Last Post: gneandr
  Controlling a RGB Led Strip over pilight mightyuhu 2 2,278 08-06-2016, 09:10 PM
Last Post: JohannK
  HomeBridge with pilight on raspbian Jurre 10 10,786 04-06-2016, 07:45 AM
Last Post: tomtom
  pilight voice commands kniazio 11 5,310 01-29-2016, 07:51 PM
Last Post: sral
  Python Ping pilight detect mobilephone Cryptomaster 0 2,028 01-10-2016, 04:17 PM
Last Post: Cryptomaster
  pilight config editor ktams 16 7,453 01-06-2016, 02:42 PM
Last Post: ktams
  command processing between pilight and openhab royhofman1989 3 2,689 07-13-2015, 11:26 AM
Last Post: curlymo

Forum Jump:


Browsing: 1 Guest(s)