Improve Jewish calendar entities (#120236)
* By default don't enable all sensors
* Fix tests
* Add entity category
* Set has_entity_name to true
* Revert "Set has_entity_name to true"
This reverts commit 5ebfcde78a
.
pull/120248/head
parent
473b3b61eb
commit
2cc34fd7e7
|
@ -16,7 +16,7 @@ from homeassistant.components.binary_sensor import (
|
|||
BinarySensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_LANGUAGE, CONF_LOCATION
|
||||
from homeassistant.const import CONF_LANGUAGE, CONF_LOCATION, EntityCategory
|
||||
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
|
||||
from homeassistant.helpers import event
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -55,11 +55,13 @@ BINARY_SENSORS: tuple[JewishCalendarBinarySensorEntityDescription, ...] = (
|
|||
key="erev_shabbat_hag",
|
||||
name="Erev Shabbat/Hag",
|
||||
is_on=lambda state: bool(state.erev_shabbat_chag),
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
JewishCalendarBinarySensorEntityDescription(
|
||||
key="motzei_shabbat_hag",
|
||||
name="Motzei Shabbat/Hag",
|
||||
is_on=lambda state: bool(state.motzei_shabbat_chag),
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -82,6 +84,7 @@ class JewishCalendarBinarySensor(BinarySensorEntity):
|
|||
"""Representation of an Jewish Calendar binary sensor."""
|
||||
|
||||
_attr_should_poll = False
|
||||
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||
entity_description: JewishCalendarBinarySensorEntityDescription
|
||||
|
||||
def __init__(
|
||||
|
|
|
@ -15,7 +15,12 @@ from homeassistant.components.sensor import (
|
|||
SensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_LANGUAGE, CONF_LOCATION, SUN_EVENT_SUNSET
|
||||
from homeassistant.const import (
|
||||
CONF_LANGUAGE,
|
||||
CONF_LOCATION,
|
||||
SUN_EVENT_SUNSET,
|
||||
EntityCategory,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.sun import get_astral_event_date
|
||||
|
@ -54,11 +59,13 @@ INFO_SENSORS: tuple[SensorEntityDescription, ...] = (
|
|||
key="omer_count",
|
||||
name="Day of the Omer",
|
||||
icon="mdi:counter",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="daf_yomi",
|
||||
name="Daf Yomi",
|
||||
icon="mdi:book-open-variant",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -67,11 +74,13 @@ TIME_SENSORS: tuple[SensorEntityDescription, ...] = (
|
|||
key="first_light",
|
||||
name="Alot Hashachar", # codespell:ignore alot
|
||||
icon="mdi:weather-sunset-up",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="talit",
|
||||
name="Talit and Tefillin",
|
||||
icon="mdi:calendar-clock",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="sunrise",
|
||||
|
@ -82,41 +91,49 @@ TIME_SENSORS: tuple[SensorEntityDescription, ...] = (
|
|||
key="gra_end_shma",
|
||||
name='Latest time for Shma Gr"a',
|
||||
icon="mdi:calendar-clock",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="mga_end_shma",
|
||||
name='Latest time for Shma MG"A',
|
||||
icon="mdi:calendar-clock",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="gra_end_tfila",
|
||||
name='Latest time for Tefilla Gr"a',
|
||||
icon="mdi:calendar-clock",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="mga_end_tfila",
|
||||
name='Latest time for Tefilla MG"A',
|
||||
icon="mdi:calendar-clock",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="midday",
|
||||
name="Chatzot Hayom",
|
||||
icon="mdi:calendar-clock",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="big_mincha",
|
||||
name="Mincha Gedola",
|
||||
icon="mdi:calendar-clock",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="small_mincha",
|
||||
name="Mincha Ketana",
|
||||
icon="mdi:calendar-clock",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="plag_mincha",
|
||||
name="Plag Hamincha",
|
||||
icon="mdi:weather-sunset-down",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="sunset",
|
||||
|
@ -127,21 +144,25 @@ TIME_SENSORS: tuple[SensorEntityDescription, ...] = (
|
|||
key="first_stars",
|
||||
name="T'set Hakochavim",
|
||||
icon="mdi:weather-night",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="three_stars",
|
||||
name="T'set Hakochavim, 3 stars",
|
||||
icon="mdi:weather-night",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="upcoming_shabbat_candle_lighting",
|
||||
name="Upcoming Shabbat Candle Lighting",
|
||||
icon="mdi:candle",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="upcoming_shabbat_havdalah",
|
||||
name="Upcoming Shabbat Havdalah",
|
||||
icon="mdi:weather-night",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="upcoming_candle_lighting",
|
||||
|
@ -178,6 +199,8 @@ async def async_setup_entry(
|
|||
class JewishCalendarSensor(SensorEntity):
|
||||
"""Representation of an Jewish calendar sensor."""
|
||||
|
||||
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
entry_id: str,
|
||||
|
|
|
@ -201,6 +201,7 @@ TEST_IDS = [
|
|||
TEST_PARAMS,
|
||||
ids=TEST_IDS,
|
||||
)
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_jewish_calendar_sensor(
|
||||
hass: HomeAssistant,
|
||||
now,
|
||||
|
@ -541,6 +542,7 @@ SHABBAT_TEST_IDS = [
|
|||
SHABBAT_PARAMS,
|
||||
ids=SHABBAT_TEST_IDS,
|
||||
)
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_shabbat_times_sensor(
|
||||
hass: HomeAssistant,
|
||||
language,
|
||||
|
@ -617,6 +619,7 @@ OMER_TEST_IDS = [
|
|||
|
||||
|
||||
@pytest.mark.parametrize(("test_time", "result"), OMER_PARAMS, ids=OMER_TEST_IDS)
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_omer_sensor(hass: HomeAssistant, test_time, result) -> None:
|
||||
"""Test Omer Count sensor output."""
|
||||
test_time = test_time.replace(tzinfo=dt_util.get_time_zone(hass.config.time_zone))
|
||||
|
@ -651,6 +654,7 @@ DAFYOMI_TEST_IDS = [
|
|||
|
||||
|
||||
@pytest.mark.parametrize(("test_time", "result"), DAFYOMI_PARAMS, ids=DAFYOMI_TEST_IDS)
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_dafyomi_sensor(hass: HomeAssistant, test_time, result) -> None:
|
||||
"""Test Daf Yomi sensor output."""
|
||||
test_time = test_time.replace(tzinfo=dt_util.get_time_zone(hass.config.time_zone))
|
||||
|
|
Loading…
Reference in New Issue