Skip to content

Commit

Permalink
Make charging state options lower_snake_case and introduce translatio…
Browse files Browse the repository at this point in the history
…ns for the options

Fixes #56
  • Loading branch information
WebSpider committed Sep 30, 2024
1 parent e460905 commit 32fe07a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
14 changes: 9 additions & 5 deletions custom_components/myskoda/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,21 +253,25 @@ class ChargingState(ChargingSensor):
device_class=SensorDeviceClass.ENUM,
translation_key="charging_state",
)

# lower_snake_case for translations
_attr_options = [
"CONNECT_CABLE",
"READY_FOR_CHARGING",
"CONSERVING",
"CHARGING",
"connect_cable",
"ready_for_charging",
"conserving",
"charging",
]

@property
def native_value(self): # noqa: D102
return self._status().state
return str(self._status().state).lower()

@property
def icon(self): # noqa: D102
if self._status().state == charging.ChargingState.CONNECT_CABLE:
return "mdi:power-plug-off"
if self._status().state == charging.ChargingState.CHARGING:
return "mdi:power-plug-battery"
return "mdi:power-plug"


Expand Down
13 changes: 13 additions & 0 deletions custom_components/myskoda/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
}
}
},
"entity": {
"sensor": {
"charging_state": {
"name": "Charging State",
"state": {
"connect_cable": "Cable Disconnected",
"ready_for_charging": "Ready for Charging",
"conserving": "Conserving Charge",
"charging": "Charging"
}
}
}
},
"options": {
"step": {
"init": {
Expand Down

0 comments on commit 32fe07a

Please sign in to comment.