Difference between revisions of "WeeWX Weather Server"

From Da Nerd Mage Wiki
Jump to navigation Jump to search
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{{!}} class="wikitable" style="float: right; width: 322px;" border="2"
{{!}}+ Proven on:
{{!}}- < --="" debian="" -->
{{!}} style="text-align: center; width: 60px;" {{!}} [[File:Logo Debian.png{{!}}60px{{!}}link=https://www.debian.org/{{!}}center{{!}}middle{{!}}frameless]]
{{!}} style="text-align: center; width: 40px;" {{!}} 12 (bullseye)
{{!}} Actually, a pretty much all default LXC running under Proxmox. Only non-default item being that I gave it 4 cores.
{{!}}}
This particular set of instructions is based on building a Debian 12 based LXC under Proxmox to handle WeeWX.  On my network, I have an existing WebServer & an existing Automation Server.  The intent is to have the weather information served up as a web page (Default WeeWX thing...) by the WebServer and also be used by the Automation Server.
This particular set of instructions is based on building a Debian 12 based LXC under Proxmox to handle WeeWX.  On my network, I have an existing WebServer & an existing Automation Server.  The intent is to have the weather information served up as a web page (Default WeeWX thing...) by the WebServer and also be used by the Automation Server.


Line 7: Line 15:
Originally, the old version of this article was done with a much earlier version of WeeWX & our old Accurite weather station.  Things have seriously changed since those days...
Originally, the old version of this article was done with a much earlier version of WeeWX & our old Accurite weather station.  Things have seriously changed since those days...


== Configure '''apt''' ==
== Configure apt ==
* <code>sudo apt install -y wget gnupg</code>
* <code>sudo apt install -y wget gnupg</code>
* <code>wget -qO - <nowiki>https://weewx.com/keys.html</nowiki> | sudo gpg --dearmor --output /etc/apt/trusted.gpg.d/weewx.gpg</code>
* <code>wget -qO - <nowiki>https://weewx.com/keys.html</nowiki> | sudo gpg --dearmor --output /etc/apt/trusted.gpg.d/weewx.gpg</code>
Line 16: Line 24:
* <code>sudo apt update</code>
* <code>sudo apt update</code>
* <code>sudo apt install weewx</code>
* <code>sudo apt install weewx</code>
During this step, you will be asked for all the details about your install.
During this step, you will be asked for all the details about your install.


Fill everything in as best you can, but you can indeed change things later too.
Fill everything in as best you can, but you can indeed [[#OTHER CUSTOMISATIONS{{!}}change things later]] too.


If you are using weather station hardware that is supported by default, go ahead and select that hardware when asked. In my case, I'm currently running an EcoWitt weather station & that will require a little more effort. For now, I'm selecting '''Simulator''' as my hardware type.
If you are using weather station hardware that is supported by default, go ahead and select that hardware when asked. In my case, I'm currently running an EcoWitt weather station & that will require a little more effort. For now, I'm selecting '''Simulator''' as my hardware type.


Once the machine has finished churning away at the install, WeeWX will be running. You can verify this by running:
Once the machine has finished churning away at the install, WeeWX will be running. You can verify this by running:


* <code>sudo systemctl status weewx</code>
* <code>sudo systemctl status weewx</code>
Line 34: Line 41:
* <code>wget -O weewx-gw1000.zip <nowiki>https://github.com/hoetzgit/weewx-gw1000/archive/master.zip</nowiki></code>
* <code>wget -O weewx-gw1000.zip <nowiki>https://github.com/hoetzgit/weewx-gw1000/archive/master.zip</nowiki></code>
* <code>sudo weectl extension install weewx-gw1000.zip</code>
* <code>sudo weectl extension install weewx-gw1000.zip</code>
Verify it can talk to your EcoWitt gateway:
Verify it can talk to your EcoWitt gateway:


*<code>PYTHONPATH=/usr/share/weewx python3 /etc/weewx/bin/user/gw1000.py --test-driver --ip-address='''device_ip_address'''</code>
*<code>PYTHONPATH=/usr/share/weewx python3 /etc/weewx/bin/user/gw1000.py --test-driver --ip-address='''device_ip_address'''</code>
(Where you replace '''device_ip_address''' with the actual address of your gateway...)
(Where you replace '''device_ip_address''' with the actual address of your gateway...)


Line 48: Line 53:


*<code>sudo weectl station reconfigure --driver=user.gw1000</code>
*<code>sudo weectl station reconfigure --driver=user.gw1000</code>
restart WeeWx
restart WeeWx


*<code>sudo systemctl restart weewx</code>
*<code>sudo systemctl restart weewx</code>
 
('''Note''': I've verified this with '''GW1100''', '''GW1200 and GW3000''' gateways so far...)
('''Note''': I've verified this with '''GW1100''' and '''GW1200''' gateways so far...)


== Customising WeeWX ==
== Customising WeeWX ==


=== Connecting to a remote database ===
=== Uploading to your own webserver ===
=== Broadcasting over MQTT ===
=== Broadcasting over MQTT ===
Install paho-mqtt
Install paho-mqtt
Line 87: Line 88:
* <code>sudo systemctl restart weewx</code>
* <code>sudo systemctl restart weewx</code>


=== Connecting to a remote database ===
By default, WeeWX uses a local instance of SQLite.
But, you may wish to archive its data on your primary database.
(Maybe even go nuts & set up multiple weather stations, all sending their data to a central database server...)
==== Setting up the database (MySQL / MariaDB) ====
On the Database Server:
(NOTE: Your Database Server must be configured to allow remote access.)
*<code>sudo mysql -u root -p</code>
CREATE USER 'weewx'@''''Machine.Domain.TLD'''' IDENTIFIED BY 'weewx';
CREATE DATABASE weewx;
GRANT select, update, create, delete, insert, drop ON weewx.* TO weewx@''''Machine.Domain.TLD'''';
('''Machine.Domain.TLD''', of course, being the address of your WeeWX Server...)
==== Configuring WeeWX to use this database ====
*<code>sudo vi /etc/weewx/weewx.conf</code>
in <nowiki>[[wx_binding]]</nowiki>
change
<code>database = archive_sqlite</code>
to
<code>database = archive_mysql</code>
in <nowiki>[[MySQL]]</nowiki>
change
<code>host = localhost</code>
to
<code>host = '''Machine.Domain.TLD'''</code>
('''Machine.Domain.TLD''', of course, being the address of your Database Server...)
restart WeeWx
* <code>sudo systemctl restart weewx</code>
=== Making the weather visible via Web Browser ===
There are 3 options for locally serving up the weather as HTML...
==== 1: Install a web server on the same machine (or VM...or LXC...) ====
Install your choice of web server and simply point the root at '''/var/www/html/weewx'''
==== 2: Use FTP to upload to your existing WebServer ====
(Your Web Server will need to have FTP enabled...)
*<code>sudo vi /etc/weewx/weewx.conf</code>
Find the <nowiki>[[FTP]]</nowiki> block & edit it to suit.
<nowiki>[StdReport]</nowiki>
    <nowiki>[[FTP]]</nowiki>
        skin = Ftp
        enable = true
        server = '''Machine.Domain.TLD'''
        path = /var/www/html/weewx
        user = '''USERNAME'''
        password = '''PASSWORD'''
==== 3: Use RSYNC to upload to your existing WebServer ====
(You will need to set up passwordless SSH between this machine & your web server...)
*<code>sudo vi /etc/weewx/weewx.conf</code>
Find the <nowiki>[[RSYNC]]</nowiki> block & edit it to suit.
<nowiki>[StdReport]</nowiki>
    <nowiki>[[RSYNC]]</nowiki>
        skin = Rsync
        enable = true
        server = '''Machine.Domain.TLD'''
        path = /var/www/html/weewx
        user = '''USERNAME'''
(Make sure your chosen user has write permissions...)
=== OTHER CUSTOMISATIONS ===
There is a configuration file at:
* <code>/etc/weewx/weewx.conf</code>
that holds most (if not all) of the little details & tweaks for your weather server.
==== Useful examples ====
'''archive_interval''' defines how often WeeWX updates its reports (Including via MQTT if you're using that...)
==Administration==
Checking status:
* <code>sudo systemctl status weewx</code>
Starting:
* <code>sudo systemctl start weewx</code>
Stopping:
* <code>sudo systemctl stop weewx</code>
Restarting:
* <code>sudo systemctl restart weewx</code>
Watching the system log
* <code>sudo journalctl -u weewx</code>


* <code></code>
* <code></code>

Latest revision as of 17:05, 16 September 2025

Proven on:
Logo Debian.png
12 (bullseye) Actually, a pretty much all default LXC running under Proxmox. Only non-default item being that I gave it 4 cores.

This particular set of instructions is based on building a Debian 12 based LXC under Proxmox to handle WeeWX. On my network, I have an existing WebServer & an existing Automation Server. The intent is to have the weather information served up as a web page (Default WeeWX thing...) by the WebServer and also be used by the Automation Server.

There is also a dedicated Database Server which we will be using. (can't possibly do things the easy way...)

(Based on: WeeWX: Installation on Debian-based systems)

Originally, the old version of this article was done with a much earlier version of WeeWX & our old Accurite weather station. Things have seriously changed since those days...

Configure apt

  • sudo apt install -y wget gnupg
  • wget -qO - https://weewx.com/keys.html | sudo gpg --dearmor --output /etc/apt/trusted.gpg.d/weewx.gpg
  • echo "deb [arch=all] https://weewx.com/apt/python3 buster main" | sudo tee /etc/apt/sources.list.d/weewx.list

Install WeeWX

  • sudo apt update
  • sudo apt install weewx

During this step, you will be asked for all the details about your install.

Fill everything in as best you can, but you can indeed change things later too.

If you are using weather station hardware that is supported by default, go ahead and select that hardware when asked. In my case, I'm currently running an EcoWitt weather station & that will require a little more effort. For now, I'm selecting Simulator as my hardware type.

Once the machine has finished churning away at the install, WeeWX will be running. You can verify this by running:

  • sudo systemctl status weewx

Setting up for EcoWitt gear

You'll be installing the Ecowitt Gateway (formerly GW1000) Driver

(Something happened to the original developer & all his stuff has vanished from the Interwebs...)

  • wget -O weewx-gw1000.zip https://github.com/hoetzgit/weewx-gw1000/archive/master.zip
  • sudo weectl extension install weewx-gw1000.zip

Verify it can talk to your EcoWitt gateway:

  • PYTHONPATH=/usr/share/weewx python3 /etc/weewx/bin/user/gw1000.py --test-driver --ip-address=device_ip_address

(Where you replace device_ip_address with the actual address of your gateway...)

You should observe loop packets being emitted on a regular basis. Once finished press ctrl-c to exit.

Note: You will only see loop packets and not archive records when running the driver directly. This is because you are seeing output not from WeeWX, but rather directly from the driver.

Configure WeeWX to use the driver:

  • sudo weectl station reconfigure --driver=user.gw1000

restart WeeWx

  • sudo systemctl restart weewx

(Note: I've verified this with GW1100, GW1200 and GW3000 gateways so far...)

Customising WeeWX

Broadcasting over MQTT

Install paho-mqtt

  • sudo apt -y install python3-paho-mqtt

Download the WeeWX MQTT Extension:

  • wget -O weewx-mqtt.zip https://github.com/matthewwall/weewx-mqtt/archive/master.zip

Install the extension:

  • sudo weectl extension install weewx-mqtt.zip

Then edit weewx.conf to configure things for your own MQTT server

  • sudo vim /etc/weewx/weewx.conf

Scroll down & find the [[MQTT]] block, then edit it to suit your network.

   [[MQTT]]
       server_url = mqtt://Machine.Domain.TLD:1883
       topic = weather
       unit_system = METRIC

restart WeeWx

  • sudo systemctl restart weewx

Connecting to a remote database

By default, WeeWX uses a local instance of SQLite.

But, you may wish to archive its data on your primary database.

(Maybe even go nuts & set up multiple weather stations, all sending their data to a central database server...)

Setting up the database (MySQL / MariaDB)

On the Database Server:

(NOTE: Your Database Server must be configured to allow remote access.)

  • sudo mysql -u root -p
CREATE USER 'weewx'@'Machine.Domain.TLD' IDENTIFIED BY 'weewx';
CREATE DATABASE weewx;
GRANT select, update, create, delete, insert, drop ON weewx.* TO weewx@'Machine.Domain.TLD';

(Machine.Domain.TLD, of course, being the address of your WeeWX Server...)

Configuring WeeWX to use this database

  • sudo vi /etc/weewx/weewx.conf

in [[wx_binding]]

change

database = archive_sqlite

to

database = archive_mysql

in [[MySQL]]

change

host = localhost

to

host = Machine.Domain.TLD

(Machine.Domain.TLD, of course, being the address of your Database Server...)

restart WeeWx

  • sudo systemctl restart weewx

Making the weather visible via Web Browser

There are 3 options for locally serving up the weather as HTML...

1: Install a web server on the same machine (or VM...or LXC...)

Install your choice of web server and simply point the root at /var/www/html/weewx

2: Use FTP to upload to your existing WebServer

(Your Web Server will need to have FTP enabled...)

  • sudo vi /etc/weewx/weewx.conf

Find the [[FTP]] block & edit it to suit.

[StdReport]
    [[FTP]]
        skin = Ftp
        enable = true
        server = Machine.Domain.TLD
        path = /var/www/html/weewx
        user = USERNAME
        password = PASSWORD

3: Use RSYNC to upload to your existing WebServer

(You will need to set up passwordless SSH between this machine & your web server...)

  • sudo vi /etc/weewx/weewx.conf

Find the [[RSYNC]] block & edit it to suit.

[StdReport]
    [[RSYNC]]
        skin = Rsync
        enable = true
        server = Machine.Domain.TLD
        path = /var/www/html/weewx
        user = USERNAME

(Make sure your chosen user has write permissions...)

OTHER CUSTOMISATIONS

There is a configuration file at:

  • /etc/weewx/weewx.conf

that holds most (if not all) of the little details & tweaks for your weather server.

Useful examples

archive_interval defines how often WeeWX updates its reports (Including via MQTT if you're using that...)

Administration

Checking status:

  • sudo systemctl status weewx

Starting:

  • sudo systemctl start weewx

Stopping:

  • sudo systemctl stop weewx

Restarting:

  • sudo systemctl restart weewx

Watching the system log

  • sudo journalctl -u weewx