temperatureInCelsius() public method

public temperatureInCelsius ( $temperature, $serial_number = null )
Esempio n. 1
0
 $deltah = $locations[0]->outside_humidity - $data_lasth["outside_humidity"][0];
 //print_r($deltah);//print value for debug purposes
 //check if logical delta value is exceeded and that this is not a new database.
 if (abs($deltah) > $jumph and $data_lasth["outside_humidity"][0] != NULL) {
     //replace current value with previous value. Introduces small error, but less than introducing nonsense values
     $locations[0]->outside_humidity = $data_lasth["outside_humidity"][0];
 }
 //-------------------------------------------------------------------------------------------------------------------
 //Insert Current Values into Nest Database Table
 //if you add addional values to the NEST API, you need to also add them here so that they will be logged in the database.
 // you also need to add the correctly named column to the database structure FIRST, or the php script will return an error.
 $sql = 'INSERT INTO nest (log_datetime, location, outside_temp, outside_humidity, away_status, leaf_status, current_temp, current_humidity, temp_mode, low_target_temp, high_target_temp, time_to_target, target_humidity, heat_on, humidifier_on, ac_on, fan_on, battery_level, is_online, alt_heat, aux_threshold, hvac_wires) VALUES (NOW(), "' . $postal_code . '", "' . $locations[0]->outside_temperature . '", "' . $locations[0]->outside_humidity . '", "' . $locations[0]->away . '", "' . $infos->current_state->leaf . '", "' . $infos->current_state->temperature . '", "' . $infos->current_state->humidity . '", "' . $infos->current_state->mode . '", "' . $low_target_temp . '", "' . $high_target_temp . '", "' . $infos->target->time_to_target . '","' . $infos->target->humidity . '","' . $infos->current_state->heat . '","' . $infos->current_state->humidifier . '","' . $infos->current_state->ac . '","' . $infos->current_state->fan . '","' . $infos->current_state->battery_level . '","' . $infos->network->online . '", "' . $infos->current_state->alt_heat . '","' . $aux_converted . '","' . $infos->current_state->hvac_wires . '")';
 $result = $con->query($sql) or trigger_error('SQL: ' . $sql . ' Error: ' . $con->error, E_USER_ERROR);
 //Set the humidity level if enabled.
 if ($set_humidity) {
     $exttemp = $nest->temperatureInCelsius($locations[0]->outside_temperature);
     // Drop target humidity 5% for every 5degree C drop below 0
     $target = max(0, $maxhumidity + $exttemp);
     $target = round(min($target, $maxhumidity, 60));
     if (abs($target - $infos->target->humidity) >= 1) {
         // Target humidity has changed
         $nest->setHumidity(intval($target));
     }
 }
 //-------------------------------------------circulation mode-------------------------------------------------------------------------
 // If circulate air mode is allowed, check to see if inside temp is over setpoint by 1.4 (circbuffer) degrees and that all other criteria are met. Enable fan until criteria are not met.
 if ($circmode == true and $low_target_temp + $circbuffer - $infos->current_state->temperature <= 0 and round($low_target_temp) >= $circtemp and $infos->current_state->fan == 0 and $infos->current_state->temperature - $circobuffer > $locations[0]->outside_temperature) {
     $nest->setFanModeOnWithTimer(FAN_TIMER_15M);
     //run fan for 15 minutes
 } else {
     $nest->setFanMode(FAN_MODE_AUTO);