Changeset 2013472
- Timestamp:
- 01/16/2019 03:13:08 PM (7 years ago)
- Location:
- live-weather-station/trunk
- Files:
-
- 11 edited
-
changelog.txt (modified) (1 diff)
-
includes/libraries/netatmo/Clients/NAApiClient.php (modified) (1 diff)
-
includes/traits/ClientrawPluginStationClient.php (modified) (5 diffs)
-
includes/traits/DBQuery.php (modified) (4 diffs)
-
includes/traits/DBStorage.php (modified) (1 diff)
-
includes/traits/DataDashboardHandling.php (modified) (2 diffs)
-
includes/traits/DataOutput.php (modified) (6 diffs)
-
includes/traits/DataTypeDescription.php (modified) (1 diff)
-
includes/traits/SystemOptionsHandling.php (modified) (1 diff)
-
includes/traits/WeatherIndexClient.php (modified) (2 diffs)
-
todo.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
live-weather-station/trunk/changelog.txt
r2012989 r2013472 2 2 #3.7.8 / January 14th, 2018 3 3 4 * Improvement: better data obsolescence handling. 5 * Improvement: for clientraw based stations, extra modules are created only if they are operational. 4 6 * Improvement: full compatibility with PHP 7.3. 5 7 * Bug fix: some few German words are again wrongly lower-cased - sorry, that's a long story (thanks to [@zerog981](https://weather.station.software/community/profile/zerog981/)). 8 * Bug fix: PHP errors when hosting provider blocks Netatmo services. 9 * Bug fix: psychrometric computation takes in some rare cases wrong reference values. 6 10 7 11 #3.7.7 / January 14th, 2018 -
live-weather-station/trunk/includes/libraries/netatmo/Clients/NAApiClient.php
r2010448 r2013472 240 240 return $decode; 241 241 } 242 elseif (isset($http_code)){ 243 throw new NAApiErrorType($http_code, 'HTTP error.', $decode); 244 } 242 245 else { 243 throw new NAApiErrorType( $http_code, 'HTTP error', $decode);246 throw new NAApiErrorType(490, 'No HTTP access.', $decode); 244 247 } 245 248 } -
live-weather-station/trunk/includes/traits/ClientrawPluginStationClient.php
r1962740 r2013472 83 83 $this->update_data_table($updates); 84 84 $updates['measure_type'] = 'pressure'; 85 $updates['measure_value'] = $this->convert_from_mslp_to_baro($weather[6], $station['loc_altitude'], $weather[4]); 85 $pressure_ref = $this->convert_from_mslp_to_baro($weather[6], $station['loc_altitude'], $weather[4]); 86 $updates['measure_value'] = $pressure_ref; 86 87 $this->update_data_table($updates); 87 88 $updates['measure_type'] = 'pressure_sl'; … … 164 165 $updates['measure_value'] = $weather[163]; 165 166 $this->update_data_table($updates); 167 $updates['measure_type'] = 'absolute_humidity'; 168 $updates['measure_value'] = $this->compute_partial_absolute_humidity($weather[4], 100 * $pressure_ref, $weather[5]); 169 $this->update_data_table($updates); 170 166 171 Logger::debug($this->facility, $this->service, $updates['device_id'], $updates['device_name'], $updates['module_id'], $updates['module_name'], 0, 'Success while collecting current weather data.'); 167 172 … … 260 265 $updates['measure_type'] = 'humidity'; 261 266 $updates['measure_value'] = $weather[13]; 267 $this->update_data_table($updates); 268 $updates['measure_type'] = 'absolute_humidity'; 269 $updates['measure_value'] = $this->compute_partial_absolute_humidity($weather[12], 100 * $pressure_ref, $weather[13]); 262 270 $this->update_data_table($updates); 263 271 $health = $this->compute_health_index($weather[12], $weather[13], null, null); … … 408 416 $updates['device_name'] = $station['station_name']; 409 417 for ($i = 0; $i < 9; $i++) { 418 if (!is_numeric($weather[$tmp[$i]])) { 419 $weather[$tmp[$i]] = null; 420 } 410 421 if ($weather[$tmp[$i]] < -99) { 411 422 $weather[$tmp[$i]] = null; 423 } 424 if (!is_numeric($weather[$hum[$i]])) { 425 $weather[$hum[$i]] = null; 412 426 } 413 427 if ($weather[$hum[$i]] >= 100) { … … 436 450 $this->update_data_table($updates); 437 451 } 438 $health = $this->compute_health_index($weather[$tmp[$i]], $weather[$hum[$i]], null, null); 439 foreach ($health as $key => $idx) { 440 $updates['measure_type'] = $key; 441 $updates['measure_value'] = $idx; 452 if (isset($weather[$tmp[$i]]) && isset($weather[$hum[$i]])) { 453 $updates['measure_type'] = 'absolute_humidity'; 454 $updates['measure_value'] = $this->compute_partial_absolute_humidity($weather[$tmp[$i]], 100 * $pressure_ref, $weather[$hum[$i]]); 442 455 $this->update_data_table($updates); 456 $health = $this->compute_health_index($weather[$tmp[$i]], $weather[$hum[$i]], null, null); 457 foreach ($health as $key => $idx) { 458 $updates['measure_type'] = $key; 459 $updates['measure_value'] = $idx; 460 $this->update_data_table($updates); 461 } 443 462 } 444 463 Logger::debug($this->facility, $this->service, $updates['device_id'], $updates['device_name'], $updates['module_id'], $updates['module_name'], 0, 'Success while collecting current weather data.'); -
live-weather-station/trunk/includes/traits/DBQuery.php
r2008024 r2013472 27 27 'uv_index_trend', 'illuminance_min', 'illuminance_max', 'illuminance_trend', 'soil_temperature_min', 'soil_temperature_max', 28 28 'soil_temperature_trend', 'moisture_content_min', 'moisture_content_max', 'moisture_content_trend', 'moisture_tension_min', 29 'moisture_tension_max', 'moisture_tension_trend', 'windstrength_trend'); 29 'moisture_tension_max', 'moisture_tension_trend', 'windstrength_trend', 'absolute_humidity_min', 'absolute_humidity_max', 30 'absolute_humidity_trend', 'loc_city', 'loc_country', 'loc_timezone'); 30 31 31 32 /** … … 457 458 $result[] = (array)$val; 458 459 } 459 $result = $this-> filter_values_by_stations_type($result, $station_type);460 $result = $this->obsolescence_filtering($this->filter_values_by_stations_type($result, $station_type)); 460 461 } 461 462 catch(\Exception $ex) { … … 470 471 $result = array(); 471 472 foreach ($return as $device_id => $device) { 473 $result[$device_id]['name'] = $device['device_name']; 472 474 foreach ($device as $measure_type => $measure) { 473 475 if (is_array($measure)) { … … 475 477 foreach ($measure as $module_type => $module) { 476 478 $value = $module['value']; 477 $diff = round ((abs( strtotime(get_date_from_gmt(date('Y-m-d H:i:s'))) - strtotime(get_date_from_gmt($module['timestamp']))))/60); 478 $ts = $module['timestamp']; 479 if ($measure_type == 'temperature' && $module_type == 'NAModule1' && ($diff < $this->delta_time)) { 480 break; 479 if ($measure_type == 'temperature') { 480 if ($module_type == 'NAModule1') { 481 $result[$device_id][$measure_type] = $value; 482 } 483 if ($module_type == 'NACurrent') { 484 if (!array_key_exists($measure_type, $result[$device_id])) { 485 $result[$device_id][$measure_type] = $value; 486 } 487 } 481 488 } 482 if ($measure_type == 'humidity' && $module_type == 'NAModule1' && ($diff < $this->delta_time)) { 483 break; 489 if ($measure_type == 'humidity') { 490 if ($module_type == 'NAModule1') { 491 $result[$device_id][$measure_type] = $value; 492 } 493 if ($module_type == 'NACurrent') { 494 if (!array_key_exists($measure_type, $result[$device_id])) { 495 $result[$device_id][$measure_type] = $value; 496 } 497 } 484 498 } 485 if ($measure_type == 'windstrength' && $module_type == 'NAModule2' && ($diff < $this->delta_time)) { 486 break; 499 if ($measure_type == 'windstrength') { 500 if ($module_type == 'NAModule2') { 501 $result[$device_id][$measure_type] = $value; 502 } 503 if ($module_type == 'NACurrent') { 504 if (!array_key_exists($measure_type, $result[$device_id])) { 505 $result[$device_id][$measure_type] = $value; 506 } 507 } 487 508 } 488 if ($measure_type == 'pressure' && $module_type == 'NAMain' && ($diff < $this->delta_time)) { 489 break; 509 if ($measure_type == 'pressure') { 510 if ($module_type == 'NAMain') { 511 $result[$device_id][$measure_type] = $value; 512 } 513 if ($module_type == 'NACurrent') { 514 if (!array_key_exists($measure_type, $result[$device_id])) { 515 $result[$device_id][$measure_type] = $value; 516 } 517 } 518 } 519 if (strpos($measure_type, 'loc_') === 0) { 520 $result[$device_id][$measure_type] = $value; 490 521 } 491 522 } 492 $result[$device_id]['name'] = $device['device_name'];493 $result[$device_id][$measure_type] = $value;494 523 } 495 524 } -
live-weather-station/trunk/includes/traits/DBStorage.php
r2011810 r2013472 751 751 // VERSION 3.7.0 752 752 self::create_live_weather_station_maps_table(); 753 754 // VERSION 3.7.8 755 update_option('live_weather_station_absolute_humidity_min_boundary', 0.0005); 753 756 754 757 -
live-weather-station/trunk/includes/traits/DataDashboardHandling.php
r2012989 r2013472 36 36 */ 37 37 private function get_dashboard($station_type, $device_id, $device_name, $module_id, $module_name, $module_type, $types, $datas, $place=null, $last_seen=false) { 38 $pressure_ref = null; 39 $temperature_ref = null; 40 $humidity_ref = null; 38 41 foreach($types as $type) { 39 42 if (isset($datas) && is_array($datas) && array_key_exists($type, $datas)) { … … 56 59 $updates['measure_value'] = $datas[$type]; 57 60 $this->update_data_table($updates); 58 } 61 if ($type === 'temperature') { 62 $temperature_ref = $datas[$type]; 63 } 64 if ($type === 'humidity') { 65 $humidity_ref = $datas[$type]; 66 } 67 } 68 } 69 if (isset($datas) && is_array($datas) && array_key_exists('pressure', $datas)) { 70 $pressure_ref = $datas['pressure']; 71 } 72 if (isset($temperature_ref) && isset($pressure_ref) && isset($humidity_ref)) { 73 $updates = array(); 74 $updates['device_id'] = $device_id; 75 $updates['device_name'] = $device_name; 76 $updates['module_id'] = $module_id; 77 $updates['module_type'] = $module_type; 78 $updates['module_name'] = $module_name; 79 $updates['measure_timestamp'] = date('Y-m-d H:i:s'); 80 $updates['measure_type'] = 'absolute_humidity'; 81 $updates['measure_value'] = $this->compute_partial_absolute_humidity($temperature_ref, 100 * $pressure_ref, $humidity_ref); 82 $this->update_data_table($updates); 59 83 } 60 84 $updates = array(); -
live-weather-station/trunk/includes/traits/DataOutput.php
r2011810 r2013472 53 53 'moisture_content', 'moisture_tension', 'evapotranspiration', 'strike_count', 'strike_instant', 54 54 'strike_distance', 'strike_bearing', 'visibility', 'picture', 'video', 'video_imperial', 'video_metric', 'steadman', 55 'summer_simmer', 'delta_t' );55 'summer_simmer', 'delta_t', 'absolute_humidity'); 56 56 private $not_showable_measurements = array('battery', 'firmware', 'signal', 'loc_timezone', 'loc_altitude', 57 57 'loc_latitude', 'loc_longitude', 'last_seen', 'last_refresh', 'first_setup', 'last_upgrade', 'last_setup', … … 66 66 'illuminance_trend', 'soil_temperature_min', 'soil_temperature_max', 'soil_temperature_trend', 'moisture_content_min', 67 67 'moisture_content_max', 'moisture_content_trend', 'moisture_tension_min', 'moisture_tension_max', 'moisture_tension_trend', 68 'windstrength_trend' );68 'windstrength_trend', 'absolute_humidity_min', 'absolute_humidity_max', 'absolute_humidity_trend'); 69 69 private $graph_allowed_serie = array('device_id', 'module_id', 'measurement', 'line_mode', 'dot_style', 'line_style', 'line_size'); 70 70 private $graph_allowed_parameter = array('cache', 'mode', 'type', 'template', 'color', 'label', 'interpolation', 'guideline', 'height', 'timescale', 'valuescale', 'data', 'periodtype', 'periodvalue'); … … 7014 7014 case 'co2_trend': 7015 7015 case 'humidity_trend': 7016 case 'absolute_humidity_trend': 7016 7017 case 'noise_trend': 7017 7018 case 'pressure_trend': … … 7183 7184 break; 7184 7185 case 'absolute_humidity': 7186 case 'absolute_humidity_min': 7187 case 'absolute_humidity_max': 7185 7188 case 'partial_absolute_humidity': 7186 7189 case 'saturation_absolute_humidity': … … 8173 8176 case 'partial_absolute_humidity': 8174 8177 case 'absolute_humidity': 8178 case 'absolute_humidity_min': 8179 case 'absolute_humidity_max': 8175 8180 $ref = get_option('live_weather_station_unit_psychrometry') ; 8176 8181 if ($force_ref != 0) { … … 8517 8522 case 'saturation_absolute_humidity': 8518 8523 case 'absolute_humidity': 8524 case 'absolute_humidity_min': 8525 case 'absolute_humidity_max': 8519 8526 $result = __('humidity', 'live-weather-station') ; 8520 8527 break; -
live-weather-station/trunk/includes/traits/DataTypeDescription.php
r2011810 r2013472 603 603 case 'absolute_humidity': 604 604 $result = ($abbr ? __('Abs. humidity', 'live-weather-station') : __('Absolute humidity', 'live-weather-station')); 605 break; 606 case 'absolute_humidity_min': 607 $result = ($abbr ? __('Abs. humidity', 'live-weather-station') : lws__('Lowest absolute humidity of the day', 'live-weather-station')); 608 break; 609 case 'absolute_humidity_max': 610 $result = ($abbr ? __('Abs. humidity', 'live-weather-station') : lws__('Highest absolute humidity of the day', 'live-weather-station')); 611 break; 612 case 'absolute_humidity_trend': 613 $result = ($abbr ? __('Abs. humidity', 'live-weather-station') : lws__('Absolute humidity trend', 'live-weather-station')); 605 614 break; 606 615 case 'specific_enthalpy': -
live-weather-station/trunk/includes/traits/SystemOptionsHandling.php
r2011810 r2013472 459 459 'min_alarm' => 0.005, 460 460 'max_alarm' => 0.05, 461 'min_boundary' => 0.00 5,461 'min_boundary' => 0.0005, 462 462 'max_boundary' => 0.05), 463 463 'uv_index' => array ( 'min_value' => 0, -
live-weather-station/trunk/includes/traits/WeatherIndexClient.php
r1970415 r2013472 20 20 use Id_Manipulation, Datetime_Conversion, Dashboard_Manipulation; 21 21 22 private $delta_time = 30;22 private $delta_time = 1800; 23 23 private $value_unknown = -9999; 24 24 protected $facility = 'Weather Computer'; … … 34 34 public function compute($station_type=false) { 35 35 $datas = $this->get_reference_values($station_type); 36 error_log(print_r($datas, true)); 36 37 $result = array(); 37 38 foreach ($datas as $id => $data) { -
live-weather-station/trunk/todo.txt
r2012989 r2013472 91 91 Widget styles 92 92 Use of live_weather_station_mutation_observer 93 UV sticker 93 94 94 95 New indexes: … … 127 128 128 129 Extension : 130 absolute_humidity 129 131 co2 130 132 humidity
Note: See TracChangeset
for help on using the changeset viewer.