Switc heater on if temp is 2 low, making Knut's life easier

Moderator: Telldus

Post Reply
philarete
Posts: 54
Joined: Fri Mar 17, 2023 9:45 am

Switc heater on if temp is 2 low, making Knut's life easier

Post by philarete »

Ok, i try to contibute - but i fell useless. Using PHP classes by Manticus, here is a simple try to switch a device on if sensor temp is low:

Code: Select all

    $infoDedans = $telldus_api->getSensor(178530); 
// Get sensor and humidity info in infoDedans Array
    $d2 = date('H:i:s', $infoDedans->lastUpdated);
//print_r($infoSensor); --> if tou wanna check
    $test=$infoDedans->data[0]->value; 
// Getting temp value (in Hash $infoDedans, 2 infos [0] is temp, and value its label and the same goes for [1] (humidity), 
// which label is 'value'.
	$humidity = $infoDedans->data[1]->value;
// At this point, you can compare value and switchon a device with turnOndevice function of Manticus classes. 
// Or implement a json_decode($this->consumer->sendRequest(constant('REQUEST_URI').'/device/turnOn',id,'GET'));
	if ($test < 19) {$telldus_api->turnOnDevice(141286)->status;} else {$telldus_api->turnOffDevice(141286)->status;}
If you want to refresh your php page in order to follow the sensor temp, use the "header" instruction with "refres" option set to "x" seconds.

Code: Select all

header("Refresh: 10;");
Could it be possible to implement a widget for this kind of thing ?
Post Reply