Skip to content

Commit

Permalink
Add translation support for utility_meter type in config flow (#86220)
Browse files Browse the repository at this point in the history
* Add translation support for utility_meter type

* Remove redundant labels
  • Loading branch information
jbouwh committed Jan 24, 2023
1 parent 63bddae commit c97cf62
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 11 deletions.
22 changes: 12 additions & 10 deletions homeassistant/components/utility_meter/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
)

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,
]


Expand Down Expand Up @@ -74,7 +74,9 @@ async def _validate_config(
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(
Expand Down
15 changes: 15 additions & 0 deletions homeassistant/components/utility_meter/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
17 changes: 16 additions & 1 deletion homeassistant/components/utility_meter/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}

0 comments on commit c97cf62

Please sign in to comment.