8383 ATTR_CONDITION_EXCEPTIONAL ,
8484}
8585
86- CONF_WEATHER = "weather"
87- CONF_TEMPERATURE_TEMPLATE = "temperature_template"
88- CONF_HUMIDITY_TEMPLATE = "humidity_template"
89- CONF_CONDITION_TEMPLATE = "condition_template"
86+ CONF_APPARENT_TEMPERATURE_TEMPLATE = "apparent_temperature_template"
9087CONF_ATTRIBUTION_TEMPLATE = "attribution_template"
91- CONF_PRESSURE_TEMPLATE = "pressure_template"
92- CONF_WIND_SPEED_TEMPLATE = "wind_speed_template"
93- CONF_WIND_BEARING_TEMPLATE = "wind_bearing_template"
94- CONF_OZONE_TEMPLATE = "ozone_template"
95- CONF_UV_INDEX_TEMPLATE = "uv_index_template"
96- CONF_VISIBILITY_TEMPLATE = "visibility_template"
88+ CONF_CLOUD_COVERAGE_TEMPLATE = "cloud_coverage_template"
89+ CONF_CONDITION_TEMPLATE = "condition_template"
90+ CONF_DEW_POINT_TEMPLATE = "dew_point_template"
9791CONF_FORECAST_DAILY_TEMPLATE = "forecast_daily_template"
9892CONF_FORECAST_HOURLY_TEMPLATE = "forecast_hourly_template"
9993CONF_FORECAST_TWICE_DAILY_TEMPLATE = "forecast_twice_daily_template"
94+ CONF_HUMIDITY_TEMPLATE = "humidity_template"
95+ CONF_OZONE_TEMPLATE = "ozone_template"
96+ CONF_PRECIPITATION_UNIT = "precipitation_unit"
97+ CONF_PRESSURE_TEMPLATE = "pressure_template"
10098CONF_PRESSURE_UNIT = "pressure_unit"
101- CONF_WIND_SPEED_UNIT = "wind_speed_unit"
99+ CONF_TEMPERATURE_TEMPLATE = "temperature_template"
100+ CONF_UV_INDEX_TEMPLATE = "uv_index_template"
101+ CONF_VISIBILITY_TEMPLATE = "visibility_template"
102102CONF_VISIBILITY_UNIT = "visibility_unit"
103- CONF_PRECIPITATION_UNIT = "precipitation_unit"
103+ CONF_WEATHER = "weather"
104+ CONF_WIND_BEARING_TEMPLATE = "wind_bearing_template"
104105CONF_WIND_GUST_SPEED_TEMPLATE = "wind_gust_speed_template"
105- CONF_CLOUD_COVERAGE_TEMPLATE = "cloud_coverage_template"
106- CONF_DEW_POINT_TEMPLATE = "dew_point_template"
107- CONF_APPARENT_TEMPERATURE_TEMPLATE = "apparent_temperature_template"
106+ CONF_WIND_SPEED_TEMPLATE = "wind_speed_template"
107+ CONF_WIND_SPEED_UNIT = "wind_speed_unit"
108108
109109DEFAULT_NAME = "Template Weather"
110110
@@ -198,51 +198,51 @@ def __init__(
198198 """Initialize the Template weather."""
199199 super ().__init__ (hass , config , unique_id )
200200
201- self ._condition_template = config [ CONF_CONDITION_TEMPLATE ]
202- self . _temperature_template = config [ CONF_TEMPERATURE_TEMPLATE ]
203- self . _humidity_template = config [ CONF_HUMIDITY_TEMPLATE ]
201+ self ._apparent_temperature_template = config . get (
202+ CONF_APPARENT_TEMPERATURE_TEMPLATE
203+ )
204204 self ._attribution_template = config .get (CONF_ATTRIBUTION_TEMPLATE )
205- self ._pressure_template = config .get (CONF_PRESSURE_TEMPLATE )
206- self ._wind_speed_template = config .get (CONF_WIND_SPEED_TEMPLATE )
207- self ._wind_bearing_template = config .get (CONF_WIND_BEARING_TEMPLATE )
208- self ._ozone_template = config .get (CONF_OZONE_TEMPLATE )
209- self ._uv_index_template = config .get (CONF_UV_INDEX_TEMPLATE )
210- self ._visibility_template = config .get (CONF_VISIBILITY_TEMPLATE )
205+ self ._cloud_coverage_template = config .get (CONF_CLOUD_COVERAGE_TEMPLATE )
206+ self ._condition_template = config [CONF_CONDITION_TEMPLATE ]
207+ self ._dew_point_template = config .get (CONF_DEW_POINT_TEMPLATE )
211208 self ._forecast_daily_template = config .get (CONF_FORECAST_DAILY_TEMPLATE )
212209 self ._forecast_hourly_template = config .get (CONF_FORECAST_HOURLY_TEMPLATE )
213210 self ._forecast_twice_daily_template = config .get (
214211 CONF_FORECAST_TWICE_DAILY_TEMPLATE
215212 )
213+ self ._humidity_template = config [CONF_HUMIDITY_TEMPLATE ]
214+ self ._ozone_template = config .get (CONF_OZONE_TEMPLATE )
215+ self ._pressure_template = config .get (CONF_PRESSURE_TEMPLATE )
216+ self ._temperature_template = config [CONF_TEMPERATURE_TEMPLATE ]
217+ self ._uv_index_template = config .get (CONF_UV_INDEX_TEMPLATE )
218+ self ._visibility_template = config .get (CONF_VISIBILITY_TEMPLATE )
219+ self ._wind_bearing_template = config .get (CONF_WIND_BEARING_TEMPLATE )
216220 self ._wind_gust_speed_template = config .get (CONF_WIND_GUST_SPEED_TEMPLATE )
217- self ._cloud_coverage_template = config .get (CONF_CLOUD_COVERAGE_TEMPLATE )
218- self ._dew_point_template = config .get (CONF_DEW_POINT_TEMPLATE )
219- self ._apparent_temperature_template = config .get (
220- CONF_APPARENT_TEMPERATURE_TEMPLATE
221- )
221+ self ._wind_speed_template = config .get (CONF_WIND_SPEED_TEMPLATE )
222222
223223 self ._attr_native_precipitation_unit = config .get (CONF_PRECIPITATION_UNIT )
224224 self ._attr_native_pressure_unit = config .get (CONF_PRESSURE_UNIT )
225225 self ._attr_native_temperature_unit = config .get (CONF_TEMPERATURE_UNIT )
226226 self ._attr_native_visibility_unit = config .get (CONF_VISIBILITY_UNIT )
227227 self ._attr_native_wind_speed_unit = config .get (CONF_WIND_SPEED_UNIT )
228228
229- self ._condition = None
230- self ._temperature = None
231- self ._humidity = None
229+ self ._apparent_temperature = None
232230 self ._attribution = None
233- self ._pressure = None
234- self ._wind_speed = None
235- self ._wind_bearing = None
236- self ._ozone = None
237- self ._uv_index = None
238- self ._visibility = None
239- self ._wind_gust_speed = None
240231 self ._cloud_coverage = None
232+ self ._condition = None
241233 self ._dew_point = None
242- self ._apparent_temperature = None
243234 self ._forecast_daily : list [Forecast ] = []
244235 self ._forecast_hourly : list [Forecast ] = []
245236 self ._forecast_twice_daily : list [Forecast ] = []
237+ self ._humidity = None
238+ self ._ozone = None
239+ self ._pressure = None
240+ self ._temperature = None
241+ self ._uv_index = None
242+ self ._visibility = None
243+ self ._wind_bearing = None
244+ self ._wind_gust_speed = None
245+ self ._wind_speed = None
246246
247247 self ._attr_supported_features = 0
248248 if self ._forecast_daily_template :
@@ -340,46 +340,72 @@ def attribution(self) -> str | None:
340340 def _async_setup_templates (self ) -> None :
341341 """Set up templates."""
342342
343+ if self ._apparent_temperature_template :
344+ self .add_template_attribute (
345+ "_apparent_temperature" ,
346+ self ._apparent_temperature_template ,
347+ )
348+ if self ._attribution_template :
349+ self .add_template_attribute (
350+ "_attribution" ,
351+ self ._attribution_template ,
352+ )
353+ if self ._cloud_coverage_template :
354+ self .add_template_attribute (
355+ "_cloud_coverage" ,
356+ self ._cloud_coverage_template ,
357+ )
343358 if self ._condition_template :
344359 self .add_template_attribute (
345360 "_condition" ,
346361 self ._condition_template ,
347362 lambda condition : condition if condition in CONDITION_CLASSES else None ,
348363 )
349- if self ._temperature_template :
364+ if self ._dew_point_template :
350365 self .add_template_attribute (
351- "_temperature" ,
352- self ._temperature_template ,
366+ "_dew_point" ,
367+ self ._dew_point_template ,
368+ )
369+ if self ._forecast_daily_template :
370+ self .add_template_attribute (
371+ "_forecast_daily" ,
372+ self ._forecast_daily_template ,
373+ on_update = partial (self ._update_forecast , "daily" ),
374+ validator = partial (self ._validate_forecast , "daily" ),
375+ )
376+ if self ._forecast_hourly_template :
377+ self .add_template_attribute (
378+ "_forecast_hourly" ,
379+ self ._forecast_hourly_template ,
380+ on_update = partial (self ._update_forecast , "hourly" ),
381+ validator = partial (self ._validate_forecast , "hourly" ),
382+ )
383+ if self ._forecast_twice_daily_template :
384+ self .add_template_attribute (
385+ "_forecast_twice_daily" ,
386+ self ._forecast_twice_daily_template ,
387+ on_update = partial (self ._update_forecast , "twice_daily" ),
388+ validator = partial (self ._validate_forecast , "twice_daily" ),
353389 )
354390 if self ._humidity_template :
355391 self .add_template_attribute (
356392 "_humidity" ,
357393 self ._humidity_template ,
358394 )
359- if self ._attribution_template :
395+ if self ._ozone_template :
360396 self .add_template_attribute (
361- "_attribution " ,
362- self ._attribution_template ,
397+ "_ozone " ,
398+ self ._ozone_template ,
363399 )
364400 if self ._pressure_template :
365401 self .add_template_attribute (
366402 "_pressure" ,
367403 self ._pressure_template ,
368404 )
369- if self ._wind_speed_template :
370- self .add_template_attribute (
371- "_wind_speed" ,
372- self ._wind_speed_template ,
373- )
374- if self ._wind_bearing_template :
375- self .add_template_attribute (
376- "_wind_bearing" ,
377- self ._wind_bearing_template ,
378- )
379- if self ._ozone_template :
405+ if self ._temperature_template :
380406 self .add_template_attribute (
381- "_ozone " ,
382- self ._ozone_template ,
407+ "_temperature " ,
408+ self ._temperature_template ,
383409 )
384410 if self ._uv_index_template :
385411 self .add_template_attribute (
@@ -391,47 +417,20 @@ def _async_setup_templates(self) -> None:
391417 "_visibility" ,
392418 self ._visibility_template ,
393419 )
420+ if self ._wind_bearing_template :
421+ self .add_template_attribute (
422+ "_wind_bearing" ,
423+ self ._wind_bearing_template ,
424+ )
394425 if self ._wind_gust_speed_template :
395426 self .add_template_attribute (
396427 "_wind_gust_speed" ,
397428 self ._wind_gust_speed_template ,
398429 )
399- if self ._cloud_coverage_template :
400- self .add_template_attribute (
401- "_cloud_coverage" ,
402- self ._cloud_coverage_template ,
403- )
404- if self ._dew_point_template :
405- self .add_template_attribute (
406- "_dew_point" ,
407- self ._dew_point_template ,
408- )
409- if self ._apparent_temperature_template :
410- self .add_template_attribute (
411- "_apparent_temperature" ,
412- self ._apparent_temperature_template ,
413- )
414-
415- if self ._forecast_daily_template :
416- self .add_template_attribute (
417- "_forecast_daily" ,
418- self ._forecast_daily_template ,
419- on_update = partial (self ._update_forecast , "daily" ),
420- validator = partial (self ._validate_forecast , "daily" ),
421- )
422- if self ._forecast_hourly_template :
423- self .add_template_attribute (
424- "_forecast_hourly" ,
425- self ._forecast_hourly_template ,
426- on_update = partial (self ._update_forecast , "hourly" ),
427- validator = partial (self ._validate_forecast , "hourly" ),
428- )
429- if self ._forecast_twice_daily_template :
430+ if self ._wind_speed_template :
430431 self .add_template_attribute (
431- "_forecast_twice_daily" ,
432- self ._forecast_twice_daily_template ,
433- on_update = partial (self ._update_forecast , "twice_daily" ),
434- validator = partial (self ._validate_forecast , "twice_daily" ),
432+ "_wind_speed" ,
433+ self ._wind_speed_template ,
435434 )
436435
437436 super ()._async_setup_templates ()
0 commit comments