It`s PHP class to authorize, get and set data for Nibe devices using Nibe myUplink -> successor of NibeUplink (which will be closed summer 2024). Entry level to use this tool is very low, so you can easily get and modify data from your device with basic php skills.
For more information -> look at wiki pages.
- PHP version 7.4+ (including 8.5)
- Account and application created on myUplink
- any other dependencies nor composers or packages
Goal is to have easy, non dependent class which will be cron ready to fetch all heat-pump data into json and allow changing parameters (such as running water heating on demand). And of course everyone can contribute to this repo.
-
Visit MyUplink and sign up for a user account.
-
Go to Applications, and register a new App
-
Download released version and paste it into your web directory
-
Open config.php and fill below settings as written in comments:
'clientID' => 'xxxxxxxxx', //from dev.myuplink.com
'clientSecret' => 'xxxxxxxxxxx', //from dev.myuplink.com
'redirectUri' => 'https://xxxxx/myuplink/', // from dev.myuplink.com - your absolute path where index.php is stored
'jsonOutPath' => '/xxxx/xxxx/myuplink/json/', //your absolute path when you will store json files as well as token.json* redirectUri is a web directory on which you pasted myuplink class - please make sure it is the same web URL as you saved in your Myuplink app.
-
Save config.php and open browser with redirectUri address. And see example below.
-
Optional - change debug to TRUE if you want to get detailed api responses.
Below example is the basic content of index.php for fetching data.
Outcome: will fetch all device data and save into jSON files and additionally returns array that you can access in your app.
//include autoloader for classes
include(__DIR__ . '/src/autoloader.php');
//start main class and fetch config
$nibe = new myuplink(__DIR__ . '/config.php');
//authorization, getting token and its status
if ($nibe->authorizeAPI() == TRUE) {
//if authorized switching to class which get data
$nibeGet = new myuplinkGet($nibe);
//get all possible endpoints, put to array and save to jSON
//$data is an array with key = endpoint key
$data = $nibeGet->getALL();
}To modify parameters (such as hot water boost or heating offsets), use the myuplinkSet class.
//include autoloader for classes
include(__DIR__ . '/src/autoloader.php');
//start main class and fetch config
$nibe = new myuplink(__DIR__ . '/config.php');
//authorization, getting token and its status
if ($nibe->authorizeAPI() == TRUE) {
// WARNING: Changing heat pump parameters via API is risky and can affect your system operation.
$nibeSet = new myuplinkSet($nibe);
// Set hot water boost (Mode 1: 3 hr, Mode 2: 6 hr, Mode 3: 12 hr, Mode 4: One-time incr., Mode 0: Off)
$nibeSet->setHotWaterBoost(1);
}If you doesn`t want to get all data everytime, look at /src/myuplinkGet.php for single methods.
For methods description you can look at API documentation.
- v.1.x.x - Class can authorize and get all data from Nibe device
- v.2.x.x - Class can change the parameters (f.e run water heating on demand)