Reading weather.homeassistant's forecast from grafana

Hi,

I pipe data from HA to influxdb and visualize in grafana

influxdb:
  host: a0d7b954-influxdb
  port: 8086
  database: homeassistant
  username: homeassistant
  password: !secret influxdb
  max_retries: 3
  default_measurement: state
  include:
    entities:
      - weather.homeassistant

but I failed miserably to visualize the weather forecast. Anyone an idea how to translate e.g.

state_attr('weather.homeassistant', 'forecast')[0].templow

(i.e. tomorrow’s low temp) to the grafana query of

SELECT mean("value") FROM "°C" WHERE ("entity_id" = 'some-magic-here') AND $timeFilter GROUP BY time(1d) fill(null)

without using a separate template sensor?

TIA, Stefan

1 Like

The following worked for me:

SELECT last("temperature") FROM "autogen"."state" WHERE ("entity_id"::tag='forecast_home') AND $timeFilter GROUP BY time($interval) FILL(none)

Requires the Meteorologisk institutt (Met.no) integration and did not need the ‘include: entities:…’ in my influxdb config. I worked it out by poking around influxdb where I stumbled upon the data. I then used the Query generated in influxdb as a starting point in Grafana. a few syntax changes later (following the grafana query from my sensors) and boom, it worked!

I included it on a graph of data from my temperature sensors
image
(FYI, the sensors are altogether in a box to check the calibration hence why they are close together)

2 Likes

@sharris - many thanks, this has allowed me to graph a loft installed dht22 temp and humidity sensor with the outside forecast temperature. The correlation between both sensor and forecast values give me confidence that my loft is actually well ventilated.