• 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

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: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:ConfusedetDimLevel($level); // Provide numeric value to set dimlevel
   return pilight:ConfusedendControl();

Just my two bits,


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

Possibly Related Threads...
Thread Author Replies Views Last Post
  HomeBridge with pilight on raspbian Jurre 11 16,204 08-30-2021, 12:52 AM
Last Post: RTmed
  Connect pilight to your hue bridge hannemann 4 4,374 10-26-2020, 02:08 PM
Last Post: Michelebup
  Does piSchedule work with pilight 8.1.1-nightly Peter S 0 2,399 06-29-2018, 07:57 PM
Last Post: Peter S
  pilight-console - an LCD / keypad interface for pilight frenchie71 3 2,484 11-21-2017, 11:15 PM
Last Post: curlymo
  piScheduler -- A pilight extension for the daily switch plan gneandr 159 101,220 08-09-2016, 04:33 PM
Last Post: gneandr
  Controlling a RGB Led Strip over pilight mightyuhu 2 3,392 08-06-2016, 09:10 PM
Last Post: JohannK
  pilight voice commands kniazio 11 8,789 01-29-2016, 07:51 PM
Last Post: sral
  Python Ping pilight detect mobilephone Cryptomaster 0 2,803 01-10-2016, 04:17 PM
Last Post: Cryptomaster
  pilight config editor ktams 16 11,938 01-06-2016, 02:42 PM
Last Post: ktams
  command processing between pilight and openhab royhofman1989 3 3,815 07-13-2015, 11:26 AM
Last Post: curlymo

Forum Jump:

Browsing: 1 Guest(s)