Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Islamic prayer times naming #34784

Merged
merged 25 commits into from Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b41c566
Add Islamic Prayer Times config_flow
engrbm87 Nov 13, 2019
211b60a
Add Islamic Prayer Times config_flow
engrbm87 Nov 13, 2019
a98ee58
Merge branch 'islamic-prayer-config-flow' of https://github.com/engrb…
engrbm87 Feb 5, 2020
4fd2cea
handle options update and fix tests
engrbm87 Feb 7, 2020
87460d0
fix sensor update handling
engrbm87 Feb 7, 2020
8336df4
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
engrbm87 Feb 11, 2020
0e544e5
fix pylint
engrbm87 Feb 13, 2020
d412176
fix scheduled update and add test
engrbm87 Feb 15, 2020
8f9d01b
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
engrbm87 Mar 16, 2020
2a61a7d
update test_init
engrbm87 Mar 18, 2020
d5e6dfb
update flow options to show drop list
engrbm87 Mar 19, 2020
da7f34c
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
engrbm87 Apr 1, 2020
33e757e
Merge branch 'dev' into islamic-prayer-config-flow
engrbm87 Apr 10, 2020
25547a3
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
engrbm87 Apr 10, 2020
ee453f6
clean up code
engrbm87 Apr 13, 2020
3c75168
Merge branch 'islamic-prayer-config-flow' of https://github.com/engrb…
engrbm87 Apr 13, 2020
92ca24c
async scheduling and revert state to timestamp
engrbm87 Apr 13, 2020
d2b9782
fix update retry method
engrbm87 Apr 15, 2020
a1c57a9
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
engrbm87 Apr 20, 2020
d8d3df0
update strings
engrbm87 Apr 20, 2020
f3dc053
keep title as root key
engrbm87 Apr 20, 2020
60e56ca
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
engrbm87 Apr 27, 2020
300220d
fix sensor naming and calculation_method key
engrbm87 Apr 27, 2020
41dc6f0
fix strings
engrbm87 Apr 27, 2020
3e2bfbb
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
engrbm87 Apr 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions 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"
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/islamic_prayer_times/sensor.py
Expand Up @@ -5,7 +5,7 @@
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__)

Expand Down Expand Up @@ -33,7 +33,7 @@ def __init__(self, sensor_type, client):
@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):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/islamic_prayer_times/strings.json
Expand Up @@ -15,7 +15,7 @@
"step": {
"init": {
"data": {
"calc_method": "Prayer calculation method"
"calculation_method": "Prayer calculation method"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After merging this we should update the translation key in lokalise or else all existing translations will be lost .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}
}
Expand Down
40 changes: 20 additions & 20 deletions 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"
}
}
}
},
"title": "Islamic Prayer Times"
}
4 changes: 3 additions & 1 deletion tests/components/islamic_prayer_times/test_sensor.py
Expand Up @@ -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()
)