Add translation support for utility_meter type in config flow (#86220)

* Add translation support for utility_meter type

* Remove redundant labels
pull/86525/head
Jan Bouwhuis 2023-01-24 12:52:26 +01:00 committed by GitHub
parent 63bddae01d
commit c97cf62b47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 11 deletions

View File

@ -35,15 +35,15 @@ from .const import (
)
METER_TYPES = [
selector.SelectOptionDict(value="none", label="No cycle"),
selector.SelectOptionDict(value=QUARTER_HOURLY, label="Every 15 minutes"),
selector.SelectOptionDict(value=HOURLY, label="Hourly"),
selector.SelectOptionDict(value=DAILY, label="Daily"),
selector.SelectOptionDict(value=WEEKLY, label="Weekly"),
selector.SelectOptionDict(value=MONTHLY, label="Monthly"),
selector.SelectOptionDict(value=BIMONTHLY, label="Every two months"),
selector.SelectOptionDict(value=QUARTERLY, label="Quarterly"),
selector.SelectOptionDict(value=YEARLY, label="Yearly"),
"none",
QUARTER_HOURLY,
HOURLY,
DAILY,
WEEKLY,
MONTHLY,
BIMONTHLY,
QUARTERLY,
YEARLY,
]
@ -74,7 +74,9 @@ CONFIG_SCHEMA = vol.Schema(
selector.EntitySelectorConfig(domain=SENSOR_DOMAIN),
),
vol.Required(CONF_METER_TYPE): selector.SelectSelector(
selector.SelectSelectorConfig(options=METER_TYPES),
selector.SelectSelectorConfig(
options=METER_TYPES, translation_key=CONF_METER_TYPE
),
),
vol.Required(CONF_METER_OFFSET, default=0): selector.NumberSelector(
selector.NumberSelectorConfig(

View File

@ -31,5 +31,20 @@
}
}
}
},
"selector": {
"cycle": {
"options": {
"none": "No cycle",
"quarter-hourly": "Every 15 minutes",
"hourly": "Hourly",
"daily": "Daily",
"weekly": "Weekly",
"monthly": "Monthly",
"bimonthly": "Every two months",
"quarterly": "Quarterly",
"yearly": "Yearly"
}
}
}
}

View File

@ -31,5 +31,20 @@
}
}
},
"title": "Utility Meter"
"title": "Utility Meter",
"selector": {
"cycle": {
"options": {
"none": "No cycle",
"quarter-hourly": "Every 15 minutes",
"hourly": "Hourly",
"daily": "Daily",
"weekly": "Weekly",
"monthly": "Monthly",
"bimonthly": "Every two months",
"quarterly": "Quarterly",
"yearly": "Yearly"
}
}
}
}