Commit e46e311 1 parent b501acc commit e46e311 Copy full SHA for e46e311
File tree 1 file changed +15
-14
lines changed
custom_components/dwd_weather
1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -224,8 +224,8 @@ def get_condition(self):
224
224
now = datetime .now (timezone .utc )
225
225
condition = self .dwd_weather .get_forecast_condition (now , False )
226
226
if condition == "sunny" and (
227
- now .hour < self .sun .riseutc (now . day ).hour
228
- or now .hour > self .sun .setutc (now . day ).hour
227
+ now .hour < self .sun .riseutc (now ).hour
228
+ or now .hour > self .sun .setutc (now ).hour
229
229
):
230
230
condition = "clear-night"
231
231
return condition
@@ -254,24 +254,25 @@ def get_weather_value(self, data_type: WeatherDataType):
254
254
shouldUpdate = False ,
255
255
)
256
256
257
- if self ._config [CONF_INTERPOLATE ]:
257
+ if self ._config [CONF_INTERPOLATE ] and value is not None :
258
258
now_time_actual = datetime .now (timezone .utc )
259
259
next_value = self .dwd_weather .get_forecast_data (
260
260
data_type ,
261
261
now_time_actual + timedelta (hours = 1 ),
262
262
shouldUpdate = False ,
263
263
)
264
- now_time_hour = self .dwd_weather .strip_to_hour (now_time_actual ).replace (
265
- tzinfo = timezone .utc
266
- )
267
- value = round (
268
- value
269
- + (
270
- (next_value - value )
271
- * ((now_time_actual - now_time_hour ).seconds / 3600 )
272
- ),
273
- 2 ,
274
- )
264
+ if next_value is not None :
265
+ now_time_hour = self .dwd_weather .strip_to_hour (now_time_actual ).replace (
266
+ tzinfo = timezone .utc
267
+ )
268
+ value = round (
269
+ value
270
+ + (
271
+ (next_value - value )
272
+ * ((now_time_actual - now_time_hour ).seconds / 3600 )
273
+ ),
274
+ 2 ,
275
+ )
275
276
276
277
data_type_mapping = {
277
278
WeatherDataType .TEMPERATURE : lambda x : round (x - 273.1 , 1 ),
You can’t perform that action at this time.
0 commit comments