mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Loop load Jewish Calendar platforms (#70714)
This commit is contained in:
parent
d907eb2810
commit
70e8f81be1
@ -11,6 +11,7 @@ from homeassistant.helpers.discovery import async_load_platform
|
|||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
DOMAIN = "jewish_calendar"
|
DOMAIN = "jewish_calendar"
|
||||||
|
PLATFORMS: list[Platform] = [Platform.SENSOR, Platform.BINARY_SENSOR]
|
||||||
|
|
||||||
CONF_DIASPORA = "diaspora"
|
CONF_DIASPORA = "diaspora"
|
||||||
CONF_LANGUAGE = "language"
|
CONF_LANGUAGE = "language"
|
||||||
@ -67,6 +68,9 @@ def get_unique_prefix(
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the Jewish Calendar component."""
|
"""Set up the Jewish Calendar component."""
|
||||||
|
if DOMAIN not in config:
|
||||||
|
return True
|
||||||
|
|
||||||
name = config[DOMAIN][CONF_NAME]
|
name = config[DOMAIN][CONF_NAME]
|
||||||
language = config[DOMAIN][CONF_LANGUAGE]
|
language = config[DOMAIN][CONF_LANGUAGE]
|
||||||
|
|
||||||
@ -97,12 +101,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
"prefix": prefix,
|
"prefix": prefix,
|
||||||
}
|
}
|
||||||
|
|
||||||
hass.async_create_task(
|
for platform in PLATFORMS:
|
||||||
async_load_platform(hass, Platform.SENSOR, DOMAIN, {}, config)
|
hass.async_create_task(async_load_platform(hass, platform, DOMAIN, {}, config))
|
||||||
)
|
|
||||||
|
|
||||||
hass.async_create_task(
|
|
||||||
async_load_platform(hass, Platform.BINARY_SENSOR, DOMAIN, {}, config)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -24,7 +24,7 @@ from . import DOMAIN
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DATA_SENSORS = (
|
INFO_SENSORS = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="date",
|
key="date",
|
||||||
name="Date",
|
name="Date",
|
||||||
@ -143,7 +143,7 @@ async def async_setup_platform(
|
|||||||
|
|
||||||
sensors = [
|
sensors = [
|
||||||
JewishCalendarSensor(hass.data[DOMAIN], description)
|
JewishCalendarSensor(hass.data[DOMAIN], description)
|
||||||
for description in DATA_SENSORS
|
for description in INFO_SENSORS
|
||||||
]
|
]
|
||||||
sensors.extend(
|
sensors.extend(
|
||||||
JewishCalendarTimeSensor(hass.data[DOMAIN], description)
|
JewishCalendarTimeSensor(hass.data[DOMAIN], description)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user