Here is the solution to keep “HomeMade” sensor data for a longer time. Motivation: I have my own dragino Lorawan Sensor configurations and my weatherstation (vantage pro) and wanted to keep this data longer than the default ten days. You find a lot of outdated informations for older HA Versions, that recommend installing new databses, different systems, whatever. This might be a way, but I think it is outdated. With the help of Tom, I did the following for my Vantage Weatherstation and my dragino Lorawan devices:
To get a better overview over such configutations, I suggest to split them up in “Packages”, as shown here Packages - Home Assistant and NOT filling up the configuration.yaml more and more, as still described in many places.
So my configuration.yaml has this
homeassistant:
packages: !include_dir_named "packages"
in the very first lines, and than I have the directory “packages
”, which looks like
The configuration for “some” (the ones I need) sensors of the Vantage pro is in the vantage_pro.yaml
(Beware, if you are like me and don’t read all information immediately, there HAS to be the underscore in the filename, and “-” (minus) is forbidden!
In my scenario my Vantage is reachable thru the ethernet wifi gateway, this is reachable at IP http://192.168.90.146. Change this below accordingly. You might call the url below, but depending on the webbrowser you won’t see anything, or get the json data to see.
The content of this file is:
# Description of Vantage pro weather staion API
# https://weatherlink.github.io/weatherlink-live-local-api/
sensor:
- name: davis_vantage_pro_curr
platform: rest
resource: "http://192.168.90.146/v1/current_conditions"
json_attributes:
- data
value_template: "Vantage Pro"
template:
- sensor:
- name: "Vantage Temperatur Heubergweg"
unique_id: vantage_temp
device_class: temperature
state_class: measurement # <- generates LTS (long term statistics)
unit_of_measurement: "°F"
state: '{{ (state_attr("sensor.davis_vantage_pro_curr", "data")["conditions"][0]["temp"] | float * 100) | round / 100 }}'
availability: '{{ state_attr("sensor.davis_vantage_pro_curr", "data")["conditions"][0]["temp"] | is_number }}'
- sensor:
- name: "Wind-Gesch"
unique_id: vantage_wind_speed
device_class: wind_speed
state_class: measurement # <- generates LTS (long term statistics)
unit_of_measurement: "km/h"
state: '{{ ((state_attr("sensor.davis_vantage_pro_curr", "data")["conditions"][0]["wind_speed_avg_last_2_min"] | float * 160.934)) | round / 100}}'
availability: '{{ state_attr("sensor.davis_vantage_pro_curr", "data")["conditions"][0]["temp"] | is_number }}'
- sensor:
- name: "Regen (1 Min)"
unique_id: vantage_rain_1
device_class: water
state_class: measurement # <- generates LTS (long term statistics)
unit_of_measurement: "L"
state: '{{ ((state_attr("sensor.davis_vantage_pro_curr", "data")["conditions"][0]["rain_rate_hi"] | float * 20)) | round / 100}}'
- sensor:
- name: "Regen (60 Min)"
unique_id: vantage_rain_60
device_class: water
state_class: measurement # <- generates LTS (long term statistics)
unit_of_measurement: "L"
state: '{{ ((state_attr("sensor.davis_vantage_pro_curr", "data")["conditions"][0]["rainfall_last_60_min"] | float * 20)) | round / 100}}'
- sensor:
- name: "Regen (24h)"
unique_id: vantage_rain_24
device_class: water
state_class: measurement # <- generates LTS (long term statistics)
unit_of_measurement: "L"
state: '{{ ((state_attr("sensor.davis_vantage_pro_curr", "data")["conditions"][0]["rainfall_last_24_hr"] | float * 20)) | round / 100}}'
- sensor:
- name: "Feuchtigkeit"
unique_id: vantage_hum
device_class: humidity
state_class: measurement # <- generates LTS (long term statistics)
unit_of_measurement: "%"
state: '{{ ((state_attr("sensor.davis_vantage_pro_curr", "data")["conditions"][0]["hum"] | float * 100)) | round / 100 }}'
- sensor:
- name: "Windchill"
unique_id: vantage_wind_chill
device_class: temperature
state_class: measurement # <- generates LTS (long term statistics)
unit_of_measurement: "°F"
state: '{{ ((state_attr("sensor.davis_vantage_pro_curr", "data")["conditions"][0]["wind_chill"] | float * 100)) |round / 100 }}'
which you might have to adapt, if you want non metric values. And which you definitely do have to translate, if you are a non germans speaker.
I hope this helps others.
Again: Many thanks Tom
all the best
Juergen