Weather Station Data

User guide for making weather station via MQTT work…

Home Assistant:

Weather station via WeewX:
ws1
ws2

1 STEP:
Set up weather station to the same network as WeewX will be set up and Home Assistant.
To set up EasyWeather use software: WS View



If data is sended to Weather Underground, then weather station is set up… Don’t worry, latter you can delete WU account…

2 STEP:
Set up router DNAT forwarding. To do this under EdgeRouter look pictures down… In other routers just use the same ports and of course your IP settings…


3 STEP:
Install Raspbian to the new docker station or to Raspberry Pi 2, 3 etc…
Download link: https://www.raspberrypi.org/downloads/raspbian/
(use: Raspbian Buster with desktop and recommended software)

4 STEP:
Set up weewX on Raspbian OS.
User guide: http://www.weewx.com/docs/debian.htm

Before of use my backup files it’s good to install:
1: Install weewx, select ‘Simulator’ driver
http://weewx.com/docs/usersguide.htm#installing
2: Download the interceptor driver
wget -O weewx-interceptor.zip https://github.com/matthewwall/weewx-interceptor/archive/master.zip
3: Install the driver (at installation choose simulator mode)
sudo wee_extension --install weewx-interceptor.zip
4: Configure the driver
sudo wee_config --reconfigure --driver=user.interceptor --no-prompt
5: Start weewx
sudo /etc/init.d/weewx start

You can download my predefined and ready-to-use WeewX backup… Just rewrite files and run weewX via Terminal command… Also change IP, username etc… where data is sended via MQTT procotol…

Files are located under: /etc/weewx

My complete weewX folder: https://gofile.io/?c=ZoqAsN
(ZIP password: home)

For copying use command…
gksudo in Terminal
pcmanfm on the Run text field. Pressing ok.

5 STEP:

Setup web server… After 5 minutes you should have data in web site of raspberry where weewx runs…

If the server is on the same machine

The reports generated by WeeWX can be served by a web server running on the same computer as WeeWX. These are instructions for making WeeWX reports available via the Apache web server. The process is similar for other web servers such as nginx or lighthttpd.

Install the Apache web server on the computer on which WeeWX is running. For example, on Debian systems:

sudo apt-get install apache2

Configure Apache to see the WeeWX reports.

    If WeeWX was installed from DEB or RPM package, no configuration should be necessary since the reports are placed in the directory /var/www/html/weewx, which is in the Apache DocumentRoot directory /var/www/html

    If WeeWX was installed using setup.py, you must tell Apache where to find the WeeWX reports. One method is to install an Apache configuration snippet:

    sudo cp util/apache/conf.d/weewx.conf /etc/apache2/conf.d

    Be sure that the path in the Apache configuration snippet matches the HTML_ROOT defined in the WeeWX configuration file. For example, the path for a default setup.py installation would look like this:

    Alias /weewx /home/weewx/public_html
    <Directory /home/weewx/public_html>
        Options FollowSymlinks
        AllowOverride None
    </Directory>

    Restart Apache to make the changes happen:

    sudo /etc/init.d/apache2 restart

Open the WeeWX URL in a web browser:

http://localhost/weewx

6 STEP:

After copying, set up your data, so edit file under weewx:
weewx.conf

To change desired port:
slika

To set up MQTT, so that data will be sended to Home Assistant. Also here you can set if you still want to receive data in WUnderground etc…
slika

7 STEP:

At the end make backup for just in case of making some restore…
User guide: https://www.raspberrypi.org/magpi/back-up-raspberry-pi/

8 STEP:

Now it’s time to set up Home Assistant…

My sensors, so that in lovelace looks like it looks:
sensor.relativna_vlaznost
sensor.pritisk
sensor.pritisk_visinomer
sensor.stopnja_padavin
sensor.stopnja_padavin_zadnja_ura
sensor.padavine_danes
sensor.soncno_sevanje
sensor.uv
sensor.temperatura
sensor.sunek_vetra
sensor.smer_vetra
sensor.hitrost_vetra

My code:

  - platform: mqtt
    name: "Relativna vlažnost"
    icon: mdi:water-percent
    state_topic: "weather/outHumidity"
    value_template: '{{ value | round(0) }}'
    unit_of_measurement: "%"

  - platform: mqtt
    name: "Pritisk (višinomer)"
    icon: mdi:gauge
    state_topic: "weather/altimeter_mbar"
    value_template: '{{ value | round(0) }}'
    unit_of_measurement: "mBar"

  - platform: mqtt
    name: "Pritisk"
    icon: mdi:gauge
    state_topic: "weather/pressure_mbar"
    value_template: '{{ value | round(0) }}'
    unit_of_measurement: "mBar"

  - platform: mqtt
    name: "Stopnja padavin"
    icon: mdi:umbrella-outline
    state_topic: "weather/rainRate_cm_per_hour"
    value_template: '{{ value | round(0) }}'
    unit_of_measurement: "mm/h"

  - platform: mqtt
    name: "Stopnja padavin (zadnja ura)"
    icon: mdi:umbrella
    state_topic: "weather/hourRain_cm"
    value_template: '{{ value | round(0) }}'
    unit_of_measurement: "mm/h"

  - platform: mqtt
    name: "Padavine (danes)"
    icon: mdi:umbrella
    state_topic: "weather/rain24_cm"
    value_template: '{{ value | round(0) }}'
    unit_of_measurement: "mm"

  - platform: mqtt
    name: "Temperatura"
    state_topic: "weather/outTemp_C"
    value_template: '{{ value | round(1) }}'
    unit_of_measurement: "°C"

  - platform: mqtt
    name: "Sončno sevanje"
    icon: mdi:radioactive
    state_topic: "weather/radiation_Wpm2"
    value_template: '{{ value | round(1) }}'
    unit_of_measurement: "watts/m²"

  - platform: mqtt
    name: "UV"
    icon: mdi:sunglasses
    state_topic: "weather/UV"
    value_template: '{{ value | round(1) }}'
    unit_of_measurement: "index"

  - platform: mqtt
    name: "Hitrost vetra"
    icon: mdi:weather-windy
    state_topic: "weather/windSpeed_kph"
    value_template: '{{ value | round(1) }}'
    unit_of_measurement: "km/h"

  - platform: mqtt
    name: "Sunek vetra"
    icon: mdi:weather-windy-variant
    state_topic: "weather/windGust_kph"
    value_template: '{{ value | round(1) }}'
    unit_of_measurement: "km/h"

  - platform: mqtt
    name: "Smer vetra"
    icon: mdi:wind-turbine
    state_topic: "weather/windDir"
    value_template: '{{ value | round(1) }}'
    unit_of_measurement: "°"

Code for notify in case of high UV:

- id: '709'
  alias: VREME - visoka vrednost UV sevanja
  trigger:
    platform: numeric_state
    entity_id: sensor.uv
    above: '8'
    for:
      minutes: 15
  action:
      - service: notify.MY_DEVICE
        data:
          message: "Zaznana visoka vrednost UV sevanja - vrednost UV nad 8 od skupaj možnih 16."
          title: "VREME - UV sevanje"
      - service: notify.MY_OTHER_DEVICE
        data:
          message: "Zaznana visoka vrednost UV sevanja - vrednost UV nad 8 od skupaj možnih 16."
          title: "VREME - UV sevanje"

Some useful links:




https://jackstromberg.com/2018/06/setting-up-weewx-with-a-raspberry-pi/
http://weewx.com/docs/usersguide.htm
http://weewx.com/docs/debian.htm

Enjoy…