Switc heater on if temp is 2 low, making Knut's life easier
Posted: Fri Mar 17, 2023 9:45 am
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:
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.
Could it be possible to implement a widget for this kind of thing ?
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;}
Code: Select all
header("Refresh: 10;");