Skip to content

Commit 1b2535d

Browse files
Add V2.4 Sensors (#335)
1 parent 2a3a4da commit 1b2535d

File tree

4 files changed

+54
-3
lines changed

4 files changed

+54
-3
lines changed

custom_components/pirateweather/const.py

+3
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@
135135
"hrrr_18_48_update_time": "HRRR 18-48 Update Time",
136136
"gfs_update_time": "GFS Update Time",
137137
"gefs_update_time": "GEFS Update Time",
138+
"current_day_liquid": "Current Day Liquid Accumulation",
139+
"current_day_snow": "Current Day Snow Accumulation",
140+
"current_day_ice": "Current Day Ice Accumulation",
138141
}
139142

140143
LANGUAGES = [

custom_components/pirateweather/forecast_models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def _forcastio_data(self, key):
7878
if key == "currently":
7979
return ForecastioDataPoint(self.json[key])
8080
return ForecastioDataBlock(self.json[key])
81-
except requests.HTTPError:
81+
except KeyError:
8282
if key == "currently":
8383
return ForecastioDataPoint()
8484
return ForecastioDataBlock()

custom_components/pirateweather/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"documentation": "https://github.com/alexander0042/pirate-weather-ha",
1010
"iot_class": "cloud_polling",
1111
"issue_tracker": "https://github.com/alexander0042/pirate-weather-ha/issues",
12-
"version": "1.6.0"
12+
"version": "1.6.1"
1313
}

custom_components/pirateweather/sensor.py

+49-1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,48 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
233233
icon="mdi:weather-snowy-rainy",
234234
forecast_mode=["hourly", "daily"],
235235
),
236+
"current_day_liquid": PirateWeatherSensorEntityDescription(
237+
key="current_day_liquid",
238+
name="Current Day Liquid Accumulation",
239+
device_class=SensorDeviceClass.PRECIPITATION,
240+
state_class=SensorStateClass.MEASUREMENT,
241+
si_unit=UnitOfLength.CENTIMETERS,
242+
us_unit=UnitOfLength.INCHES,
243+
ca_unit=UnitOfLength.CENTIMETERS,
244+
uk_unit=UnitOfLength.CENTIMETERS,
245+
uk2_unit=UnitOfLength.CENTIMETERS,
246+
suggested_display_precision=4,
247+
icon="mdi:weather-rainy",
248+
forecast_mode=["currently"],
249+
),
250+
"current_day_snow": PirateWeatherSensorEntityDescription(
251+
key="current_day_snow",
252+
name="Current Day Snow Accumulation",
253+
device_class=SensorDeviceClass.PRECIPITATION,
254+
state_class=SensorStateClass.MEASUREMENT,
255+
si_unit=UnitOfLength.CENTIMETERS,
256+
us_unit=UnitOfLength.INCHES,
257+
ca_unit=UnitOfLength.CENTIMETERS,
258+
uk_unit=UnitOfLength.CENTIMETERS,
259+
uk2_unit=UnitOfLength.CENTIMETERS,
260+
suggested_display_precision=4,
261+
icon="mdi:weather-snowy",
262+
forecast_mode=["currently"],
263+
),
264+
"current_day_ice": PirateWeatherSensorEntityDescription(
265+
key="current_day_ice",
266+
name="Current Day Ice Accumulation",
267+
device_class=SensorDeviceClass.PRECIPITATION,
268+
state_class=SensorStateClass.MEASUREMENT,
269+
si_unit=UnitOfLength.CENTIMETERS,
270+
us_unit=UnitOfLength.INCHES,
271+
ca_unit=UnitOfLength.CENTIMETERS,
272+
uk_unit=UnitOfLength.CENTIMETERS,
273+
uk2_unit=UnitOfLength.CENTIMETERS,
274+
suggested_display_precision=4,
275+
icon="mdi:weather-snowy-rainy",
276+
forecast_mode=["currently"],
277+
),
236278
"temperature": PirateWeatherSensorEntityDescription(
237279
key="temperature",
238280
name="Temperature",
@@ -1178,13 +1220,16 @@ def get_state(self, data):
11781220
]:
11791221
state = round(state * 9 / 5) + 32
11801222

1181-
# Precipitation Accumilation (mm in SI) to inches
1223+
# Precipitation Accumilation (cm in SI) to inches
11821224
if self.requestUnits in ["us"]:
11831225
if self.type in [
11841226
"precip_accumulation",
11851227
"liquid_accumulation",
11861228
"snow_accumulation",
11871229
"ice_accumulation",
1230+
"current_day_liquid",
1231+
"current_day_snow",
1232+
"current_day_ice",
11881233
]:
11891234
state = state * 0.0393701
11901235

@@ -1269,6 +1314,9 @@ def get_state(self, data):
12691314
"ice_accumulation",
12701315
"precip_intensity",
12711316
"precip_intensity_max",
1317+
"current_day_liquid",
1318+
"current_day_snow",
1319+
"current_day_ice",
12721320
]:
12731321
outState = round(state, roundingPrecip)
12741322

0 commit comments

Comments
 (0)