Change calculation methods to a fixed list (#99535)
This commit is contained in:
parent
8843a445c9
commit
8e22041ee9
3 changed files with 52 additions and 4 deletions
|
@ -8,6 +8,11 @@ import voluptuous as vol
|
|||
from homeassistant import config_entries
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.selector import (
|
||||
SelectSelector,
|
||||
SelectSelectorConfig,
|
||||
SelectSelectorMode,
|
||||
)
|
||||
|
||||
from .const import CALC_METHODS, CONF_CALC_METHOD, DEFAULT_CALC_METHOD, DOMAIN, NAME
|
||||
|
||||
|
@ -58,7 +63,13 @@ class IslamicPrayerOptionsFlowHandler(config_entries.OptionsFlow):
|
|||
default=self.config_entry.options.get(
|
||||
CONF_CALC_METHOD, DEFAULT_CALC_METHOD
|
||||
),
|
||||
): vol.In(CALC_METHODS)
|
||||
): SelectSelector(
|
||||
SelectSelectorConfig(
|
||||
options=CALC_METHODS,
|
||||
mode=SelectSelectorMode.DROPDOWN,
|
||||
translation_key=CONF_CALC_METHOD,
|
||||
)
|
||||
),
|
||||
}
|
||||
|
||||
return self.async_show_form(step_id="init", data_schema=vol.Schema(options))
|
||||
|
|
|
@ -1,12 +1,27 @@
|
|||
"""Constants for the Islamic Prayer component."""
|
||||
from typing import Final
|
||||
|
||||
from prayer_times_calculator import PrayerTimesCalculator
|
||||
|
||||
DOMAIN: Final = "islamic_prayer_times"
|
||||
NAME: Final = "Islamic Prayer Times"
|
||||
|
||||
CONF_CALC_METHOD: Final = "calculation_method"
|
||||
|
||||
CALC_METHODS: list[str] = list(PrayerTimesCalculator.CALCULATION_METHODS)
|
||||
CALC_METHODS: Final = [
|
||||
"jafari",
|
||||
"karachi",
|
||||
"isna",
|
||||
"mwl",
|
||||
"makkah",
|
||||
"egypt",
|
||||
"tehran",
|
||||
"gulf",
|
||||
"kuwait",
|
||||
"qatar",
|
||||
"singapore",
|
||||
"france",
|
||||
"turkey",
|
||||
"russia",
|
||||
"moonsighting",
|
||||
"custom",
|
||||
]
|
||||
DEFAULT_CALC_METHOD: Final = "isna"
|
||||
|
|
|
@ -20,6 +20,28 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"selector": {
|
||||
"calculation_method": {
|
||||
"options": {
|
||||
"jafari": "Shia Ithna-Ansari",
|
||||
"karachi": "University of Islamic Sciences, Karachi",
|
||||
"isna": "Islamic Society of North America",
|
||||
"mwl": "Muslim World League",
|
||||
"makkah": "Umm Al-Qura University, Makkah",
|
||||
"egypt": "Egyptian General Authority of Survey",
|
||||
"tehran": "Institute of Geophysics, University of Tehran",
|
||||
"gulf": "Gulf Region",
|
||||
"kuwait": "Kuwait",
|
||||
"qatar": "Qatar",
|
||||
"singapore": "Majlis Ugama Islam Singapura, Singapore",
|
||||
"france": "Union Organization islamic de France",
|
||||
"turkey": "Diyanet İşleri Başkanlığı, Turkey",
|
||||
"russia": "Spiritual Administration of Muslims of Russia",
|
||||
"moonsighting": "Moonsighting Committee Worldwide",
|
||||
"custom": "Custom"
|
||||
}
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"fajr": {
|
||||
|
|
Loading…
Add table
Reference in a new issue