Closed AdamWeglarz closed 4 years ago
Hi, it is not a bug, I simply haven't these functions implemented (because I personally don't see any use of it in my case).
The following behaviours could be implemented. Don't know if you have some experience and whether you could add this code... If I need to do it myself, I don't have immediately the time...
/**
* Set the thermostat to use ECO mode ($mode = ECO_MODE_MANUAL) or not ($mode = ECO_MODE_SCHEDULE).
*
* @param string $mode One of the ECO_MODE_* constants.
* @param string $serial_number The thermostat serial number. Defaults to the first device of the account.
*
* @return stdClass|bool The object returned by the API call, or FALSE on error.
*/
public function setEcoMode($mode, $serial_number = NULL) {
$serial_number = $this->getDefaultSerial($serial_number);
$data = array();
$data['mode'] = $mode;
$data['touched_by'] = 4;
$data['mode_update_timestamp'] = time();
$data = json_encode(array('eco' => $data));
return $this->doPOST("/v2/put/device." . $serial_number, $data);
}
2. HEATING ON/OFF
Same... This is not really implemented because setting the heating off has the same behaviour as lowing the temperature. Lowing the temperature is supported with the "temperature" devices that is created. Again, could be implemented based on the PHP...
/**
* Change the thermostat target mode and temperature
*
* @param string $mode One of the TARGET_TEMP_MODE_* constants.
* @param float|array $temperature Target temperature; specify a float when setting $mode = TARGET_TEMP_MODE_HEAT or TARGET_TEMP_MODE_COLD, and a array of two float values when setting $mode = TARGET_TEMP_MODE_RANGE. Not needed when setting $mode = TARGET_TEMP_MODE_OFF. Send NULL if you want to keep the previous temperature(s) value(s).
* @param string $serial_number The thermostat serial number. Defaults to the first device of the account.
*
* @return stdClass|bool The object returned by the API call, or FALSE on error.
*/
public function setTargetTemperatureMode($mode, $temperature = NULL, $serial_number = NULL) {
$serial_number = $this->getDefaultSerial($serial_number);
if ($temperature !== NULL) {
if ($mode == TARGET_TEMP_MODE_RANGE) {
if (!is_array($temperature) || count($temperature) != 2 || !is_numeric($temperature[0]) || !is_numeric($temperature[1])) {
echo "Error: when using TARGET_TEMP_MODE_RANGE, you need to set the target temperatures (second argument of setTargetTemperatureMode) using an array of two numeric values.\n";
return FALSE;
}
$temp_low = $this->temperatureInCelsius($temperature[0], $serial_number);
$temp_high = $this->temperatureInCelsius($temperature[1], $serial_number);
$data = json_encode(array('target_change_pending' => TRUE, 'target_temperature_low' => $temp_low, 'target_temperature_high' => $temp_high));
$set_temp_result = $this->doPOST("/v2/put/shared." . $serial_number, $data);
} elseif ($mode != TARGET_TEMP_MODE_OFF) {
// heat or cool
if (!is_numeric($temperature)) {
echo "Error: when using TARGET_TEMP_MODE_HEAT or TARGET_TEMP_MODE_COLD, you need to set the target temperature (second argument of setTargetTemperatureMode) using an numeric value.\n";
return FALSE;
}
$temperature = $this->temperatureInCelsius($temperature, $serial_number);
$data = json_encode(array('target_change_pending' => TRUE, 'target_temperature' => $temperature));
$set_temp_result = $this->doPOST("/v2/put/shared." . $serial_number, $data);
}
}
$data = json_encode(array('target_change_pending' => TRUE, 'target_temperature_type' => $mode));
return $this->doPOST("/v2/put/shared." . $serial_number, $data);
}
I am currently working on it... Already added the eco-mode. However I cannot yet test it in Domoticz (I am not at home now). So will upload once finished. If you want to test it yourself, give me your email address and I will mail it to you. I tested the nest function (in nest.py) itself and it works... Now the heating on/off to be done...
Both changes are done! Add possibility to set the eco mode (on/off) and the set the thermostat on/off (by using the existing switches). This version need also the following python3 modules installed (with sudo pip3 install ...): pytz and tzlocal . Take care about the remark that you need to restart your system after updating the plugin (seen the problem with the threads is not yet solved).
Hi,
I have problem with functioning of plugin. What works perfectly: 1) connecting to Nest servers 2) creating devices 3) refreshing status changed remotely on all 5 devices 4) setting up thermostat temperature 5) switching home/away
not working 1) switching heating on/off -> switch does not change inside domoticz and do not change nest thermostat setting 2) switch eco on/off -> switch does not change inside domoticz and do not change nest thermostat setting
I attach log: "2020-03-22 14:22:57.206 (Nest) Start thread Push 2020-03-22 14:22:57.175 Status: User: admin initiated a switch command (318/Nest - Hallway Away/On) 2020-03-22 14:22:58.082 (Nest - Hallway Away) Updating device from 0:'0' to have values 1:'1'. 2020-03-22 14:22:58.088 (Nest) Update Nest - Hallway Away: 1 - '1' 2020-03-22 14:22:58.088 (Nest) End thread Push 2020-03-22 14:23:00.685 (Nest) Pushing 'onCommandCallback' on to queue 2020-03-22 14:23:00.729 (Nest) Processing 'onCommandCallback' message 2020-03-22 14:23:00.729 (Nest) Calling message handler 'onCommand'. 2020-03-22 14:23:00.729 (Nest) onCommand called for Unit 1: Parameter 'Off', Level: 1 2020-03-22 14:23:00.729 (Nest) Hallway - Nest - Hallway Heating 2020-03-22 14:23:00.685 Status: User: admin initiated a switch command (317/Nest - Hallway Heating/Off) 2020-03-22 14:23:01.790 (Nest) Pushing 'onCommandCallback' on to queue 2020-03-22 14:23:01.790 Status: User: admin initiated a switch command (319/Nest - Hallway Eco mode/On) 2020-03-22 14:23:02.697 (Nest) End thread Push 2020-03-22 14:23:04.215 (Nest) Pushing 'onHeartbeatCallback' on to queue 2020-03-22 14:23:04.250 (Nest) Processing 'onHeartbeatCallback' message 2020-03-22 14:23:04.250 (Nest) Calling message handler 'onHeartbeat'. 2020-03-22 14:23:04.250 (Nest) onHeartbeat called 2020-03-22 14:23:04.251 (Nest) Start thread 2020-03-22 14:23:04.251 (Nest) Thread: GetNestCredentials done 2020-03-22 14:23:04.980 (Nest) Thread: GetDevicesAndStatus done 2020-03-22 14:23:04.980 (Nest) End thread"
Does anybody have any idea why and how to fix it?
Adam