Loop load Jewish Calendar platforms (#70714)

This commit is contained in:
Yuval Aboulafia 2022-04-28 21:35:42 +03:00 committed by GitHub
parent d907eb2810
commit 70e8f81be1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View File

@ -11,6 +11,7 @@ from homeassistant.helpers.discovery import async_load_platform
from homeassistant.helpers.typing import ConfigType
DOMAIN = "jewish_calendar"
PLATFORMS: list[Platform] = [Platform.SENSOR, Platform.BINARY_SENSOR]
CONF_DIASPORA = "diaspora"
CONF_LANGUAGE = "language"
@ -67,6 +68,9 @@ def get_unique_prefix(
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Jewish Calendar component."""
if DOMAIN not in config:
return True
name = config[DOMAIN][CONF_NAME]
language = config[DOMAIN][CONF_LANGUAGE]
@ -97,12 +101,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"prefix": prefix,
}
hass.async_create_task(
async_load_platform(hass, Platform.SENSOR, DOMAIN, {}, config)
)
hass.async_create_task(
async_load_platform(hass, Platform.BINARY_SENSOR, DOMAIN, {}, config)
)
for platform in PLATFORMS:
hass.async_create_task(async_load_platform(hass, platform, DOMAIN, {}, config))
return True

View File

@ -24,7 +24,7 @@ from . import DOMAIN
_LOGGER = logging.getLogger(__name__)
DATA_SENSORS = (
INFO_SENSORS = (
SensorEntityDescription(
key="date",
name="Date",
@ -143,7 +143,7 @@ async def async_setup_platform(
sensors = [
JewishCalendarSensor(hass.data[DOMAIN], description)
for description in DATA_SENSORS
for description in INFO_SENSORS
]
sensors.extend(
JewishCalendarTimeSensor(hass.data[DOMAIN], description)