Skip to content

Commit

Permalink
Merge pull request #225 from Pirate-Weather/v2-features
Browse files Browse the repository at this point in the history
Sensors for V2 features
  • Loading branch information
cloneofghosts authored Apr 29, 2024
2 parents 4dd3a87 + 43db5dc commit b14eb9d
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ pythonenv*
venv
.venv
.coverage
*.db*
*.log*
.HA_VERSION
config/.storage/*
config/blueprints/*
7 changes: 7 additions & 0 deletions custom_components/pirateweather/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@
"nearest_storm_bearing": "Nearest Storm Bearing",
"alerts": "Alerts",
"time": "Time",
"fire_index": "Fire Index",
"fire_index_max": "Fire Index Max",
"smoke": "Smoke",
"smoke_max": "Smoke Max",
"liquid_accumulation": "Liquid Accumulation",
"snow_accumulation": "Snow Accumulation",
"ice_accumulation": "Ice Accumulation",
}

LANGUAGES = [
Expand Down
16 changes: 10 additions & 6 deletions custom_components/pirateweather/manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"domain": "pirateweather",
"name": "Pirate Weather",
"codeowners": ["@alexander0042"],
"codeowners": [
"@alexander0042"
],
"config_flow": true,
"dependencies": [],
"dependencies": [],
"documentation": "https://github.com/alexander0042/pirate-weather-ha",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/alexander0042/pirate-weather-ha/issues",
"requirements": ["python-forecastio==1.4.0"],
"version": "1.4.5.1"
}
"issue_tracker": "https://github.com/alexander0042/pirate-weather-ha/issues",
"requirements": [
"python-forecastio==1.4.0"
],
"version": "1.5"
}
89 changes: 89 additions & 0 deletions custom_components/pirateweather/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from homeassistant.const import (
ATTR_ATTRIBUTION,
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONF_API_KEY,
CONF_LATITUDE,
CONF_LONGITUDE,
Expand Down Expand Up @@ -194,6 +195,45 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
icon="mdi:weather-snowy",
forecast_mode=["hourly", "daily"],
),
"liquid_accumulation": PirateWeatherSensorEntityDescription(
key="liquid_accumulation",
name="Liquid Accumulation",
device_class=SensorDeviceClass.PRECIPITATION,
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=["hourly", "daily"],
),
"snow_accumulation": PirateWeatherSensorEntityDescription(
key="snow_accumulation",
name="Snow Accumulation",
device_class=SensorDeviceClass.PRECIPITATION,
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=["hourly", "daily"],
),
"ice_accumulation": PirateWeatherSensorEntityDescription(
key="ice_accumulation",
name="Ice Accumulation",
device_class=SensorDeviceClass.PRECIPITATION,
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=["hourly", "daily"],
),
"temperature": PirateWeatherSensorEntityDescription(
key="temperature",
name="Temperature",
Expand Down Expand Up @@ -333,6 +373,48 @@ class PirateWeatherSensorEntityDescription(SensorEntityDescription):
suggested_display_precision=2,
forecast_mode=["currently", "hourly", "daily"],
),
"fire_index": PirateWeatherSensorEntityDescription(
key="fire_index",
name="Fire Index",
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=2,
icon="mdi:fire",
forecast_mode=["currently", "hourly"],
),
"fire_index_max": PirateWeatherSensorEntityDescription(
key="fire_index_max",
name="Fire Index Max",
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=2,
icon="mdi:fire",
forecast_mode=["daily"],
),
"smoke": PirateWeatherSensorEntityDescription(
key="smoke",
name="Smoke",
device_class=SensorDeviceClass.PM25,
si_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
us_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
ca_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
uk_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
uk2_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
suggested_display_precision=2,
icon="mdi:smoke",
forecast_mode=["currently", "hourly"],
),
"smoke_max": PirateWeatherSensorEntityDescription(
key="smoke_max",
name="Smoke Max",
device_class=SensorDeviceClass.PM25,
si_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
us_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
ca_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
uk_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
uk2_unit=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
suggested_display_precision=2,
icon="mdi:smoke",
forecast_mode=["daily"],
),
"apparent_temperature_max": PirateWeatherSensorEntityDescription(
key="apparent_temperature_max",
name="Daily High Apparent Temperature",
Expand Down Expand Up @@ -1020,11 +1102,15 @@ def get_state(self, data):
"apparent_temperature_max",
"pressure",
"ozone",
"fire_index",
"fire_index_max",
"uv_index",
"wind_speed",
"wind_gust",
"visibility",
"nearest_storm_distance",
"smoke",
"smoke_max",
]:
if roundingVal == 0:
outState = int(round(state, roundingVal))
Expand All @@ -1033,6 +1119,9 @@ def get_state(self, data):

elif self.type in [
"precip_accumulation",
"liquid_accumulation",
"snow_accumulation",
"ice_accumulation",
"precip_intensity",
"precip_intensity_max",
]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def _get_pw_weather(self):
+ "?units="
+ self.requested_units
+ "&extend=hourly"
+ "&tz=precise"
+ "&version=2"
)

async with (
Expand Down
Empty file modified scripts/develop
100644 → 100755
Empty file.
Empty file modified scripts/setup
100644 → 100755
Empty file.

0 comments on commit b14eb9d

Please sign in to comment.