Crall

SMHI forecast sensor

Dec 17th, 2025 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.21 KB | None | 0 0
  1. *****OBS, skall ligga under template: ******
  2.  
  3.  
  4. #SMHI forecast sensorer
  5.   - trigger:
  6.       - trigger: time_pattern
  7.         hours: "/1"  # Uppdatera varje timme
  8.       - trigger: homeassistant
  9.         event: start # Uppdatera vid omstart
  10.  
  11.     action:
  12.      # 1. Hämta Dygnsprognos (Daily)
  13.       - action: weather.get_forecasts
  14.         data:
  15.           type: daily
  16.         target:
  17.           entity_id: weather.smhi_home
  18.         response_variable: daily_data
  19.  
  20.       # 2. Hämta Timprognos (Hourly)
  21.       - action: weather.get_forecasts
  22.         data:
  23.           type: hourly
  24.         target:
  25.           entity_id: weather.smhi_home
  26.         response_variable: hourly_data
  27.  
  28.     sensor:
  29.      # --- SENSOR 1: IDAG (Dygn) ---
  30.       - name: "SMHI Idag"
  31.         unique_id: smhi_home_today
  32.         icon: mdi:calendar-today
  33.         state: >
  34.          {{ daily_data['weather.smhi_home'].forecast[0].condition }}
  35.         attributes:
  36.           temp_max: >
  37.            {{ daily_data['weather.smhi_home'].forecast[0].temperature }}
  38.           temp_min: >
  39.            {{ daily_data['weather.smhi_home'].forecast[0].templow }}
  40.           nederbord: >
  41.            {{ daily_data['weather.smhi_home'].forecast[0].precipitation }}
  42.           vindhastighet: >
  43.            {{ daily_data['weather.smhi_home'].forecast[0].wind_speed }}
  44.           vindriktning: >
  45.            {{ daily_data['weather.smhi_home'].forecast[0].wind_bearing }}
  46.           luftfuktighet: >
  47.            {{ daily_data['weather.smhi_home'].forecast[0].humidity }}
  48.           datum: >
  49.            {{ daily_data['weather.smhi_home'].forecast[0].datetime }}
  50.  
  51.       # --- SENSOR 2: IMORGON (Dygn) ---
  52.       - name: "SMHI Imorgon"
  53.         unique_id: smhi_home_tomorrow
  54.         icon: mdi:calendar-arrow-right
  55.         state: >
  56.          {{ daily_data['weather.smhi_home'].forecast[1].condition }}
  57.         attributes:
  58.           temp_max: >
  59.            {{ daily_data['weather.smhi_home'].forecast[1].temperature }}
  60.           temp_min: >
  61.            {{ daily_data['weather.smhi_home'].forecast[1].templow }}
  62.           nederbord: >
  63.            {{ daily_data['weather.smhi_home'].forecast[1].precipitation }}
  64.           vindhastighet: >
  65.            {{ daily_data['weather.smhi_home'].forecast[1].wind_speed }}
  66.           vindriktning: >
  67.            {{ daily_data['weather.smhi_home'].forecast[1].wind_bearing }}
  68.           luftfuktighet: >
  69.            {{ daily_data['weather.smhi_home'].forecast[1].humidity }}
  70.           datum: >
  71.            {{ daily_data['weather.smhi_home'].forecast[1].datetime }}
  72.  
  73.       # --- SENSOR 3: NÄSTA TIMME (Hourly) ---
  74.       - name: "SMHI Nästa Timme"
  75.         unique_id: smhi_home_next_hour
  76.         icon: mdi:clock-outline
  77.         state: >
  78.          {{ hourly_data['weather.smhi_home'].forecast[0].condition }}
  79.         attributes:
  80.           temperatur: >
  81.            {{ hourly_data['weather.smhi_home'].forecast[0].temperature }}
  82.           nederbord: >
  83.            {{ hourly_data['weather.smhi_home'].forecast[0].precipitation }}
  84.           vindhastighet: >
  85.            {{ hourly_data['weather.smhi_home'].forecast[0].wind_speed }}
  86.           # Hämtar alla timmar
  87.           alla_timmar: >
  88.            {{ hourly_data['weather.smhi_home'].forecast }}
Advertisement
Add Comment
Please, Sign In to add comment