How to setup a DIY home weather station

I have a simple DIY weather station I built that has WiFi. The weather station returns a simple JSON string with a get request:
“{“time”:1738039811, “voltage”:7408, “current”:28, “temperature”:-792, “humidity”:8344, “pressure”:2906, “light”:0}”.
I have a web page on this device that can access this information and display it.

I thought it would be easy enough to build this page in Home Assistant but after a couple of days at looking through the docs and examples found no such simple application. Apparently, this product is too complex to handle something this simple.
At least I expected someone had already setup an example project that was close.
Right now I have a Raspberry Pi Zero running python code that polls this device every hour and displays a graph of the data.


This was simple enough to setup with python and some java script code.

Where is the simple example of setting something like this up in Home Assistant?
Mike

Hi Michael.

Gut reaction is to use a REST request to get the JSON payload from your weather station.

Then use a template to take each of the values from the JSON and assign it to a value in HA, probably using the time value as a common key.

It’s waaaay more complicated, but Troon’s example of using REST to get data from the Met Office might point you in the right direction.

Not sure if you have MQTT or Node-Red available, but they might make bits easier.

Edit: Added links to REST & Template

Far too complicated, that example :smiley: .

This should be dead simple, guessing at some of the units:

rest:
  - resource: PI JSON URL HERE
    sensor:
      - name: WS voltage
        value_template: "{{ value_json['voltage'] }}"
        device_class: voltage
        unit_of_measurement: 'mV'
      - name: WS current
        value_template: "{{ value_json['current'] }}"
        device_class: current
        unit_of_measurement: 'mA'
      - name: WS temperature
        value_template: "{{ value_json['temperature']/100 }}"
        device_class: temperature
        unit_of_measurement: '°C'
      - name: WS humidity
        value_template: "{{ value_json['humidity']/100 }}"
        device_class: humidity
        unit_of_measurement: '%'
      - name: WS humidity
        value_template: "{{ value_json['pressure']/100 }}"
        device_class: pressure
        unit_of_measurement: 'inHg'
      - name: WS illuminance
        value_template: "{{ value_json['light'] }}"
        device_class: illuminance
        unit_of_measurement: 'lx'

Did I need more 'a’s in the waaaay? :laughing:

As usual - nice solution.

1 Like

Once you have the sensors in HA there are many cards you can use for a weather dashboard. I like using the following:

compass card
windrose card
apex charts.

I didn’t realize I would have to DIY it in HA. Kind of scary to add that code to the configuration file.
added this code:

rest:
  - resource: http://101.1.1.210/weather
    scan_interval: 900
    sensor:
      - name: WS voltage
        value_template: "{{ value_json.voltage / 1000 }}"
        device_class: voltage
        unit_of_measurement: ' V'
      - name: WS current
        value_template: "{{ value_json.current }}"
        device_class: current
        unit_of_measurement: 'mA'
      - name: WS temperature
        value_template: "{{ value_json.temperature * 9 / 500 + 32 }}"
        device_class: temperature
        unit_of_measurement: ' F'
      - name: WS humidity
        value_template: "{{ value_json.humidity / 100 }}"
        device_class: humidity
        unit_of_measurement: '%'
      - name: WS pressure
        value_template: "{{ value_json.pressure / 100 }}"
        device_class: pressure
        unit_of_measurement: 'inHg'
      - name: WS illuminance 
        value_template: "{{ value_json.light }}"
        device_class: illuminance
        unit_of_measurement: 'lux'
      - name: WS Time
        value_template: "{{ as_datetime(value_json.time, default) }}"
        device_class: timestamp
        unit_of_measurement: 's'

Didn’t know what template meant. Thought it was some kind of page you had to write.
Now I have this ugly sensor area that I need to figure out:
image

Mike

Did you expect HA to magically support your own DIY weather station?

This is the beauty of HA: as long as you have some sort of readable data, HA can be configured to pull it in. From there, you can do what you want with it.

As a side note, if your weather station supported MQTT auto-discovery, it could have been magically supported without configuration…

Are you using non-RFC1918 addresses on your LAN?!

@Troon
The web device is pretty basic and only supports defining a URL to process a request from and then passes it to the microcontroller on the back side.

Due have a website running on the network that is pin holed into one of my servers though.

I guess I thought there would be a GUI that would ask me about the URL and what data is being return and build the YAML for me.

Happy I didn’t have to write an integration though.

Mike