Database update problem

Database update problem

Hi guys,

I have received several emails recently from people with the same issue – database is updating, all database-using scripts work perfectly fine, yet blocks like Current, Gauges etc. show the station is offline. In all cases it has the same cause.

In version 12 I first introduced the API, back then it was only supported by some programs, but in version 13 I modified the API script to make it usable for all. This means everyone should be using the API now, which for many reasons is useful not just for you, but also for me – maintaining just one script, which can therefore be highly optimized, there is less potential for errors etc etc.

Some time ago I also posted that you should all check you have the meteotemplateLive.txt file in your template root folder – this is the current conditions file created by the API. The reason I asked was also because all the current conditions using scripts, including for example the online/offline indicator in the footer, now use this file rather than the database (it is more up-to-date, it is loaded faster than querying the database etc).

The API script is actually much more sophisticated than it might seem, it is probably the most complicated single script in Meteotemplate because it does several things at the same time and it is also absolutely essential that it doesn’t have any bugs and that all potential unexpected inputs are handled correctly – the database updates are always the most important thing to work correctly.

Apart from just updating the database it handles the caching, allows updates as often as several seconds, checks that the data is realistic and that no nonsense is saved to the database, converts units when necessary, handles the extra sensor data, checks the time of last station report, handles missing parameters, calculates some values (dew point, feels like), etc.

Now we finally get to the root of the problem described above. Users who previously used a method of updating the database, which worked, but which was not one of the official updating mechanisms now does not work. These people usually had some sort of script which pushed data directly to the database and did not use any of the scripts I created or software directly supporting the API. This of course still works in terms of the database, but it means that they bypass the API script and therefore apart from other things, the current conditions file, the meteotemplateLive.txt, is not created and blocks and plugins using this file see the station as offline.

It is therefore crucial that you do not send data directly to the database, even if you know how to do it and have some sort of means to do that, it is necessary to pass data via the API script.

The currently supported update ways that use the API are:

  • WeatherDisplay – use the built-in Meteotemplate update feature
  • Meteobridge – use the built-in Meteotemplate update feature
  • WeatherCat – use the built-in Meteotemplate update feature
  • WeeWx – use the built-in Meteotemplate update feature
  • Cumulus – use a CRON job for update/update.php
  • NetAtmo – use the NetAtmo plugin + CRON job
  • WeatherLink – use WL-IP plugin + CRON job
  • WANET – use WANET plugin + CRON job
  • Weather Underground – set update type to WU in control panel and create a CRON job for the URL given on the update setup page
  • Custom file – if you have current conditions in a text/CSV file that is regularly uploaded to your server, use the “Custom file” option and update the template via update/update.php + CRON job

Any other method apart from the ones given above will mean some scripts will NOT work and so it is crucial you choose from the options above. It was never the case that I would discontinue some update type, but if you used some way of updating the database that you created yourself you will need to adjust this script to use the API (if you know how to do it, the API documentation can be found in the wiki) or you need to switch to one of the methods mentioned above.

Simply put:

  • XXX -> API.php -> Database – will work fine
  • XXX -> update/update.php -> Database – will work fine (the update.php script actually calls the API script as well so this works fine)
  • one of the plugins mentioned above -> Database – will work fine
  • XXX -> Database – will not work correctly


Leave a Comment