SMHI hourly forecast

Hi,

I’ve been looking for a way to get a weather forecast, mainly temperature, with forecast for each hour for e.g. the next 24 or 48h. My plan is to use this in combination with energy spot prices to optimize running of a pool heater now that energy prices are soaring.

Today I mainly use the SMHI integration for weather forecasts, but this seems to be limited to daily forecasts. I’ve tried the OpenWeather integration but it doesn’t seem as accurate as SMHI for Sweden.

Any chance to add hourly forecast as an option to SMHI, perhaps selectable during setup?

I use met.no to retrieve some weather data and it is hourly.
I use Node-Red to get the data into a sensor.

[{"id":"bdd4adeb7b04a898","type":"http request","z":"3141b24f.cdcf76","name":"Met.no - København","method":"GET","ret":"obj","paytoqs":"body","url":"https://api.met.no/weatherapi/locationforecast/2.0/complete?lat=55.662&lon=12.553&altitude=52","tls":"","persist":false,"proxy":"","authType":"","x":660,"y":160,"wires":[["380ededeb0ccb638"]]},{"id":"bdc3a6502f0b89a7","type":"inject","z":"3141b24f.cdcf76","name":"Timed trigger","props":[],"repeat":"","crontab":"0 0-23 * * *","once":true,"onceDelay":"305","topic":"","x":180,"y":160,"wires":[["20b136f242386732"]]},{"id":"20b136f242386732","type":"function","z":"3141b24f.cdcf76","name":"set payload and headers","func":"msg.payload = \"data to post\";\nmsg.headers = {};\nmsg.headers['User-Agent'] = 'Node-Red v1.3.5';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":160,"wires":[["bdd4adeb7b04a898"]]},{"id":"380ededeb0ccb638","type":"change","z":"3141b24f.cdcf76","name":"Drop data","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload","tot":"msg"},{"t":"delete","p":"headers","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":160,"wires":[["0bc071f0cba574ab"]]},{"id":"0bc071f0cba574ab","type":"ha-entity","z":"3141b24f.cdcf76","name":"Weather Kobenhavn","server":"541ade28.b4a62","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Weather Kobenhavn"},{"property":"device_class","value":"weather"},{"property":"icon","value":"hass:weather-windy"},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"","stateType":"date","attributes":[{"property":"topic","value":"topic","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1040,"y":160,"wires":[[]]},{"id":"541ade28.b4a62","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":""}]

This is the data the sensor provide.
The forecast for the first 2-3 days have all data, but after that time some of them will dropped with certain intervals.
Since it is a current heating situation and not something, like planning a irrigation with future rain taken into account, then a 2-3 forecast should be plenty for you.

*** I had to insert only a partial of the sensor value, because the forum only accept 32000 chars and the sensor alone is actually over 100k chars. ***

device_class: weather
icon: hass:weather-windy
friendly_name: Weather Kobenhavn
topic: 
type: Feature
geometry:
  type: Point
  coordinates:
    - 12.553
    - 55.662
    - 52
properties:
  meta:
    updated_at: '2022-05-19T08:40:13Z'
    units:
      air_pressure_at_sea_level: hPa
      air_temperature: celsius
      air_temperature_max: celsius
      air_temperature_min: celsius
      air_temperature_percentile_10: celsius
      air_temperature_percentile_90: celsius
      cloud_area_fraction: '%'
      cloud_area_fraction_high: '%'
      cloud_area_fraction_low: '%'
      cloud_area_fraction_medium: '%'
      dew_point_temperature: celsius
      fog_area_fraction: '%'
      precipitation_amount: mm
      precipitation_amount_max: mm
      precipitation_amount_min: mm
      probability_of_precipitation: '%'
      probability_of_thunder: '%'
      relative_humidity: '%'
      ultraviolet_index_clear_sky: '1'
      wind_from_direction: degrees
      wind_speed: m/s
      wind_speed_of_gust: m/s
      wind_speed_percentile_10: m/s
      wind_speed_percentile_90: m/s
  timeseries:
    - time: '2022-05-19T09:00:00Z'
      data:
        instant:
          details:
            air_pressure_at_sea_level: 1018.1
            air_temperature: 19.3
            air_temperature_percentile_10: 18.6
            air_temperature_percentile_90: 20.4
            cloud_area_fraction: 99.9
            cloud_area_fraction_high: 99.9
            cloud_area_fraction_low: 0.4
            cloud_area_fraction_medium: 56.4
            dew_point_temperature: 14.4
            fog_area_fraction: 0
            relative_humidity: 69
            ultraviolet_index_clear_sky: 4.1
            wind_from_direction: 205.3
            wind_speed: 3.9
            wind_speed_of_gust: 8.6
            wind_speed_percentile_10: 2.3
            wind_speed_percentile_90: 4
        next_12_hours:
          summary:
            symbol_code: cloudy
            symbol_confidence: somewhat certain
          details:
            probability_of_precipitation: 24.4
        next_1_hours:
          summary:
            symbol_code: cloudy
          details:
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 3.8
            probability_of_thunder: 2.6
        next_6_hours:
          summary:
            symbol_code: cloudy
          details:
            air_temperature_max: 23.2
            air_temperature_min: 18.6
            precipitation_amount: 0
            precipitation_amount_max: 0.6
            precipitation_amount_min: 0
            probability_of_precipitation: 10.7
    - time: '2022-05-19T10:00:00Z'
      data:
        instant:
          details:
            air_pressure_at_sea_level: 1018.1
            air_temperature: 18.6
            air_temperature_percentile_10: 17.9
            air_temperature_percentile_90: 20.6
            cloud_area_fraction: 100
            cloud_area_fraction_high: 90.7
            cloud_area_fraction_low: 0.7
            cloud_area_fraction_medium: 99.7
            dew_point_temperature: 14.4
            fog_area_fraction: 0
            relative_humidity: 73.1
            ultraviolet_index_clear_sky: 4.8
            wind_from_direction: 192.8
            wind_speed: 3.8
            wind_speed_of_gust: 7.9
            wind_speed_percentile_10: 2.4
            wind_speed_percentile_90: 3.8
        next_12_hours:
          summary:
            symbol_code: cloudy
            symbol_confidence: uncertain
          details:
            probability_of_precipitation: 38.2
        next_1_hours:
          summary:
            symbol_code: cloudy
          details:
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 3.9
            probability_of_thunder: 2.6
        next_6_hours:
          summary:
            symbol_code: cloudy
          details:
            air_temperature_max: 23.2
            air_temperature_min: 19.6
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 9.9
    - time: '2022-05-19T11:00:00Z'
      data:
        instant:
          details:
            air_pressure_at_sea_level: 1018.1
            air_temperature: 19.6
            air_temperature_percentile_10: 19
            air_temperature_percentile_90: 22.3
            cloud_area_fraction: 97.8
            cloud_area_fraction_high: 80.9
            cloud_area_fraction_low: 1.2
            cloud_area_fraction_medium: 81.9
            dew_point_temperature: 15.1
            fog_area_fraction: 0
            relative_humidity: 70.4
            ultraviolet_index_clear_sky: 5.1
            wind_from_direction: 231.7
            wind_speed: 2.4
            wind_speed_of_gust: 7.5
            wind_speed_percentile_10: 1.5
            wind_speed_percentile_90: 3.6
        next_12_hours:
          summary:
            symbol_code: cloudy
            symbol_confidence: uncertain
          details:
            probability_of_precipitation: 44.2
        next_1_hours:
          summary:
            symbol_code: cloudy
          details:
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 1.1
            probability_of_thunder: 1.7
        next_6_hours:
          summary:
            symbol_code: cloudy
          details:
            air_temperature_max: 23.2
            air_temperature_min: 20.2
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 9.5
    - time: '2022-05-19T12:00:00Z'
      data:
        instant:
          details:
            air_pressure_at_sea_level: 1017.7
            air_temperature: 21.9
            air_temperature_percentile_10: 21.1
            air_temperature_percentile_90: 24.2
            cloud_area_fraction: 90.9
            cloud_area_fraction_high: 73.3
            cloud_area_fraction_low: 0.2
            cloud_area_fraction_medium: 62.2
            dew_point_temperature: 16.3
            fog_area_fraction: 0
            relative_humidity: 65.3
            ultraviolet_index_clear_sky: 4.7
            wind_from_direction: 183
            wind_speed: 2.2
            wind_speed_of_gust: 5.7
            wind_speed_percentile_10: 2.1
            wind_speed_percentile_90: 3.5
        next_12_hours:
          summary:
            symbol_code: partlycloudy_day
            symbol_confidence: uncertain
          details:
            probability_of_precipitation: 44.3
        next_1_hours:
          summary:
            symbol_code: cloudy
          details:
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 9.5
            probability_of_thunder: 1.8
        next_6_hours:
          summary:
            symbol_code: cloudy
          details:
            air_temperature_max: 23.2
            air_temperature_min: 19.5
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 9.5
    - time: '2022-05-19T13:00:00Z'
      data:
        instant:
          details:
            air_pressure_at_sea_level: 1017.3
            air_temperature: 23.2
            air_temperature_percentile_10: 20.7
            air_temperature_percentile_90: 24.2
            cloud_area_fraction: 98.5
            cloud_area_fraction_high: 98.3
            cloud_area_fraction_low: 3
            cloud_area_fraction_medium: 3.2
            dew_point_temperature: 16.8
            fog_area_fraction: 0
            relative_humidity: 63.2
            ultraviolet_index_clear_sky: 4
            wind_from_direction: 188.7
            wind_speed: 2.4
            wind_speed_of_gust: 5.4
            wind_speed_percentile_10: 2.1
            wind_speed_percentile_90: 3.6
        next_12_hours:
          summary:
            symbol_code: partlycloudy_day
            symbol_confidence: uncertain
          details:
            probability_of_precipitation: 43.1
        next_1_hours:
          summary:
            symbol_code: partlycloudy_day
          details:
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 6
            probability_of_thunder: 1.9
        next_6_hours:
          summary:
            symbol_code: cloudy
          details:
            air_temperature_max: 22.7
            air_temperature_min: 19.3
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 4.6
    - time: '2022-05-19T14:00:00Z'
      data:
        instant:
          details:
            air_pressure_at_sea_level: 1016.8
            air_temperature: 22.7
            air_temperature_percentile_10: 20.2
            air_temperature_percentile_90: 23.6
            cloud_area_fraction: 99.6
            cloud_area_fraction_high: 99.6
            cloud_area_fraction_low: 3.9
            cloud_area_fraction_medium: 9.5
            dew_point_temperature: 16.9
            fog_area_fraction: 0
            relative_humidity: 64.8
            ultraviolet_index_clear_sky: 3
            wind_from_direction: 75.1
            wind_speed: 2.6
            wind_speed_of_gust: 6.1
            wind_speed_percentile_10: 2.2
            wind_speed_percentile_90: 3.7
        next_12_hours:
          summary:
            symbol_code: partlycloudy_day
            symbol_confidence: uncertain
          details:
            probability_of_precipitation: 39.6
        next_1_hours:
          summary:
            symbol_code: partlycloudy_day
          details:
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 0
            probability_of_thunder: 2
        next_6_hours:
          summary:
            symbol_code: cloudy
          details:
            air_temperature_max: 22.6
            air_temperature_min: 18.2
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 8.5
    - time: '2022-05-19T15:00:00Z'
      data:
        instant:
          details:
            air_pressure_at_sea_level: 1015.9
            air_temperature: 22.6
            air_temperature_percentile_10: 19.5
            air_temperature_percentile_90: 23.6
            cloud_area_fraction: 99.8
            cloud_area_fraction_high: 99.8
            cloud_area_fraction_low: 0.9
            cloud_area_fraction_medium: 11.6
            dew_point_temperature: 16.1
            fog_area_fraction: 0
            relative_humidity: 63.8
            ultraviolet_index_clear_sky: 1.9
            wind_from_direction: 101.9
            wind_speed: 2.4
            wind_speed_of_gust: 5.7
            wind_speed_percentile_10: 1.8
            wind_speed_percentile_90: 3.4
        next_12_hours:
          summary:
            symbol_code: partlycloudy_day
            symbol_confidence: uncertain
          details:
            probability_of_precipitation: 39.8
        next_1_hours:
          summary:
            symbol_code: partlycloudy_day
          details:
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 0
            probability_of_thunder: 1.7
        next_6_hours:
          summary:
            symbol_code: cloudy
          details:
            air_temperature_max: 22.5
            air_temperature_min: 17.2
            precipitation_amount: 0
            precipitation_amount_max: 1
            precipitation_amount_min: 0
            probability_of_precipitation: 13.7
    - time: '2022-05-19T16:00:00Z'
      data:
        instant:
          details:
            air_pressure_at_sea_level: 1015.7
            air_temperature: 22.5
            air_temperature_percentile_10: 19.9
            air_temperature_percentile_90: 23.3
            cloud_area_fraction: 99.4
            cloud_area_fraction_high: 99.4
            cloud_area_fraction_low: 2.3
            cloud_area_fraction_medium: 15.6
            dew_point_temperature: 16
            fog_area_fraction: 0
            relative_humidity: 63.2
            ultraviolet_index_clear_sky: 1
            wind_from_direction: 58.9
            wind_speed: 1.2
            wind_speed_of_gust: 4.9
            wind_speed_percentile_10: 1.5
            wind_speed_percentile_90: 3
        next_12_hours:
          summary:
            symbol_code: partlycloudy_day
            symbol_confidence: uncertain
          details:
            probability_of_precipitation: 40
        next_1_hours:
          summary:
            symbol_code: cloudy
          details:
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 0
            probability_of_thunder: 2.5
        next_6_hours:
          summary:
            symbol_code: cloudy
          details:
            air_temperature_max: 20.2
            air_temperature_min: 16
            precipitation_amount: 0
            precipitation_amount_max: 1.9
            precipitation_amount_min: 0
            probability_of_precipitation: 32.2
    - time: '2022-05-19T17:00:00Z'
      data:
        instant:
          details:
            air_pressure_at_sea_level: 1015.2
            air_temperature: 20.2
            air_temperature_percentile_10: 19.3
            air_temperature_percentile_90: 22
            cloud_area_fraction: 94.6
            cloud_area_fraction_high: 94.1
            cloud_area_fraction_low: 0
            cloud_area_fraction_medium: 23.6
            dew_point_temperature: 15.1
            fog_area_fraction: 0
            relative_humidity: 68.9
            ultraviolet_index_clear_sky: 0.4
            wind_from_direction: 72.4
            wind_speed: 2.3
            wind_speed_of_gust: 4.5
            wind_speed_percentile_10: 1.8
            wind_speed_percentile_90: 2.7
        next_12_hours:
          summary:
            symbol_code: partlycloudy_day
            symbol_confidence: uncertain
          details:
            probability_of_precipitation: 40.2
        next_1_hours:
          summary:
            symbol_code: cloudy
          details:
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 0
            probability_of_thunder: 2.2
        next_6_hours:
          summary:
            symbol_code: partlycloudy_night
          details:
            air_temperature_max: 19.5
            air_temperature_min: 16
            precipitation_amount: 0
            precipitation_amount_max: 3.3
            precipitation_amount_min: 0
            probability_of_precipitation: 39.2
    - time: '2022-05-19T18:00:00Z'
      data:
        instant:
          details:
            air_pressure_at_sea_level: 1014.3
            air_temperature: 19.5
            air_temperature_percentile_10: 18.5
            air_temperature_percentile_90: 20.9
            cloud_area_fraction: 84.5
            cloud_area_fraction_high: 82.7
            cloud_area_fraction_low: 0
            cloud_area_fraction_medium: 9.4
            dew_point_temperature: 14.6
            fog_area_fraction: 0
            relative_humidity: 71.2
            ultraviolet_index_clear_sky: 0.1
            wind_from_direction: 116.2
            wind_speed: 1.8
            wind_speed_of_gust: 4.2
            wind_speed_percentile_10: 1.9
            wind_speed_percentile_90: 2.8
        next_12_hours:
          summary:
            symbol_code: partlycloudy_day
            symbol_confidence: uncertain
          details:
            probability_of_precipitation: 40.5
        next_1_hours:
          summary:
            symbol_code: partlycloudy_day
          details:
            precipitation_amount: 0
            precipitation_amount_max: 0
            precipitation_amount_min: 0
            probability_of_precipitation: 2.1
            probability_of_thunder: 1.7
        next_6_hours:
          summary:
            symbol_code: partlycloudy_night
          details:
            air_temperature_max: 19.3
            air_temperature_min: 16
            precipitation_amount: 0
            precipitation_amount_max: 3.3
            precipitation_amount_min: 0
            probability_of_precipitation: 39.2
    - time: '2022-05-19T19:00:00Z'
      data:
        instant:
          details:
            air_pressure_at_sea_level: 1013.5
            air_temperature: 19.3
            air_temperature_percentile_10: 17.3
            air_temperature_percentile_90: 20.1
            cloud_area_fraction: 79.7
            cloud_area_fraction_high: 65.8
            cloud_area_fraction_low: 0
            cloud_area_fraction_medium: 47.8
            dew_point_temperature: 14.6
            fog_area_fraction: 0
            relative_humidity: 71.4
            ultraviolet_index_clear_sky: 0
            wind_from_direction: 142.9
            wind_speed: 2.5
            wind_speed_of_gust: 4.3
            wind_speed_percentile_10: 1.9
            wind_speed_percentile_90: 2.9
        next_12_hours:
          summary:
            symbol_code: cloudy
            symbol_confidence: uncertain
          details:
            probability_of_precipitation: 40.5
        next_1_hours:
          summary:
            symbol_code: partlycloudy_night
          details:
            precipitation_amount: 0
            precipitation_amount_max: 0.3
            precipitation_amount_min: 0
            probability_of_precipitation: 11.8
            probability_of_thunder: 2.4
        next_6_hours:
          summary:
            symbol_code: partlycloudy_night
          details:
            air_temperature_max: 18.2
            air_temperature_min: 16
            precipitation_amount: 0
            precipitation_amount_max: 3.3
            precipitation_amount_min: 0
            probability_of_precipitation: 39.2
    - time: '2022-05-19T20:00:00Z'
      data:
        instant:
          details:
            air_pressure_at_sea_level: 1013
            air_temperature: 18.2
            air_temperature_percentile_10: 16.8
            air_temperature_percentile_90: 19.2
            cloud_area_fraction: 88.8
            cloud_area_fraction_high: 23
            cloud_area_fraction_low: 0.7
            cloud_area_fraction_medium: 85.8
            dew_point_temperature: 13.4
            fog_area_fraction: 0
            relative_humidity: 72.1
            ultraviolet_index_clear_sky: 0
            wind_from_direction: 161.7
            wind_speed: 2.8
            wind_speed_of_gust: 5.2
            wind_speed_percentile_10: 1.7
            wind_speed_percentile_90: 4.2
        next_12_hours:
          summary:
            symbol_code: cloudy
            symbol_confidence: uncertain
          details:
            probability_of_precipitation: 40.1
        next_1_hours:
          summary:
            symbol_code: cloudy
          details:
            precipitation_amount: 0
            precipitation_amount_max: 0.2
            precipitation_amount_min: 0
            probability_of_precipitation: 14.8
            probability_of_thunder: 4.6
        next_6_hours:
          summary:
            symbol_code: partlycloudy_night
          details:
            air_temperature_max: 18
            air_temperature_min: 15
            precipitation_amount: 0
            precipitation_amount_max: 2.5
            precipitation_amount_min: 0
            probability_of_precipitation: 39.1
    - time: '2022-05-19T21:00:00Z'
      data:
        instant:
          details:
            air_pressure_at_sea_level: 1012.7
            air_temperature: 17.2
            air_temperature_percentile_10: 15.9
            air_temperature_percentile_90: 18.8
            cloud_area_fraction: 89.8
            cloud_area_fraction_high: 3.3
            cloud_area_fraction_low: 2.4
            cloud_area_fraction_medium: 89.6
            dew_point_temperature: 12.4
            fog_area_fraction: 0
            relative_humidity: 71.4
            ultraviolet_index_clear_sky: 0
            wind_from_direction: 186.6
            wind_speed: 2.8
            wind_speed_of_gust: 4.9
            wind_speed_percentile_10: 1
            wind_speed_percentile_90: 4.3
        next_12_hours:
          summary:
            symbol_code: partlycloudy_day
            symbol_confidence: uncertain
          details:
            probability_of_precipitation: 33.1
        next_1_hours:
          summary:
            symbol_code: cloudy
          details:
            precipitation_amount: 0
            precipitation_amount_max: 1.1
            precipitation_amount_min: 0
            probability_of_precipitation: 33.3
            probability_of_thunder: 3.5
        next_6_hours:
          summary:
            symbol_code: partlycloudy_night
          details:
            air_temperature_max: 18
            air_temperature_min: 13.4
            precipitation_amount: 0
            precipitation_amount_max: 1.5
            precipitation_amount_min: 0
            probability_of_precipitation: 32.2
    - time: '2022-05-19T22:00:00Z'
      data:
        instant:
          details:
            air_pressure_at_sea_level: 1012.8
            air_temperature: 16
            air_temperature_percentile_10: 15.4
            air_temperature_percentile_90: 18.1
            cloud_area_fraction: 90.2
            cloud_area_fraction_high: 14
            cloud_area_fraction_low: 0
            cloud_area_fraction_medium: 88.2
            dew_point_temperature: 12.1
            fog_area_fraction: 0
            relative_humidity: 75.6
            ultraviolet_index_clear_sky: 0
            wind_from_direction: 221.9
            wind_speed: 3.6
            wind_speed_of_gust: 6.3
            wind_speed_percentile_10: 1.6
            wind_speed_percentile_90: 4.1
        next_12_hours:
          summary:
            symbol_code: partlycloudy_day
            symbol_confidence: somewhat certain
          details:
            probability_of_precipitation: 15.7
        next_1_hours:
          summary:
            symbol_code: cloudy
          details:
            precipitation_amount: 0
            precipitation_amount_max: 0.7
            precipitation_amount_min: 0
            probability_of_precipitation: 20.5
            probability_of_thunder: 3.7
        next_6_hours:
          summary:
            symbol_code: partlycloudy_night
          details:
            air_temperature_max: 18
            air_temperature_min: 13.3
            precipitation_amount: 0
            precipitation_amount_max: 0.7
            precipitation_amount_min: 0
            probability_of_precipitation: 15.5

Thanks for the tip!
Looks like SMHI has a similar json return format that I could try, if I do not want use met.no.
I’ve never used Node-Red but I guess I could use the rest platform directly in a sensor to achieve the same results, unless using Node-Red is much easier?

My Node-Red flow is just straight through, so no departures or anything, which should make it quite easy to handle in other ways.
It is only the “authentication” part that can be a bit tricky, since met.no require a user agent entry in the header when making the http request.

Node-Red is extremely easy to use, especially when you want more complicated things to happen.
I do not think my heating system could be handled in HA and I would for sure lose the big picture view with only text.
This is how it looks in Node-Red for one room.

But Node-Red can also shine in more simple things, like when I tried to set up a ping sensor for each of my device on the network.
I wanted the device to be pinged 4 times and then get an average and a packetloss number.
I tried in HA only and actually got the script to work, but the pings then all occured on top of each other and that affected the ping times in the result.
Now I have a Node-Red flow that handle it for me. it pings one device at a time with 4 pings make the calculations and create a sensor with the result, then it continues to the next device and so on until there are no more devices left, at which point it simply starts over.
I can add new devices with just a name entry and an IP address.
This looks like this.

It is especially these abilities that make Node-Red powerful.

  • split a flow, which would be the same as one script starts to sub-scripts in HA
  • reuse flows or part of flows easily, like one flow just connect to some part of another flow and thereby reuse that functionality.
  • loop flows, where a flow goes back to itself and thereby create loops
  • extremely easy condtions, even for complicated things, where the basic nodes can handle almost everything, but more complex nodes are often available for certain situations, that just makes it even so much simpler.

I ended up not using the NodeRed approach. It seemed a bit overkill to me.
Instread I used the Rest integration. This however was also not a straight road since the JSON response from SMHI is a bit “quirky”. An example is found here: SMHI Open Data API Docs - Meteorological Forecasts

What I really wanted was just a list of all forecast times and temperatures. But the SMHI data is not really built for easy setup in Home Assistant :slight_smile:
I saw two approaches:

  1. To make one sensor for each forecasted hour with time as value and temp as attribute and then use those to make a list of values
  2. Just make a sensor with the complete JSON response as attribute and then manage it in my python scripts (which I intended to use anyway in the next step of my automation).

It would’ve been nice to be able to get the data using JSONPath directly as an attribute, since e.g. it would be available using e.g.

$.timeSeries[*].parameters[?(@.name == 't')].values[0]

But I couldn’t figure out how to do that since json_attributes in the rest sensors requires a key to be defined…

So, I ended up using approach no. 2.

For the sensor, I used:

rest:
  - scan_interval: 3600
    resource: https://opendata-download-metfcst.smhi.se/api/category/pmp3g/version/2/geotype/point/lon/XXX/lat/YYY/data.json
    sensor:
      - name: "SMHI all"
        value_template: "OK"
        json_attributes:
          - "timeSeries"

Then, in python, I used list comprehension to make a list from the attributes of the sensor:

time_list = [time['validTime'] for time in sensor.smhi_all.timeSeries]
temp_list = [val for time in sensor.smhi_all.timeSeries for param in time['parameters'] if param['name'] == "t" for val in param['values']]

Now the next step will be to use this data to calculate when to run my pool heater in the cheapest way possible, but that’s another topic.

In case anyone wants to use the API and Node red then this should give you a sensor with the hourly temperatures.

[{"id":"e8c4886bfa53473a","type":"debug","z":"4eb25acf17389316","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":510,"y":660,"wires":[]},{"id":"fba7c704f5e5ed3a","type":"inject","z":"4eb25acf17389316","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{   \"approvedTime\":\"2015-10-12T05:13:19Z\",   \"referenceTime\":\"2015-10-12T03:00:00Z\",   \"geometry\":{     \"type\":\"Point\",     \"coordinates\":[       [         16.017767,         57.999628       ]     ]   },   \"timeSeries\":[     {       \"validTime\":\"2015-10-12T04:00:00Z\",       \"parameters\":[         {           \"name\":\"msl\",           \"levelType\":\"hmsl\",           \"level\":0,           \"values\":[             1031           ]         },         {           \"name\":\"t\",           \"levelType\":\"hl\",           \"level\":2,           \"values\":[             3.1           ]         },         {           \"name\":\"vis\",           \"levelType\":\"hl\",           \"level\":2,           \"values\":[             18           ]         },         {           \"name\":\"wd\",           \"levelType\":\"hl\",           \"level\":10,           \"values\":[             26           ]         },         {           \"name\":\"ws\",           \"levelType\":\"hl\",           \"level\":10,           \"values\":[             0.2           ]         },         {           \"name\":\"r\",           \"levelType\":\"hl\",           \"level\":2,           \"values\":[             95           ]         },         {           \"name\":\"tstm\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         },         {           \"name\":\"tcc_mean\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             6           ]         },         {           \"name\":\"lcc_mean\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             6           ]         },         {           \"name\":\"mcc_mean\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         },         {           \"name\":\"hcc_mean\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         },         {           \"name\":\"gust\",           \"levelType\":\"hl\",           \"level\":10,           \"values\":[             1.1           ]         },         {           \"name\":\"pmin\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         },         {           \"name\":\"pmax\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         },         {           \"name\":\"spp\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             -9           ]         },         {           \"name\":\"pcat\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         },         {           \"name\":\"pmean\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         },         {           \"name\":\"pmedian\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         }       ]     },     {       \"validTime\":\"2015-10-12T05:00:00Z\",       \"parameters\":[         {           \"name\":\"msl\",           \"levelType\":\"hmsl\",           \"level\":0,           \"values\":[             1030           ]         },         {           \"name\":\"t\",           \"levelType\":\"hl\",           \"level\":2,           \"values\":[             3.4           ]         },         {           \"name\":\"vis\",           \"levelType\":\"hl\",           \"level\":2,           \"values\":[             16           ]         },         {           \"name\":\"wd\",           \"levelType\":\"hl\",           \"level\":10,           \"values\":[             99           ]         },         {           \"name\":\"ws\",           \"levelType\":\"hl\",           \"level\":10,           \"values\":[             0.7           ]         },         {           \"name\":\"r\",           \"levelType\":\"hl\",           \"level\":2,           \"values\":[             95           ]         },         {           \"name\":\"tstm\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         },         {           \"name\":\"tcc_mean\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             7           ]         },         {           \"name\":\"lcc_mean\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             7           ]         },         {           \"name\":\"mcc_mean\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         },         {           \"name\":\"hcc_mean\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         },         {           \"name\":\"gust\",           \"levelType\":\"hl\",           \"level\":10,           \"values\":[             2           ]         },         {           \"name\":\"pmin\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         },         {           \"name\":\"pmax\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         },         {           \"name\":\"spp\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             -9           ]         },         {           \"name\":\"pcat\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         },         {           \"name\":\"pmean\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         },         {           \"name\":\"pmedian\",           \"levelType\":\"hl\",           \"level\":0,           \"values\":[             0           ]         }       ]     }   ] }","payloadType":"json","x":170,"y":700,"wires":[["31505c357280d0ec"]]},{"id":"31505c357280d0ec","type":"function","z":"4eb25acf17389316","name":"","func":"var array = {};\nvar time = \"\";\n\nfor (var index in msg.payload.timeSeries) {\n    for (var val in msg.payload.timeSeries[index].parameters) {\n        time = msg.payload.timeSeries[index].validTime;\n        if (msg.payload.timeSeries[index].parameters[val][\"name\"] == \"t\"){\n            array[time] = msg.payload.timeSeries[index].parameters[val].values[0]\n        }\n    }\n}\n\nmsg.arr = array;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":700,"wires":[["e8c4886bfa53473a","fae9c841252a3911"]]},{"id":"fae9c841252a3911","type":"ha-entity","z":"4eb25acf17389316","name":"smhi hourly","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"smhi hourly"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload.approvedTime","stateType":"msg","attributes":[{"property":"hourly","value":"arr","valueType":"msg"}],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":530,"y":760,"wires":[[]]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

I just used an inject with the example json, but if you use an http request on the json endpoint then it should give all the current data.
image

Very nice!

This is great! Going to try it out! Is there somewhere in the api where we can get the severe weather alerts as well? Would be awesome to have that in HA. The custom integration that was supporting this does not seem to be updated.

Don’t know.
Read the API documentation.

Is it possible to fetch estimated temperature data for the hole day and present it in apexchart?

Don’t know about the chart but the temperature is in the API

image

Temperature is t in the API response

Need some help here. I have never used node-red so can’t get it to work. I only get value for 2015 in my sensor. Do I need a automation to fetch value from the node-red automation?

I don’t understand what you are saying.
What do you mean by 2015?

I can upload my current smhi sequence later

This is what I use currently:

[{"id":"8584052db0255346","type":"http request","z":"ad594fb84fe6d294","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://opendata-download-metfcst.smhi.se/api/category/pmp3g/version/2/geotype/point/lon/xxxxxxx/lat/xxxxxxx/data.json","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"credentials":{},"x":310,"y":120,"wires":[["baaeb67025c3b042"]]},{"id":"994a4699a32ef4ec","type":"inject","z":"ad594fb84fe6d294","name":"","props":[{"p":"payload"}],"repeat":"7200","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":150,"y":120,"wires":[["8584052db0255346"]]},{"id":"baaeb67025c3b042","type":"function","z":"ad594fb84fe6d294","name":"","func":"var array = {};\nvar time = \"\";\n\ntime = new Date(msg.payload.approvedTime);\nvar offset = time.getTimezoneOffset(); \ntime = new Date(time.getTime() - (offset*60*1000)); \nmsg.state = time.toISOString().replace(\"T\", \" \").substring(0,16)\n\n\nfor (var index in msg.payload.timeSeries.slice(0,67)) {\n    time = new Date(msg.payload.timeSeries[index].validTime);\n    offset = time.getTimezoneOffset();\n    time = new Date(time.getTime() - (offset * 60 * 1000)); \n\n    array[time.toISOString().replace(\"T\", \" \").substring(0, 16)] = { \"temp\": 0, \"wind\": 0, \"gust\": 0, \"nederbord\": 0, \"symbol\" : 0 };\n    for (var val in msg.payload.timeSeries[index].parameters) {\n        if (msg.payload.timeSeries[index].parameters[val][\"name\"] == \"t\") {\n            array[time.toISOString().replace(\"T\", \" \").substring(0, 16)].temp = msg.payload.timeSeries[index].parameters[val].values[0];   //  { \"temp\": Math.round(msg.payload.timeSeries[index].parameters[val].values[0]) }\n        }else if (msg.payload.timeSeries[index].parameters[val][\"name\"] == \"ws\"){\n            array[time.toISOString().replace(\"T\", \" \").substring(0,16)].wind =  msg.payload.timeSeries[index].parameters[val].values[0];  \n        }else if (msg.payload.timeSeries[index].parameters[val][\"name\"] == \"gust\"){\n            array[time.toISOString().replace(\"T\", \" \").substring(0,16)].gust =  msg.payload.timeSeries[index].parameters[val].values[0];  \n        }else if (msg.payload.timeSeries[index].parameters[val][\"name\"] == \"pmax\") {\n            array[time.toISOString().replace(\"T\", \" \").substring(0, 16)].nederbord = msg.payload.timeSeries[index].parameters[val].values[0];  \n        } else if (msg.payload.timeSeries[index].parameters[val][\"name\"] == \"Wsymb2\") {\n            array[time.toISOString().replace(\"T\", \" \").substring(0, 16)].symbol = msg.payload.timeSeries[index].parameters[val].values[0];\n        }\n    }\n}\n\nmsg.arr = array;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":160,"wires":[["deb8fd1153e98ceb","aeb70bcf74c928d9"]]},{"id":"deb8fd1153e98ceb","type":"debug","z":"ad594fb84fe6d294","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":690,"y":80,"wires":[]},{"id":"aeb70bcf74c928d9","type":"ha-entity","z":"ad594fb84fe6d294","name":"smhi hourly","server":"4bbca37b.1700ec","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"smhi hourly"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"state","stateType":"msg","attributes":[{"property":"hourly","value":"arr","valueType":"msg"}],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":670,"y":180,"wires":[[]]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
2 Likes

Thanks!
Never used node-red and not sure if i did it right (sorry).
I have put in my long ang lat, should change something else.
I get unknown in my sensor.

I answer myself. The problem was that i use coordinates XX.XXXXX and XX.XXXXX. I should only use XX and XX.

Thanks for the code.

Big thank you for this example code!

Fungerar perfekt :smile:

Hi,
I try to read out the cloudiness values from SMHI.
Can see from doc. that there is four different parameters

image

Have added the SMHI to the Integrations
But I don’t manage to read out this values to sensor
Have following code

      smhi_cloudiness_mean:
        friendly_name: SMHI mean cloudiness
        value_template: "{{ state_attr( 'weather.smhi_vasteras', 'tcc_mean') }}"

When I try to show this value in the UI, I get “Unknown”

image

What am I doing wrong ?