Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a demo pannel and statistics for local weather data #377

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

psa-jforestier
Copy link

This conf file add a panel with weather data provided by OpenWeatherMap. You will find :

  • Location name, date and time of the weather report
  • icon of the weather (direct linking from https://openweathermap.org/), weather description, temperature
  • feels like temperature, wind speed, wind direction (in degrees and with a pictogram)
  • humidity level (in a gauge) and sunrise / sunset time (in a gauge)
  • air pressure
    w1

Statistics are also collected for some metrics :

  • Temperature, feel-like temperature, humidity
  • wind speed and direction
  • air pressure
  • sunrise and sunset time
    w2

This config file use the OpenWeatherMap API, for which you have to subscribe (for free) to have an AppId. Set the AppId in the weather.conf file, or you will have "undefined" error on the report. You can find some AppId on the wild by using your favorite search engine.

Your RPi will make regular https connection to the api, please allow connection to api.openweathermap.org on your firewall. The connection frequency is about 1 call every 5 minutes (may be changed in the weather.conf).

The report will display icon of weather (sun, cloud...) which are hosted on openweathermap.org . For privacy concern, be warned that your RPi-monitor instance may be exposed by the "referer" http header to the internet.

@telemaxx
Copy link

cool, i will try.temp gauge/statistic from owm I have already.

@Robyxxx
Copy link

Robyxxx commented May 18, 2022

Added "weather.conf" in "/ect/rpimonitor/template" using my API key, checked that every 5 min the file "/tmp/weather.dat" was written. Data in weather.dat are correct (checked using nano). But no data appears in RPI web interface, only a new tab called "weather" both in "status" and in "statistics". What can be the problem?

weather.dat
{"coord":{"lon":9.7891,"lat":42.8264},"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02d"}],"base":"stations","main":"temp":26.59,"feels_like":26.59,"temp_min":25.92,"temp_max":27.76,"pressure":1021,"humidity":55,"sea_level":1021,"grnd_level":1004},"visibility":10000,"wind":{"speed":4.99,"deg":89,"gust":5.79},"clouds":{"all":14},"dt":1652873439,"sys"{"type":1,"id":6744,"country":"IT","sunrise":1652845717,"sunset":1652899468},"timezone":7200,"id":3168627,"name":"Rome","cod":200}

@psa-jforestier
Copy link
Author

Can you check in the log file of RPIMonitor (should be /var/log/rpimonitor.log ). Is there any error related to access to weather.dat ?

@Robyxxx
Copy link

Robyxxx commented May 18, 2022

Thanks for the suggestion... anyway I think no error related to weather.dat

/var/log/rpimonitor.log

[2022/05/18-16:26:29] RPi-Monitor has been started
Log level can be increased or decreased during runtime
by sending signal USR1 or USR2 with the command killall -USRx rpimonitord
Use of uninitialized value in vec at /usr/share/perl5/HTTP/Daemon.pm line 111.
sysread() on closed filehandle GEN1 at /usr/share/perl5/HTTP/Daemon.pm line 344.
Use of uninitialized value in vec at /usr/share/perl5/HTTP/Daemon.pm line 111.
sysread() on closed filehandle GEN2 at /usr/share/perl5/HTTP/Daemon.pm line 344.
Use of uninitialized value in vec at /usr/share/perl5/HTTP/Daemon.pm line 111.
sysread() on closed filehandle GEN3 at /usr/share/perl5/HTTP/Daemon.pm line 344.

@psa-jforestier
Copy link
Author

Maybe you missed the copy/paste of the weather.dat, but this element is invalid : "main":"temp":26.59 I will check later why you have such data in the file.

@Robyxxx
Copy link

Robyxxx commented May 18, 2022

Thansk a lot. There is a mistake in my previous copy/paste. This is my correct "weather.dat".

{"coord":{"lon":9.7891,"lat":42.8264},"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02d"}],"base":"stations","main":{"temp":26.34,"feels_like":26.34,"temp_min":26.34,"temp_max":26.92,"pressure":1022,"humidity":70,"sea_level":1022,"grnd_level":1005},"visibility":10000,"wind":{"speed":5.98,"deg":92,"gust":9.68},"clouds":{"all":11},"dt":1652892179,"sys":{"type":1,"id":6744,"country":"IT","sunrise":1652845717,"sunset":1652899468},"timezone":7200,"id":3168627,"name":"Rome","cod":200}

@psa-jforestier
Copy link
Author

I cant reproduce the problem you had with your coordinates ("lon":9.7891,"lat":42.8264) and I got the correct graph in "statistics" and correct info on "Status" section of RPIMonitor.
Some advices :

  • check the access right of /tmp/weather.dat . Must be readable by rpimonitor process.
  • increase the log level of rpimonitor : do a sudo killall -USR1 rpimonitord two times and check the log file in /var/log/monitor.log when the service is updating the weather data (every 5 minutes)
  • if you modify any conf file (/etc/rpimonitor/data.conf which include the weather.conf and /etc/rpimonitor/template/weather.conf) be sure to restart RPIMonitor daemon (and log level will be reset to normal)

@Robyxxx
Copy link

Robyxxx commented May 31, 2022

Attributes for /tmp/weather.dat are -rw-rw-rw- and the file is updated every about 5 minutes.
After increasing the log level, my log is:

[2022/05/31-12:02:41] RPi-Monitor has been started
Log level can be increased or decreased during runtime
by sending signal USR1 or USR2 with the command killall -USRx rpimonitord
[[2022/05/31-12:02:422022/05/31-12:02:42] Change loglevel to ] Change loglevel to 11

[2022/05/31-12:02:42] Change loglevel to 1
[2022/05/31-12:02:43] Change loglevel to 2
[2022/05/31-12:02:43] Change loglevel to [22022/05/31-12:02:43
] Change loglevel to 2
[2022/05/31-12:02:43] Monitor::Process Processing dynamic
[2022/05/31-12:02:43] Monitor::ParseCommand Parsing command 'vcgencmd measure_volts core 2>/dev/null |'
[2022/05/31-12:02:43] Monitor::ParseCommand Parsing command 'vcgencmd measure_temp 2>/dev/null |'
[2022/05/31-12:02:43] Monitor::ParseCommand Parsing command '/bin/bash -c "m=$(expr $(date '+%M') % 5); if [[ $m == 0 ]]; then curl -m 10 -s "https://api.openweathermap.org/data/2.5/weather?units=metric&lat=42.8264&lon=9.7891&appid=xxxx&lang=en\" --output /tmp/weather.dat; fi" 2>/dev/null |'
[2022/05/31-12:02:43] Monitor::ParseCommand Parsing command 'df / 2>/dev/null |'
[2022/05/31-12:02:43] Monitor::ParseCommand Parsing command 'df /boot 2>/dev/null |'
[2022/05/31-12:02:43] Monitor::ParseCommand Parsing command 'df /media/pi/VOLUME 2>/dev/null |'
[2022/05/31-12:02:43] Monitor::ParseCommand Parsing command 'netstat -nlt 2>/dev/null |'
[2022/05/31-12:02:43] Monitor::ParseCommand Parsing command 'netstat -nlt 2>/dev/null |'
[2022/05/31-12:02:43] Monitor::Alert
[2022/05/31-12:02:43] Monitor::Status
[2022/05/31-12:02:50] Server::DoGET
[2022/05/31-12:02:50] Server::DoGET /dynamic.json
[2022/05/31-12:02:50] Server::SendStatus
Use of uninitialized value in vec at /usr/share/perl5/HTTP/Daemon.pm line 111.
sysread() on closed filehandle GEN3 at /usr/share/perl5/HTTP/Daemon.pm line 344.
[2022/05/31-12:02:53] Monitor::Process Processing dynamic
[2022/05/31-12:02:53] Monitor::ParseCommand Parsing command 'vcgencmd measure_volts core 2>/dev/null |'
[2022/05/31-12:02:53] Monitor::ParseCommand Parsing command 'vcgencmd measure_temp 2>/dev/null |'
[2022/05/31-12:02:53] Monitor::ParseCommand Parsing command '/bin/bash -c "m=$(expr $(date '+%M') % 5); if [[ $m == 0 ]]; then curl -m 10 -s "https://api.openweathermap.org/data/2.5/weather?units=metric&lat=42.8264&lon=9.7891&appid=xxxx&lang=en\" --output /tmp/weather.dat; fi" 2>/dev/null |'
[2022/05/31-12:02:53] Monitor::ParseCommand Parsing command 'df / 2>/dev/null |'
[2022/05/31-12:02:53] Monitor::ParseCommand Parsing command 'df /boot 2>/dev/null |'
[2022/05/31-12:02:53] Monitor::ParseCommand Parsing command 'df /media/pi/VOLUME 2>/dev/null |'
[2022/05/31-12:02:53] Monitor::ParseCommand Parsing command 'netstat -nlt 2>/dev/null |'
[2022/05/31-12:02:53] Monitor::ParseCommand Parsing command 'netstat -nlt 2>/dev/null |'
[2022/05/31-12:02:53] Monitor::Alert
[2022/05/31-12:02:53] Monitor::Status
[2022/05/31-12:03:02] Server::DoGET
[2022/05/31-12:03:02] Server::DoGET /dynamic.json
[2022/05/31-12:03:02] Server::SendStatus

@psa-jforestier
Copy link
Author

I have no idea... may be related to #393 ? I will check later if I have the same problem on my installation.
@Robyxxx : You should edit your log snippet and remove the value of appid.

@Robyxxx
Copy link

Robyxxx commented Jun 1, 2022

My current version is 2.12 r0, launching "sudo /etc/init.d/rpimonitor update" no update occurs. However the lastest version should be 2.13
The strange things is that in "/var/lib/rpimonitor/stat" I can found weather statistics (e.g. weather_temp.rrd, etc.)

@MatthK
Copy link

MatthK commented Jul 26, 2022

Thanks for this. I just saw this branch and tried it out.

At first I had the same problems, it just wouldn't show up. When I tried to get the weather tab, it showed ActivePage=1 in the URL. When I changed that to ActivePage=2 it did show up.

I then modified the weather.conf by commenting out the two lines at the top after "Add new pages", and changed the 3 to 1 in the web.status.X below to have it all on the same page.

Really neat!

And you can copy this PNG to /usr/share/rpimonitor/web/img/weather.png. Adjust the web.status.1.content.1.icon=weather.png line accordingly to have a more appropriate weather icon. Found this here.

weather

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants