PHP code example of phil-lavin / heat-miser-wifi-php-interface

1. Go to this page and download the library: Download phil-lavin/heat-miser-wifi-php-interface library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phil-lavin / heat-miser-wifi-php-interface example snippets




// If you installed the library with Composer
//quire_once 'src/PhilLavin/HeatMiser/Wifi.php';

try {
	// ip, pin, optional port
	$hm = new \PhilLavin\HeatMiser\Wifi('192.168.1.123', 1234);
	$dcb = $hm->get_dcb();

	var_dump($dcb); // Dump existing DCB

	// Change heat programming for the weekend. 3rd period (return), starts at 16:00, target temp 25C
	$heat_data = $dcb['heat_data'];
	$heat_data['6-7'][2] = ['time'=>'16:00:00', 'target'=>25];
	$dcb->set_heat_data($heat_data); // Could be set_ followed by any of the below writable values - e.g. set_enabled(1)

	// Write and dump new DCB
	var_dump($hm->put_dcb($dcb));
}
catch (\PhilLavin\HeatMiser\ConnectionFailedException $e) {
	die("Failed to connect: ".$e->getMessage()."\n");
}
catch (\Exception $e) {
	die("Exception of type ".get_class($e)." thrown. Error was: {$e->getMessage()}\n");
}


array(28) {
  'vendor' =>
  string(9) "Heatmiser"
  'version' =>
  double(1.6)
  'model' =>
  string(3) "PRT"
  'time' =>
  string(19) "2013-01-31 23:34:24"
  'enabled' =>
  int(1)
  'keylock' =>
  int(0)
  'holiday' =>
  string(19) "2013-01-31 23:34:00"
  'holiday_enabled' =>
  int(0)
  'units' =>
  string(1) "C"
  'switchdiff' =>
  int(1)
  'caloffset' =>
  int(0)
  'outputdelay' =>
  int(0)
  'locklimit' =>
  int(0)
  'sensor' =>
  string(8) "internal"
  'optimumstart' =>
  int(0)
  'runmode' =>
  string(7) "heating"
  'frostprotect_enabled' =>
  int(1)
  'frostprotect_target' =>
  int(12)
  'remote_temperature' =>
  NULL
  'floor_temperature' =>
  NULL
  'internal_temperature' =>
  double(15.7)
  'heating_on' =>
  int(0)
  'heating_target' =>
  int(14)
  'heating_hold' =>
  int(0)
  'rateofchange' =>
  int(20)
  'errorcode' =>
  NULL
  'progmode' =>
  string(3) "5/2"
  'heat_data' =>
  array(2) {
    '1-5' =>
    array(4) {
      [0] =>
      array(2) {
        'time' =>
        string(8) "04:00:00"
        'target' =>
        int(19)
      }
      [1] =>
      array(2) {
        'time' =>
        string(8) "08:30:00"
        'target' =>
        int(14)
      }
      [2] =>
      array(2) {
        'time' =>
        string(8) "16:30:00"
        'target' =>
        int(18)
      }
      [3] =>
      array(2) {
        'time' =>
        string(8) "22:00:00"
        'target' =>
        int(14)
      }
    }
    '6-7' =>
    array(4) {
      [0] =>
      array(2) {
        'time' =>
        string(8) "08:00:00"
        'target' =>
        int(19)
      }
      [1] =>
      array(2) {
        'time' =>
        string(8) "13:00:00"
        'target' =>
        int(14)
      }
      [2] =>
      NULL
      [3] =>
      array(2) {
        'time' =>
        string(8) "22:00:00"
        'target' =>
        int(14)
      }
    }
  }
}
Javascript
"lavin/heat-miser-wifi-php-interface": "dev-master"
}