mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Fix Islamic prayer times naming (#34784)
This commit is contained in:
parent
24fd395d09
commit
6e0d61e5e8
@ -1,12 +1,19 @@
|
|||||||
"""Constants for the Islamic Prayer component."""
|
"""Constants for the Islamic Prayer component."""
|
||||||
DOMAIN = "islamic_prayer_times"
|
DOMAIN = "islamic_prayer_times"
|
||||||
NAME = "Islamic Prayer Times"
|
NAME = "Islamic Prayer Times"
|
||||||
SENSOR_SUFFIX = "Prayer"
|
|
||||||
PRAYER_TIMES_ICON = "mdi:calendar-clock"
|
PRAYER_TIMES_ICON = "mdi:calendar-clock"
|
||||||
|
|
||||||
SENSOR_TYPES = ["Fajr", "Sunrise", "Dhuhr", "Asr", "Maghrib", "Isha", "Midnight"]
|
SENSOR_TYPES = {
|
||||||
|
"Fajr": "prayer",
|
||||||
|
"Sunrise": "time",
|
||||||
|
"Dhuhr": "prayer",
|
||||||
|
"Asr": "prayer",
|
||||||
|
"Maghrib": "prayer",
|
||||||
|
"Isha": "prayer",
|
||||||
|
"Midnight": "time",
|
||||||
|
}
|
||||||
|
|
||||||
CONF_CALC_METHOD = "calc_method"
|
CONF_CALC_METHOD = "calculation_method"
|
||||||
|
|
||||||
CALC_METHODS = ["isna", "karachi", "mwl", "makkah"]
|
CALC_METHODS = ["isna", "karachi", "mwl", "makkah"]
|
||||||
DEFAULT_CALC_METHOD = "isna"
|
DEFAULT_CALC_METHOD = "isna"
|
||||||
|
@ -5,7 +5,7 @@ from homeassistant.const import DEVICE_CLASS_TIMESTAMP
|
|||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
from .const import DATA_UPDATED, DOMAIN, PRAYER_TIMES_ICON, SENSOR_SUFFIX, SENSOR_TYPES
|
from .const import DATA_UPDATED, DOMAIN, PRAYER_TIMES_ICON, SENSOR_TYPES
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ class IslamicPrayerTimeSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return f"{self.sensor_type} {SENSOR_SUFFIX}"
|
return f"{self.sensor_type} {SENSOR_TYPES[self.sensor_type]}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"step": {
|
"step": {
|
||||||
"init": {
|
"init": {
|
||||||
"data": {
|
"data": {
|
||||||
"calc_method": "Prayer calculation method"
|
"calculation_method": "Prayer calculation method"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
"step": {
|
"step": {
|
||||||
"init": {
|
"init": {
|
||||||
"data": {
|
"data": {
|
||||||
"calc_method": "Prayer calculation method"
|
"calculation_method": "Prayer calculation method"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ async def test_islamic_prayer_times_sensors(hass):
|
|||||||
|
|
||||||
for prayer in PRAYER_TIMES:
|
for prayer in PRAYER_TIMES:
|
||||||
assert (
|
assert (
|
||||||
hass.states.get(f"sensor.{prayer}_prayer").state
|
hass.states.get(
|
||||||
|
f"sensor.{prayer}_{islamic_prayer_times.const.SENSOR_TYPES[prayer]}"
|
||||||
|
).state
|
||||||
== PRAYER_TIMES_TIMESTAMPS[prayer].isoformat()
|
== PRAYER_TIMES_TIMESTAMPS[prayer].isoformat()
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user