From 6e0d61e5e8f7bd77edf60d0c79dd9c1a680cf68f Mon Sep 17 00:00:00 2001 From: Rami Mosleh Date: Wed, 29 Apr 2020 14:38:20 +0300 Subject: [PATCH] Fix Islamic prayer times naming (#34784) --- .../components/islamic_prayer_times/const.py | 13 ++++-- .../components/islamic_prayer_times/sensor.py | 4 +- .../islamic_prayer_times/strings.json | 2 +- .../islamic_prayer_times/translations/en.json | 40 +++++++++---------- .../islamic_prayer_times/test_sensor.py | 4 +- 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/homeassistant/components/islamic_prayer_times/const.py b/homeassistant/components/islamic_prayer_times/const.py index 5a9007689d9..ee7512c2d7a 100644 --- a/homeassistant/components/islamic_prayer_times/const.py +++ b/homeassistant/components/islamic_prayer_times/const.py @@ -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" diff --git a/homeassistant/components/islamic_prayer_times/sensor.py b/homeassistant/components/islamic_prayer_times/sensor.py index d1f4baa90bc..92a0a491d8d 100644 --- a/homeassistant/components/islamic_prayer_times/sensor.py +++ b/homeassistant/components/islamic_prayer_times/sensor.py @@ -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): diff --git a/homeassistant/components/islamic_prayer_times/strings.json b/homeassistant/components/islamic_prayer_times/strings.json index ebbea482122..857ce4c2dff 100644 --- a/homeassistant/components/islamic_prayer_times/strings.json +++ b/homeassistant/components/islamic_prayer_times/strings.json @@ -15,7 +15,7 @@ "step": { "init": { "data": { - "calc_method": "Prayer calculation method" + "calculation_method": "Prayer calculation method" } } } diff --git a/homeassistant/components/islamic_prayer_times/translations/en.json b/homeassistant/components/islamic_prayer_times/translations/en.json index 155a693ab1f..4db928c0ede 100644 --- a/homeassistant/components/islamic_prayer_times/translations/en.json +++ b/homeassistant/components/islamic_prayer_times/translations/en.json @@ -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" -} \ No newline at end of file + } + } + }, + "title": "Islamic Prayer Times" +} diff --git a/tests/components/islamic_prayer_times/test_sensor.py b/tests/components/islamic_prayer_times/test_sensor.py index 4954287b864..0579664ae7b 100644 --- a/tests/components/islamic_prayer_times/test_sensor.py +++ b/tests/components/islamic_prayer_times/test_sensor.py @@ -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() )