1
mirror of https://github.com/home-assistant/core synced 2024-10-07 10:13:38 +02:00

Fix Islamic prayer times naming (#34784)

This commit is contained in:
Rami Mosleh 2020-04-29 14:38:20 +03:00 committed by GitHub
parent 24fd395d09
commit 6e0d61e5e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 27 deletions

View File

@ -1,12 +1,19 @@
"""Constants for the Islamic Prayer component."""
DOMAIN = "islamic_prayer_times"
NAME = "Islamic Prayer Times"
SENSOR_SUFFIX = "Prayer"
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"]
DEFAULT_CALC_METHOD = "isna"

View File

@ -5,7 +5,7 @@ from homeassistant.const import DEVICE_CLASS_TIMESTAMP
from homeassistant.helpers.dispatcher import async_dispatcher_connect
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__)
@ -33,7 +33,7 @@ class IslamicPrayerTimeSensor(Entity):
@property
def name(self):
"""Return the name of the sensor."""
return f"{self.sensor_type} {SENSOR_SUFFIX}"
return f"{self.sensor_type} {SENSOR_TYPES[self.sensor_type]}"
@property
def unique_id(self):

View File

@ -15,7 +15,7 @@
"step": {
"init": {
"data": {
"calc_method": "Prayer calculation method"
"calculation_method": "Prayer calculation method"
}
}
}

View File

@ -1,23 +1,23 @@
{
"config": {
"abort": {
"one_instance_allowed": "Only a single instance is necessary."
},
"step": {
"user": {
"description": "Do you want to set up Islamic Prayer Times?",
"title": "Set up Islamic Prayer Times"
}
}
"config": {
"abort": {
"one_instance_allowed": "Only a single instance is necessary."
},
"options": {
"step": {
"init": {
"data": {
"calc_method": "Prayer calculation method"
}
}
"step": {
"user": {
"description": "Do you want to set up Islamic Prayer Times?",
"title": "Set up Islamic Prayer Times"
}
}
},
"options": {
"step": {
"init": {
"data": {
"calculation_method": "Prayer calculation method"
}
},
"title": "Islamic Prayer Times"
}
}
}
},
"title": "Islamic Prayer Times"
}

View File

@ -23,6 +23,8 @@ async def test_islamic_prayer_times_sensors(hass):
for prayer in PRAYER_TIMES:
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()
)