Added Alexa Music
This commit is contained in:
@@ -18,6 +18,8 @@ from homeassistant.const import (
|
||||
CONF_SCAN_INTERVAL,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType
|
||||
|
||||
from .const import (
|
||||
CONF_ENDPOINT,
|
||||
@@ -28,6 +30,7 @@ from .const import (
|
||||
DOMAIN,
|
||||
ENTRY_NAME,
|
||||
ENTRY_WEATHER_COORDINATOR,
|
||||
MANUFACTURER,
|
||||
PLATFORMS,
|
||||
PW_PLATFORM,
|
||||
PW_PLATFORMS,
|
||||
@@ -146,6 +149,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
CONF_MODELS: models,
|
||||
}
|
||||
|
||||
device_registry = dr.async_get(hass)
|
||||
device_registry.async_get_or_create(
|
||||
config_entry_id=entry.entry_id,
|
||||
entry_type=DeviceEntryType.SERVICE,
|
||||
identifiers={(DOMAIN, entry.unique_id or entry.entry_id)},
|
||||
manufacturer=MANUFACTURER,
|
||||
name=name,
|
||||
)
|
||||
|
||||
# Setup platforms
|
||||
# If both platforms
|
||||
if (PW_PLATFORMS[0] in pw_entity_platform) and (
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
@@ -112,6 +112,7 @@ ALL_CONDITIONS = {
|
||||
"apparent_temperature_low": "Apparent Temperature Low",
|
||||
"precip_intensity_max": "Precip Intensity Max",
|
||||
"uv_index": "UV Index",
|
||||
"air_quality_index": "Air Quality Index",
|
||||
"moon_phase": "Moon Phase",
|
||||
"sunrise_time": "Sunrise Time",
|
||||
"sunset_time": "Sunset Time",
|
||||
|
||||
@@ -10,5 +10,5 @@
|
||||
"integration_type": "service",
|
||||
"iot_class": "cloud_polling",
|
||||
"issue_tracker": "https://github.com/alexander0042/pirate-weather-ha/issues",
|
||||
"version": "1.8.9"
|
||||
"version": "1.9.0"
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ from homeassistant.const import (
|
||||
UnitOfVolumetricFlux,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import DiscoveryInfoType, StateType
|
||||
from homeassistant.util import dt as dt_util
|
||||
@@ -44,6 +45,7 @@ from .const import (
|
||||
DEFAULT_SCAN_INTERVAL,
|
||||
DOMAIN,
|
||||
ENTRY_WEATHER_COORDINATOR,
|
||||
MANUFACTURER,
|
||||
PW_PLATFORM,
|
||||
PW_PLATFORMS,
|
||||
PW_PREVPLATFORM,
|
||||
@@ -631,6 +633,15 @@ SENSOR_TYPES: dict[str, PirateWeatherSensorEntityDescription] = {
|
||||
icon="mdi:weather-sunny",
|
||||
forecast_mode=["currently", "hourly", "daily"],
|
||||
),
|
||||
"air_quality_index": PirateWeatherSensorEntityDescription(
|
||||
key="air_quality_index",
|
||||
name="Air Quality Index",
|
||||
device_class=SensorDeviceClass.AQI,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
suggested_display_precision=0,
|
||||
icon="mdi:air-filter",
|
||||
forecast_mode=["currently", "hourly", "daily"],
|
||||
),
|
||||
"cape": PirateWeatherSensorEntityDescription(
|
||||
key="cape",
|
||||
name="Convective Available Potential Energy",
|
||||
@@ -1020,6 +1031,7 @@ async def async_setup_entry(
|
||||
conditions = domain_data[CONF_MONITORED_CONDITIONS]
|
||||
forecast_days = domain_data[CONF_FORECAST]
|
||||
forecast_hours = domain_data[CONF_HOURLY_FORECAST]
|
||||
service_id = config_entry.unique_id or config_entry.entry_id
|
||||
|
||||
# Round Output
|
||||
outputRound = domain_data[PW_ROUND]
|
||||
@@ -1051,6 +1063,7 @@ async def async_setup_entry(
|
||||
description=sensorDescription,
|
||||
requestUnits=requestUnits,
|
||||
outputRound=outputRound,
|
||||
service_id=service_id,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1070,6 +1083,7 @@ async def async_setup_entry(
|
||||
description=sensorDescription,
|
||||
requestUnits=requestUnits,
|
||||
outputRound=outputRound,
|
||||
service_id=service_id,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1089,6 +1103,7 @@ async def async_setup_entry(
|
||||
description=sensorDescription,
|
||||
requestUnits=requestUnits,
|
||||
outputRound=outputRound,
|
||||
service_id=service_id,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1113,6 +1128,7 @@ class PirateWeatherSensor(SensorEntity):
|
||||
description: PirateWeatherSensorEntityDescription,
|
||||
requestUnits: str,
|
||||
outputRound: str,
|
||||
service_id: str,
|
||||
) -> None:
|
||||
"""Initialize the sensor."""
|
||||
self.client_name = name
|
||||
@@ -1124,13 +1140,12 @@ class PirateWeatherSensor(SensorEntity):
|
||||
|
||||
self._attr_unique_id = unique_id
|
||||
self._attr_name = name
|
||||
|
||||
# self._attr_device_info = DeviceInfo(
|
||||
# entry_type=DeviceEntryType.SERVICE,
|
||||
# identifiers={(DOMAIN, unique_id)},
|
||||
# manufacturer=MANUFACTURER,
|
||||
# name=DEFAULT_NAME,
|
||||
# )
|
||||
self._attr_device_info = DeviceInfo(
|
||||
entry_type=DeviceEntryType.SERVICE,
|
||||
identifiers={(DOMAIN, service_id)},
|
||||
manufacturer=MANUFACTURER,
|
||||
name=name,
|
||||
)
|
||||
|
||||
self.forecast_day = forecast_day
|
||||
self.forecast_hour = forecast_hour
|
||||
@@ -1370,6 +1385,7 @@ class PirateWeatherSensor(SensorEntity):
|
||||
"fire_index",
|
||||
"fire_index_max",
|
||||
"uv_index",
|
||||
"air_quality_index",
|
||||
"wind_speed",
|
||||
"wind_gust",
|
||||
"visibility",
|
||||
|
||||
@@ -39,6 +39,7 @@ from homeassistant.const import (
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
||||
from homeassistant.util.dt import utc_from_timestamp
|
||||
@@ -50,6 +51,7 @@ from .const import (
|
||||
DOMAIN,
|
||||
ENTRY_WEATHER_COORDINATOR,
|
||||
FORECAST_MODES,
|
||||
MANUFACTURER,
|
||||
PW_PLATFORM,
|
||||
PW_PLATFORMS,
|
||||
PW_PREVPLATFORM,
|
||||
@@ -262,12 +264,13 @@ async def async_setup_entry(
|
||||
forecast_mode = domain_data[CONF_MODE]
|
||||
|
||||
unique_id = f"{config_entry.unique_id}"
|
||||
service_id = config_entry.unique_id or config_entry.entry_id
|
||||
|
||||
# Round Output
|
||||
outputRound = domain_data[PW_ROUND]
|
||||
|
||||
pw_weather = PirateWeather(
|
||||
name, unique_id, forecast_mode, weather_coordinator, outputRound
|
||||
name, unique_id, forecast_mode, weather_coordinator, outputRound, service_id
|
||||
)
|
||||
|
||||
async_add_entities([pw_weather], False)
|
||||
@@ -292,10 +295,17 @@ class PirateWeather(SingleCoordinatorWeatherEntity[WeatherUpdateCoordinator]):
|
||||
forecast_mode: str,
|
||||
weather_coordinator: WeatherUpdateCoordinator,
|
||||
outputRound: str,
|
||||
service_id: str,
|
||||
) -> None:
|
||||
"""Initialize the sensor."""
|
||||
super().__init__(weather_coordinator)
|
||||
self._attr_name = name
|
||||
self._attr_device_info = DeviceInfo(
|
||||
entry_type=DeviceEntryType.SERVICE,
|
||||
identifiers={(DOMAIN, service_id)},
|
||||
manufacturer=MANUFACTURER,
|
||||
name=name,
|
||||
)
|
||||
self._weather_coordinator = weather_coordinator
|
||||
self._name = name
|
||||
self._mode = forecast_mode
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Weather data coordinator for the Pirate Weather service."""
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
import async_timeout
|
||||
from aiohttp import ClientError
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
@@ -61,7 +61,7 @@ class WeatherUpdateCoordinator(DataUpdateCoordinator):
|
||||
async def _async_update_data(self):
|
||||
"""Update the data."""
|
||||
data = {}
|
||||
async with async_timeout.timeout(60):
|
||||
async with asyncio.timeout(60):
|
||||
try:
|
||||
data = await self._get_pw_weather()
|
||||
except ClientError as err:
|
||||
|
||||
Reference in New Issue
Block a user