Create new sensor with temperature forecast data

Hi all,

I want to visualize the forecasted temperature in Grafana which is provided by the met.no HA integration (see below) that stores data in InfluxDB.

Does somebody have a good idea how to realize that? I explored:

  • An automation that manually writes data into InfluxDB → Doesn’t exist?
  • A new sensor with future time stamps → Doesn’t work with HA?
  • Any other ideas?

Thanks!

How the origin attributes of the met.no sensor looks like:

temperature: -8
dew_point: -8.9

forecast:

  • condition: partlycloudy
    datetime: “2024-01-12T11:00:00+00:00”
    temperature: -2.3
  • condition: cloudy
    datetime: “2024-01-13T11:00:00+00:00”
    temperature: -2

Desired outcome: Show the forecasted temperature in Grafana like this

Here is the doc on creating this sensor
Template - Home Assistant (home-assistant.io)

Explain what you mean, with examples of sensor state and attributes.

template:
  - sensor:
      - name: Forecast 0
        state: "{{ state_attr('weather.ENTITY_ID', 'forecast')[0]['temperature'] }}"
        unit_of_measurement: "°C"

      - name: Forecast 1
        state: "{{ state_attr('weather.ENTITY_ID', 'forecast')[1]['temperature'] }}"
        unit_of_measurement: "°C"

      - name: Forecast 2
        state: "{{ state_attr('weather.ENTITY_ID', 'forecast')[2]['temperature'] }}"
        unit_of_measurement: "°C"

Not sure what you mean by “with the respective dates”, which is why I asked for an example. Date as an attribute?

Typically, plotting forward data in e.g. Grafana is not something HA is designed for, or good at.

Hi Troon,

thanks for offering your help! Maybe it’s not even possible, but the aim was to get a sensor like this:

value: 3 → See note below
state_class: measurement
unit_of_measurement: °C
device_class: temperature
friendly_name: Daily Forecast

And for values, I don’t only want to store past values, but directly the forecast data for the next 7 days. And here I am stuck, since I’m not sure if that’s even possible.

Is it clearer now? Sorry I struggle a bit to explain the thing :smiley:

Hi Troon,

thanks you very much - This could work, I haven’t thought of creating different sensors, each for one future day!

The data get’s stored in InfluxDB and then accessed by Grafana. So the only piece missing is giving each sensor a forced time-stamp so that the value of each sensor get’s shown as a different future day in Grafana (that’s what I mean with “with the respective dates”.

And that’s the difficult bit. HA is not made to do that. You’ll have to go deep into SQL and the database.

Thanks Troon for clarifying!

Goal is to show a temperature forecast in Grafana like below. I’m now exploring if an automation could manually write future values in the InfluxDB Temperature sensor - But seems there is no InfluxDB write service :frowning:

If anybody has an idea, let me know! :slight_smile: