Weather Station Data

Yea, I figured out…

When I will have everything ready I will publish complete code…

I don’t suppose anyone has used the data being returned by their weather station and managed to build something that determines whether or not its raining right now?

If you can get the total rain data value and store that every five minutes in an internal HA mqtt sensor topic, then test that value against the one five minutes later it should give you rain amount inside that window.
I have this in my setup to do daily rain based on the total cumulative value sent by my station, but I can’t see why in principal it couldn’t be done every few minutes…

  - platform: mqtt
    state_topic: 'ha/total_rain_prior'
    name: 'rain_total_prior'
    unit_of_measurement: 'mm'
    value_template: '{{ value_json.day_1 }}' 
  - platform: template
    sensors:
      rain:
        value_template: '{%- if not (is_state("sensor.rain_register","unknown") or is_state("sensor.rain_total_prior","unknown") )-%}  {{ ((states.sensor.rain_register.state | float) - (states.sensor.rain_total_prior.state | float)) | max (0) | round(1) }} {%- endif -%}' ## ensure calc is no lower than zero!
        friendly_name: 'Rain from 9AM today'
        unit_of_measurement: 'mm'

Or just use the trend sensor https://www.home-assistant.io/components/trend/

And it eliminates more mqtt, a winner :slight_smile:

1 Like

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…

10 Likes

Had a similar issue, and couldn’t get weewx to work, so I used node-red instead…

1 Like

If you want I can give you Virtualization station which can be used in QNAP or VMWare Player etc… you should only set up MQTT data and IP of Raspbian OS and voila…

Database can be used as MySQL on external server or local - based on settings…

I’m using on MySQL on QNAP NAS…

hi,thanks for ur work,are your files no longer available
?

It would be great to have an addon or an integration in hacs for weewx, nobody knows something?

I can republish files… if you need I can give you complete Image for QNAP NAS with complete working ecosystem…

1 Like

Thanks again, im using the old hassio in docker with Ubuntu, I’m not sure if it will work for me

Hi, I would like to give this a go! I checked and the files you uploaded are no longer there also I do have a QNAP as well as a Synology. I am currently running HA in a Container on the Synology I was running WeeWx on a Pi 4 and getting the data from a Davis IP Data Logger.
I would like to get HA and WeeWx running on the same box either in a container or VM.
Thanks for your help !
Mark

Today I will prepeare file… Sorry for delay, I was away…

Hi Were you able to get to this? Thanks.

Prepearing file… Will publish download link tommorow…

Hi, now I managed to prepeare file and file server, so that you can download it.

So, open website:
www.vseznalec.si
Username:
homeassistant
Password:
virtualclone2020_weeWX%

For your access click on “homeassistant” folder.

Then you can download image. Also when you will set up virtual station on QNAP you will find instructions.txt on desktop in virtual machine.

I hope that you will succed.

Got it! Thanks kslb!

Hey guys do I have this idea right about this code on Github I noticed ?
I’m not a coder of any note but this python code on Github seems to me to create a destination for any Ecowitt protocol compliant WiFi weather station like WH2900 or WS-2902 (and obviously the Ecowitt GW1000 gateway) on a RPi of to send data to, and then creates a .CSV file with the sent data ?

If that’s right, is it possible to get HA to look for the .CSV file updates and read the new station sensor values ?
https://github.com/iz0qwm/ecowitt_http_gateway/blob/2628beaee63d78c14a38de780024c71bb1deeb48/README.md

Why to use CSV if you can use weeWX MQTT protocol?