Skip to content

Commit

Permalink
Add V2.4 Sensors (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
cloneofghosts authored Oct 27, 2024
1 parent 2a3a4da commit 1b2535d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
3 changes: 3 additions & 0 deletions custom_components/pirateweather/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@
"hrrr_18_48_update_time": "HRRR 18-48 Update Time",
"gfs_update_time": "GFS Update Time",
"gefs_update_time": "GEFS Update Time",
"current_day_liquid": "Current Day Liquid Accumulation",
"current_day_snow": "Current Day Snow Accumulation",
"current_day_ice": "Current Day Ice Accumulation",
}

LANGUAGES = [
Expand Down
2 changes: 1 addition & 1 deletion custom_components/pirateweather/forecast_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _forcastio_data(self, key):
if key == "currently":
return ForecastioDataPoint(self.json[key])
return ForecastioDataBlock(self.json[key])
except requests.HTTPError:
except KeyError:
if key == "currently":
return ForecastioDataPoint()
return ForecastioDataBlock()
Expand Down
2 changes: 1 addition & 1 deletion custom_components/pirateweather/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"documentation": "https://github.com/alexander0042/pirate-weather-ha",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/alexander0042/pirate-weather-ha/issues",
"version": "1.6.0"
"version": "1.6.1"
}
50 changes: 49 additions & 1 deletion custom_components/pirateweather/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,48 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
icon="mdi:weather-snowy-rainy",
forecast_mode=["hourly", "daily"],
),
"current_day_liquid": PirateWeatherSensorEntityDescription(
key="current_day_liquid",
name="Current Day Liquid Accumulation",
device_class=SensorDeviceClass.PRECIPITATION,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfLength.CENTIMETERS,
us_unit=UnitOfLength.INCHES,
ca_unit=UnitOfLength.CENTIMETERS,
uk_unit=UnitOfLength.CENTIMETERS,
uk2_unit=UnitOfLength.CENTIMETERS,
suggested_display_precision=4,
icon="mdi:weather-rainy",
forecast_mode=["currently"],
),
"current_day_snow": PirateWeatherSensorEntityDescription(
key="current_day_snow",
name="Current Day Snow Accumulation",
device_class=SensorDeviceClass.PRECIPITATION,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfLength.CENTIMETERS,
us_unit=UnitOfLength.INCHES,
ca_unit=UnitOfLength.CENTIMETERS,
uk_unit=UnitOfLength.CENTIMETERS,
uk2_unit=UnitOfLength.CENTIMETERS,
suggested_display_precision=4,
icon="mdi:weather-snowy",
forecast_mode=["currently"],
),
"current_day_ice": PirateWeatherSensorEntityDescription(
key="current_day_ice",
name="Current Day Ice Accumulation",
device_class=SensorDeviceClass.PRECIPITATION,
state_class=SensorStateClass.MEASUREMENT,
si_unit=UnitOfLength.CENTIMETERS,
us_unit=UnitOfLength.INCHES,
ca_unit=UnitOfLength.CENTIMETERS,
uk_unit=UnitOfLength.CENTIMETERS,
uk2_unit=UnitOfLength.CENTIMETERS,
suggested_display_precision=4,
icon="mdi:weather-snowy-rainy",
forecast_mode=["currently"],
),
"temperature": PirateWeatherSensorEntityDescription(
key="temperature",
name="Temperature",
Expand Down Expand Up @@ -1178,13 +1220,16 @@ def get_state(self, data):
]:
state = round(state * 9 / 5) + 32

# Precipitation Accumilation (mm in SI) to inches
# Precipitation Accumilation (cm in SI) to inches
if self.requestUnits in ["us"]:
if self.type in [
"precip_accumulation",
"liquid_accumulation",
"snow_accumulation",
"ice_accumulation",
"current_day_liquid",
"current_day_snow",
"current_day_ice",
]:
state = state * 0.0393701

Expand Down Expand Up @@ -1269,6 +1314,9 @@ def get_state(self, data):
"ice_accumulation",
"precip_intensity",
"precip_intensity_max",
"current_day_liquid",
"current_day_snow",
"current_day_ice",
]:
outState = round(state, roundingPrecip)

Expand Down

1 comment on commit 1b2535d

@cloneofghosts
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently I got my versions mixed up. Should be 2.3.3 and not 2.4

Please sign in to comment.