Code Monkey home page Code Monkey logo

weather-station-software / live-weather-station Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 2.0 8.28 MB

Display on your WordPress site, in many elegant ways, the meteorological data collected by public or personal weather stations.

Home Page: https://weather.station.software/

License: GNU General Public License v2.0

PHP 85.83% CSS 0.79% JavaScript 13.37%
ambient-weather bloomsky cumulus meteobridge netatmo-weather-station openweathermap weather weatherdisplay weatherflow weatherlink

live-weather-station's People

Contributors

jaz-on avatar szepeviktor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jaz-on seanford

live-weather-station's Issues

Ambient Weather - Incorrect assignment of temperature data from extra modules to outdoor temperature

Hello there,

Congratulations on taking over the project. I really appreciate the ability to display my weather station's data on my website. I was pleased to discover that you are on GitHub, providing a platform for users to contribute and report bugs. I'm in Information Security as one of my Jobs so I hope this is complete and helps identify the issues.

Description:

I've noticed an issue in the file includes/traits/AmbientPluginBaseClient.php. The temperature data from extra modules ('temp' . $i . 'f') is being assigned to the 'temperature' key in the $device array. This seems to be overwriting the outdoor temperature data, resulting in the temperature from extra modules being displayed as the outdoor temperature.

I am using the Ambient Weather Station model WS-5000. However, based on a brief review of the API documentation from Ambient Weather, it appears that the API output might not be dependent on the model. Ambient Weather seems to have standardized the outputs and simply omits data if it doesn't exist for a particular model. I've only had this weather station for a few weeks.

Steps to reproduce:

  1. Add the station to the WordPress plugin.
  2. Wait for the API to sync.
  3. Verify that the outdoor temperature displayed is incorrect.
  4. Remove the station from the WordPress plugin.
  5. Enable debug logs.
  6. Re-add the station to the WordPress plugin.
  7. Wait for the API to sync again.
  8. Verify that the outdoor temperature displayed is still incorrect.
  9. Go to the debug logs and retrieve the API log.
  10. In the API log, find the correct outdoor temperature field and the additional temperature and humidity sensor (in this case, a Pool/Hot Tub Temp sensor).
  11. Verify that the incorrect outdoor temperature displayed is actually the temperature from the additional temperature and humidity sensor.
  12. The issue occurs consistently every time these steps are performed.

Expected behavior:

The outdoor temperature and the temperatures from extra modules should be stored and displayed separately.

Actual behavior:

The temperature from extra modules is being displayed as the outdoor temperature.

Debug logs:

Here are the debug logs showing the API output with the correct values:

Array
(
    [0] => Array
        (
            [macAddress] => C4:5B:BE:5D:33:FE
            [lastData] => Array
                (
                    // ...
                    [tempf] => 68, // This is the correct outdoor temperature
                    // ...
                    [temp8f] => 100.9, // This is an additional module (Pool/Hot Tub Sensor with temperature only)
                    // ...
                )
            // ...
        )
)

In the above output, [tempf] => 68 is the correct outdoor temperature. However, [temp8f] => 100.9 is actually an additional module which is a Pool/Hot Tub Sensor with temperature only. The issue is that the temperature from this additional module is being displayed as the outdoor temperature.

Suggested fix:

Consider storing the temperature and humidity data from extra modules in separate keys in the $device array to avoid overwriting the outdoor temperature and humidity data. For example:

$device['temperature' . $i] = $device['temp' . $i . 'f'];
$device['humidity' . $i] = $device['humidity' . $i];

This would need to be done in the following section of code:

// NAModule9 - max 9 extra modules
for ($i = 0; $i < 9; $i++) {
    if (array_key_exists('temp' . $i . 'f', $device) || array_key_exists('humidity' . $i, $device)) {
        if (array_key_exists('temp' . $i . 'f', $device)) {
            $device['temperature'] = $device['temp' . $i . 'f'];
        }
        else {
            unset($device['temperature']);
        }
        if (array_key_exists('humidity' . $i, $device)) {
            $device['humidity'] = $device['humidity' . $i];
        }
        else {
            unset($device['humidity']);
        }
        // ...
    }
}

Please note that other parts of the codebase that interact with the $device array might need to be updated to handle these new keys.


Full w/o commentary Debug logs:

Here are the debug logs showing the API output with the correct values:

Array
(
    [0] => Array
        (
            [macAddress] => C4:5B:BE:5D:33:FE
            [lastData] => Array
                (
                    [dateutc] => 1689394440000
                    [tempinf] => 75.6
                    [battin] => 1
                    [humidityin] => 51
                    [baromrelin] => 28.955
                    [baromabsin] => 28.955
                    [tempf] => 68
                    [battout] => 1
                    [battrain] => 1
                    [humidity] => 96
                    [winddir] => 154
                    [winddir_avg10m] => 151
                    [windspeedmph] => 2.2
                    [windspdmph_avg10m] => 5.1
                    [windgustmph] => 6.7
                    [maxdailygust] => 28.4
                    [hourlyrainin] => 0
                    [eventrainin] => 0.24
                    [dailyrainin] => 0.24
                    [weeklyrainin] => 0.874
                    [monthlyrainin] => 3.823
                    [yearlyrainin] => 4
                    [lightning_day] => 144
                    [lightning_time] => 1689382933000
                    [lightning_distance] => 12.43
                    [batt_lightning] => 0
                    [solarradiation] => 0
                    [uv] => 0
                    [temp3f] => 7.7
                    [humidity3] => 73
                    [temp4f] => -4.2
                    [humidity4] => 58
                    [temp5f] => 35.8
                    [humidity5] => 56
                    [temp6f] => 0.1
                    [humidity6] => 54
                    [temp8f] => 100.9
                    [batt3] => 1
                    [batt4] => 1
                    [batt5] => 1
                    [batt6] => 1
                    [batt7] => 1
                    [batt8] => 1
                    [pm25] => 11
                    [pm25_24h] => 23.1
                    [aqi_pm25] => 46
                    [aqi_pm25_24h] => 74
                    [batt_25] => 1
                    [batt_co2] => 1
                    [feelsLike] => 68
                    [dewPoint] => 66.81
                    [feelsLike3] => 7.7
                    [dewPoint3] => 0.9
                    [feelsLike4] => -4.2
                    [dewPoint4] => -15.2
                    [feelsLike5] => 35.8
                    [dewPoint5] => 21.7
                    [feelsLike6] => 0.1
                    [dewPoint6] => -12.6
                    [feelsLikein] => 75.3
                    [dewPointin] => 56.2
                    [lastRain] => 2023-07-15T03:52:00.000Z
                    [lightning_hour] => 0
                    [tz] => America/Chicago
                    [date] => 2023-07-15T04:14:00.000Z
                )

            [info] => Array
                (
                    [name] => Main Farm Weather Station
                    [coords] => Array
                        (
                            [coords] => Array
                                (
                                    [lat] => 41.096889
                                    [lon] => -89.999745
                                )

                            [address] => 2220 Golf Course Rd, La Fayette, IL 61449, USA
                            [location] => La Fayette
                            [elevation] => 228.0929107666
                            [geo] => Array
                                (
                                    [type] => Point
                                    [coordinates] => Array
                                        (
                                            [0] => -89.999745
                                            [1] => 41.096889
                                        )

                                )

                        )

                )

        )

)

Renaming uncountable words + enhancing Github actions

Continuation of #27.

Further tuning needed: renaming uncountable words like datas, informations, serie.
These words were mixed up, as they also exist in French and are countable in my mother tongue.

Resources:

Props @szepeviktor

Send data to windy.com

Hi Jason

Congratulation with taking over the source code for weather station it was long needed, that someone carried it on onwards. We have been using the weather station module for number of years now and have developed quite a page combining data from weather station with other data sources see more details on: https://www.gillelejesejlklub.dk/vejret/

I'm also sharing data from weather station to https://stations.windy.com/ using some code I have built.

You are free to use the source code below if you want to include the capability in weather station.

function ws_get_windy_token( $token = "")
{
$token = " Register your station on https://stations.windy.com/ to get key "; // <- Replace this with your own token
return $token;
}

//-----------------------> Post to windy.com <---------------------------------

function ws_dopost($url, $json)
{
$fields = (is_array($json)) ? http_build_query($json) : $json;

if($ch = curl_init($url))
{
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$json = curl_exec($ch);

  $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  $json =   curl_getinfo($ch, CURLINFO_HTTP_CODE); 


  curl_close($ch);

  return (int) $status;

}
else
{
return false;
}
}

//-----------------------> Get the weatherlink data for you upload <---------------------------------

function ws_get_weatherlinkdata($message = "" )
{

$temp   = do_shortcode("[live-weather-station-textual device_id='wl:1d:0a:00:38:b2' module_id='m1:c0:00:00:00:01' measure_type='temperature' element='measure_value' format='computed' fx='none' color='#000000' speed='2000']");
$wind   = do_shortcode("[live-weather-station-textual device_id='wl:1d:0a:00:38:b2' module_id='m2:c0:00:00:00:01' measure_type='windstrength' element='measure_value' format='computed' fx='none' color='#000000' speed='2000']");
$windir = do_shortcode("[live-weather-station-textual device_id='wl:1d:0a:00:38:b2' module_id='m2:c0:00:00:00:01' measure_type='windangle' element='measure_value' format='raw' fx='none' color='#000000' speed='2000']");
$gust   = do_shortcode("[live-weather-station-textual device_id='wl:1d:0a:00:38:b2' module_id='m2:c0:00:00:00:01' measure_type='guststrength' element='measure_value' format='computed' fx='none' color='#000000' speed='2000']");
$rh     = do_shortcode("[live-weather-station-textual device_id='wl:1d:0a:00:38:b2' module_id='m1:c0:00:00:00:01' measure_type='humidity' element='measure_value' format='raw' fx='none' color='#000000' speed='2000']");


$curdatetime = date_format(date_create(),"Y-m-d").'T'.date_format(date_create(),"H:i:s");

$json =  '{"stations": [
						{"station":0, "name":"Name of station", "lat":xx.xxxxxxx, "lon":xx.xxxxxxxx, "elevation":0, "tempheight":2, "windheight":10}		
					],
		  "observations": [
					{"station":0, "dateutc":"'.$curdatetime.'", "temp":'.$temp.', "wind":'.$wind.', "winddir":'.$windir.', "gust":'.$gust.', "rh":'.$rh.'}
						] }' ;


return $json;

}

//-----------------------> main code code for sending data to windy <---------------------------------

function ws_put_weatherdata_to_windy( )
{

$url   = "https://stations.windy.com/pws/update/".ws_get_windy_token();
$json =  ws_get_weatherlinkdata();
$status = ws_dopost($url, $json);

}

//-----------------------> adding the cron task for schedule job <---------------------------------
//-----------------------> remember to set the scedule to max 5 minutes <---------------------------------

add_action( 'init', function () {

$hook = 'run_windy_update';
$args = array();

if ( ! wp_next_scheduled( $hook, $args ) ) {
	wp_schedule_event( time(), 'five_minutes', $hook, $args );
}

} );

add_action( 'run_windy_update', function () {

ws_put_weatherdata_to_windy();

} );

not updating info on real time

In the wordpress plug in is there a way to make a forced updated of the data? this is because its not updating since todays before today. how to fix this? thaks a lot

Wind state

This idea has been copied from the old todo.txt: requires discussion to add further details.

Time of High/Low Temperature incorrect?

If I try to report the lowest or highest temperature and the time of those readings, the plugin reports only the current time, not the actual time of the high/low temperature reading? Attached are screenshots
TimeMaximum
TimeMinimum

A screenshot of the realtime.txt file shows the txt file recording the correct times?
Realtimetxt

As reported on the web page, it shows the current local time for both High and Low?
Screenshot web

Gutenberg blocks

This idea has been copied from the old todo.txt: requires discussion to add further details.

5 days forecasting

This idea has been copied from the old todo.txt: requires discussion to add further details.

DataUnitConversion.php error with PHP 8.2

functions like this one in the file /wp-content/plugins/live-weather-station/includes/traits/DataUnitConversion.php :

protected function get_wind_angle($value)
    {
        $result = $value;
        return sprintf('%d', round($result, 0));
    }

throw an error in PHP 8.2 (it works fine in PHP 7.4) when $result='NULL' when executing the round command.
I run a test with the following modification, and it works for me (maybe not the best) :

protected function get_wind_angle($value)
	{
    // Convert non-numeric values to 0
    $result = is_numeric($value) ? $value : 0;

    // Round the numeric value
    return sprintf('%d', round($result, 0));
	}

Netatmo login not working

Good morning,

I have a problem: logging in with Netatmo doesn't work. It gives me a warning that the password is wrong. I tried to consult the other issues, but there is no resolution. Can anyone help me resolve this, or is there a valid alternative? Thank you

wind graph problems

Hi Jason,

i am very happy that weather station project it's going further with you!

this is the problems that I am having sometimes with the wind graph.
red line is gust and blue is medium intensity.
sometimes the gust is less than medium intensity

I attached a screenshot

Screenshot 2023-07-01 alle 16 29 39

Aridity index computing

This idea has been copied from the old todo.txt: requires discussion to add further details.

Davis Vantage Pro2 length of the password needs to be longer

Feedback from Johannes Anderson on Facebook:

[...]
I have a Davis Vantage Pro2 station and as others in the forum has found out, the length of the password for this is 32 chars (my memory may not be correct here) and the max length for the input field in the plug-in is 24 chars (my memory...)
I actually tried to download the code and found the place with the char limit for the password, but I did not have the courage to try to mage my own instance of the plug-in.
[...]

"Yesterday" rain not reporting

Firstly, thank you again for taking on this plugin. It is surely the best plugin available! I understand this is a project of love, so please understand my questions are in the hope you can help and I expect you will prioritise any requests as you see fit.

I have observed that "Yesterday" rain does not report on my website.
I have attached my realtime.txt file. It does not report anything for yesterday's rain?
20230912_W-Underground
You can see on Weather Underground that yesterday's rain was 0.3mm
20230911-realtime.txt

I have compared my realtime.txt file with someone else's and they report "Yesterday's Rain" at Line 21 also. Is the problem with the plugin or the realtime.txt file?

Netatmo logging not working

Netatmo support response >>

"This plugin seems to use client_credentials grant type (username/password) which was deprecated and now does not work anymore
The authorization_code grant type must be implemented to authenticate users : https://dev.netatmo.com/apidocumentation/oauth#authorization-code. They must then redo the /token process with the "code" value provided as URL parameter at user's redirection. If they implement the refresh_token process, you will maintain connectivity and will not have to use this “code” value anymore

As this is a third-party service using our APIs, we are not linked to them or their developments. You need to contact directly the developers of the solution or their community

Have a good day,
Leslie - Community Manager"

Einari

3.8.x add to documentation

This idea has been copied from the old todo.txt: requires discussion to add further details.

DOCUMENTATION:

-- Comparison

  • Bonus : banner

php72 /usr/local/bin/wp core update --version=trunk

Improved plugin description

Display meteorological data collected by public or personal weather stations on your WordPress site in a variety of elegant ways.

  • repository details (About ⚙️)
  • README.md
  • readme.txt
  • composer.json
  • plugin header

Please consider using the above description. Or improve upon it.

4 hours forecasting

This idea has been copied from the old todo.txt: requires discussion to add further details.

An error of type E_ERROR was caused in line 714 of the file DataUnitConversion.php

An error of type E_ERROR was caused in line 714 of the file /home/gregobru/public_html/wp-content/plugins/live-weather-station/includes/traits/DataUnitConversion.php. Error message: Uncaught ArgumentCountError: is_numeric() expects exactly 1 argument, 0 given in /home/gregobru/public_html/wp-content/plugins/live-weather-station/includes/traits/DataUnitConversion.php:714
Stack trace:
#0 /home/gregobru/public_html/wp-content/plugins/live-weather-station/includes/traits/DataUnitConversion.php(714): is_numeric()
#1 /home/gregobru/public_html/wp-content/plugins/live-weather-station/includes/traits/DataOutput.php(9321): WeatherStation\UI\Station\Handling->get_wind_angle()
#2 /home/gregobru/public_html/wp-content/plugins/live-weather-station/includes/traits/DataOutput.php(13278): WeatherStation\UI\Station\Handling->output_value()
#3 /home/gregobru/public_html/wp-content/plugins/live-weather-station/includes/classes/StationHelper.php(737): WeatherStation\UI\Station\Handling->get_all_formated_datas()
#4 /home/gregobru/public_html/wp-content/plugins/live-weather-station/includes/classes/StationHelper.php(553): WeatherStation\UI\Station\Handling->add_metaboxes()
#5 /home/gregobru/public_html/wp-includes/class-wp-hook.php(310): WeatherStation\UI\Station\Handling->station_add_options()
#6 /home/gregobru/public_html/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters()
#7 /home/gregobru/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#8 /home/gregobru/public_html/wp-admin/admin.php(237): do_action()
#9 {main}
thrown

Using Wordpress 6.3 and local file realtime.txt created by weewx via weewx-crt
Suspect the issue is that weather station is expecting an int but receiving a string but I'm unable to determine where this data is originating

Number formating

This idea has been copied from the old todo.txt: requires discussion to add further details.

Can't connect to Netatmo

I have weatherstation plugin hooked up to pull data from netatmo, now i'm not able to connect to netatmo. Just get bad credential when i try to login to my netatmo account thru weatherstation.
I know for a fact thats my credential is correct. When i login direct on netatmo site it is no problem.

Any suggestion?

New widgets?

This idea has been copied from the old todo.txt: requires discussion to add further details.

  • 3.x - Simple Weather Widget
  • 4.x - Soil widget
  • 4.x - UV widget
  • 4.x - Pollution widget
  • 5.x - Marine widget
  • 5.x - Aero widget
  • 5.x - Snow widget

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.