Plugin Directory

Changeset 2013472


Ignore:
Timestamp:
01/16/2019 03:13:08 PM (7 years ago)
Author:
PierreLannoy
Message:

Version 3.7.8-dev0 / 3.7.8 pre-release.

Location:
live-weather-station/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • live-weather-station/trunk/changelog.txt

    r2012989 r2013472  
    22#3.7.8 / January 14th, 2018
    33
     4* Improvement: better data obsolescence handling.
     5* Improvement: for clientraw based stations, extra modules are created only if they are operational.
    46* Improvement: full compatibility with PHP 7.3.
    57* 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.
    610
    711#3.7.7 / January 14th, 2018
  • live-weather-station/trunk/includes/libraries/netatmo/Clients/NAApiClient.php

    r2010448 r2013472  
    240240                return $decode;
    241241            }
     242            elseif (isset($http_code)){
     243                throw new  NAApiErrorType($http_code, 'HTTP error.', $decode);
     244            }
    242245            else {
    243                 throw new  NAApiErrorType($http_code, 'HTTP error', $decode);
     246                throw new  NAApiErrorType(490, 'No HTTP access.', $decode);
    244247            }
    245248        }
  • live-weather-station/trunk/includes/traits/ClientrawPluginStationClient.php

    r1962740 r2013472  
    8383        $this->update_data_table($updates);
    8484        $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;
    8687        $this->update_data_table($updates);
    8788        $updates['measure_type'] = 'pressure_sl';
     
    164165        $updates['measure_value'] = $weather[163];
    165166        $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
    166171        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.');
    167172
     
    260265        $updates['measure_type'] = 'humidity';
    261266        $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]);
    262270        $this->update_data_table($updates);
    263271        $health = $this->compute_health_index($weather[12], $weather[13], null, null);
     
    408416        $updates['device_name'] = $station['station_name'];
    409417        for ($i = 0; $i < 9; $i++) {
     418            if (!is_numeric($weather[$tmp[$i]])) {
     419                $weather[$tmp[$i]] = null;
     420            }
    410421            if ($weather[$tmp[$i]] < -99) {
    411422                $weather[$tmp[$i]] = null;
     423            }
     424            if (!is_numeric($weather[$hum[$i]])) {
     425                $weather[$hum[$i]] = null;
    412426            }
    413427            if ($weather[$hum[$i]] >= 100) {
     
    436450                    $this->update_data_table($updates);
    437451                }
    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]]);
    442455                    $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                    }
    443462                }
    444463                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  
    2727                                 'uv_index_trend', 'illuminance_min', 'illuminance_max', 'illuminance_trend', 'soil_temperature_min', 'soil_temperature_max',
    2828                                 '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');
    3031
    3132    /**
     
    457458                $result[] = (array)$val;
    458459            }
    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));
    460461        }
    461462        catch(\Exception $ex) {
     
    470471        $result = array();
    471472        foreach ($return as $device_id => $device) {
     473            $result[$device_id]['name'] = $device['device_name'];
    472474            foreach ($device as $measure_type => $measure) {
    473475                if (is_array($measure)) {
     
    475477                    foreach ($measure as $module_type => $module) {
    476478                        $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                            }
    481488                        }
    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                            }
    484498                        }
    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                            }
    487508                        }
    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;
    490521                        }
    491522                    }
    492                     $result[$device_id]['name'] = $device['device_name'];
    493                     $result[$device_id][$measure_type] = $value;
    494523                }
    495524            }
  • live-weather-station/trunk/includes/traits/DBStorage.php

    r2011810 r2013472  
    751751            // VERSION 3.7.0
    752752            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);
    753756
    754757
  • live-weather-station/trunk/includes/traits/DataDashboardHandling.php

    r2012989 r2013472  
    3636     */
    3737    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;
    3841        foreach($types as $type) {
    3942            if (isset($datas) && is_array($datas) && array_key_exists($type, $datas)) {
     
    5659                $updates['measure_value'] = $datas[$type];
    5760                $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);
    5983        }
    6084        $updates = array();
  • live-weather-station/trunk/includes/traits/DataOutput.php

    r2011810 r2013472  
    5353        'moisture_content', 'moisture_tension', 'evapotranspiration', 'strike_count', 'strike_instant',
    5454        'strike_distance', 'strike_bearing', 'visibility', 'picture', 'video', 'video_imperial', 'video_metric', 'steadman',
    55         'summer_simmer', 'delta_t');
     55        'summer_simmer', 'delta_t', 'absolute_humidity');
    5656    private $not_showable_measurements = array('battery', 'firmware', 'signal', 'loc_timezone', 'loc_altitude',
    5757        'loc_latitude', 'loc_longitude', 'last_seen', 'last_refresh', 'first_setup', 'last_upgrade', 'last_setup',
     
    6666        'illuminance_trend', 'soil_temperature_min', 'soil_temperature_max', 'soil_temperature_trend', 'moisture_content_min',
    6767        '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');
    6969    private $graph_allowed_serie = array('device_id', 'module_id', 'measurement', 'line_mode', 'dot_style', 'line_style', 'line_size');
    7070    private $graph_allowed_parameter = array('cache', 'mode', 'type', 'template', 'color', 'label', 'interpolation', 'guideline', 'height', 'timescale', 'valuescale', 'data', 'periodtype', 'periodvalue');
     
    70147014            case 'co2_trend':
    70157015            case 'humidity_trend':
     7016            case 'absolute_humidity_trend':
    70167017            case 'noise_trend':
    70177018            case 'pressure_trend':
     
    71837184                break;
    71847185            case 'absolute_humidity':
     7186            case 'absolute_humidity_min':
     7187            case 'absolute_humidity_max':
    71857188            case 'partial_absolute_humidity':
    71867189            case 'saturation_absolute_humidity':
     
    81738176            case 'partial_absolute_humidity':
    81748177            case 'absolute_humidity':
     8178            case 'absolute_humidity_min':
     8179            case 'absolute_humidity_max':
    81758180                $ref = get_option('live_weather_station_unit_psychrometry') ;
    81768181                if ($force_ref != 0) {
     
    85178522            case 'saturation_absolute_humidity':
    85188523            case 'absolute_humidity':
     8524            case 'absolute_humidity_min':
     8525            case 'absolute_humidity_max':
    85198526                $result = __('humidity', 'live-weather-station') ;
    85208527                break;
  • live-weather-station/trunk/includes/traits/DataTypeDescription.php

    r2011810 r2013472  
    603603            case 'absolute_humidity':
    604604                $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'));
    605614                break;
    606615            case 'specific_enthalpy':
  • live-weather-station/trunk/includes/traits/SystemOptionsHandling.php

    r2011810 r2013472  
    459459                                                'min_alarm' => 0.005,
    460460                                                'max_alarm' => 0.05,
    461                                                 'min_boundary' => 0.005,
     461                                                'min_boundary' => 0.0005,
    462462                                                'max_boundary' => 0.05),
    463463            'uv_index' => array (               'min_value' => 0,
  • live-weather-station/trunk/includes/traits/WeatherIndexClient.php

    r1970415 r2013472  
    2020    use Id_Manipulation, Datetime_Conversion, Dashboard_Manipulation;
    2121
    22     private $delta_time = 30;
     22    private $delta_time = 1800;
    2323    private $value_unknown = -9999;
    2424    protected $facility = 'Weather Computer';
     
    3434    public function compute($station_type=false) {
    3535        $datas = $this->get_reference_values($station_type);
     36        error_log(print_r($datas, true));
    3637        $result = array();
    3738        foreach ($datas as $id => $data) {
  • live-weather-station/trunk/todo.txt

    r2012989 r2013472  
    9191Widget styles
    9292Use of live_weather_station_mutation_observer
     93UV sticker
    9394
    9495New indexes:
     
    127128
    128129Extension :
     130absolute_humidity
    129131co2
    130132humidity
Note: See TracChangeset for help on using the changeset viewer.