Skip to content

Commit

Permalink
Merge pull request #121 from astrandb/FloatErrors
Browse files Browse the repository at this point in the history
Remove float conversions and let None values through
  • Loading branch information
astrandb authored Jan 16, 2024
2 parents a5a02c8 + 3388454 commit ae71f51
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions custom_components/weatherlink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ def _preprocess(indata: str): # noqa: C901
0
][f"wet_leaf_{numb}"]
outdata[tx_id][DataKey.BAR_SEA_LEVEL] = sensor["data"][0]["bar"]
outdata[tx_id][DataKey.BAR_TREND] = (
float(sensor["data"][0].get("bar_trend", 0)) / 1000
)
if (xx := sensor["data"][0].get("bar_trend", 0)) is not None:
xx = xx / 1000
outdata[tx_id][DataKey.BAR_TREND] = xx
outdata[tx_id][DataKey.HUM_OUT] = sensor["data"][0]["hum_out"]
outdata[tx_id][DataKey.HUM_IN] = sensor["data"][0]["hum_in"]
outdata[tx_id][DataKey.WIND_MPH] = sensor["data"][0]["wind_speed"]
Expand All @@ -300,8 +300,8 @@ def _preprocess(indata: str): # noqa: C901
outdata[tx_id][DataKey.DEWPOINT] = sensor["data"][0]["dew_point"]
outdata[tx_id][DataKey.HEAT_INDEX] = sensor["data"][0]["heat_index"]
outdata[tx_id][DataKey.WIND_CHILL] = sensor["data"][0]["wind_chill"]
outdata[tx_id][DataKey.RAIN_DAY] = float(
sensor["data"][0].get("rain_day_in", 0)
outdata[tx_id][DataKey.RAIN_DAY] = sensor["data"][0].get(
"rain_day_in"
)
if (xx := sensor["data"][0].get("rain_storm_in", 0.0)) is None:
xx = 0.0
Expand Down

0 comments on commit ae71f51

Please sign in to comment.