The Green Shed

Home Assistant Config for a Basic JSON REST Device

After much effort (and help from the forums), I was able to get a config working for my backyard weather station.

My station is custom built hardware, and returns a very simple JSON object with its current state when queried.

The json it returns looks like this: {"timestamp":"2022-03-12 09:35:36 -0700", "temperature_c":15.8720368908, "temperature_f":60.56966640344, "humidity":27.009330285, "pressure":965.103717974, "dewpoint_c":-3.0690760974329714, "dewpoint_f":26.47566302462065}

And this is the Home Assistant configuration I needed to use to get the data into HASS:

rest:
  - resource: http://weather.local
    scan_interval: 60
    sensor:
      - name: Weather Station - Temperature
        value_template: '{{ value_json.temperature_f | round(1) }}'
        unit_of_measurement: '°F'
        device_class: temperature
        state_class: measurement
      - name: Weather Station - Humidity
        value_template: '{{ value_json.humidity | round(1) }}'
        unit_of_measurement: '%'
        device_class: humidity
        state_class: measurement
      - name: Weather Station - Pressure
        value_template: '{{ value_json.pressure | round(1) }}'
        unit_of_measurement: 'mbar'
        device_class: atmospheric_pressure
        state_class: measurement
      - name: Weather Station - Dewpoint
        value_template: '{{ value_json.dewpoint_f | round(1) }}'
        unit_of_measurement: '°F'
        device_class: temperature
        state_class: measurement

Home Assistant is very powerful, but goodness is the learning curve steep. Documentation exists, but much of it is not helpful enough. I should probably contribute back some additional examples, at the least.

(Interesting side note: I asked ChatGPT to help me put together a configuration for this setup. It was able to do so, but the result was inefficient and used an older style of REST sensor setup. Human help in the forums led me to this solution.)