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

Expose more to translations #59

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 14 additions & 0 deletions custom_components/myskoda/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class WindowHeating(MySkodaSwitch):
name="Window Heating",
icon="mdi:car-defrost-front",
device_class=SwitchDeviceClass.SWITCH,
translation_key="window_heating",
)

def _air_conditioning(self) -> AirConditioning:
Expand Down Expand Up @@ -92,6 +93,16 @@ def required_capabilities(self) -> list[CapabilityId]:


class ChargingSwitch(MySkodaSwitch):
"""Shows charging."""

entity_description = SwitchEntityDescription(
key="charging_switch",
name="Charging",
icon="mdi:car-electric",
device_class=SwitchDeviceClass.SWITCH,
translation_key="charging_switch",
)

def _charging(self) -> Charging:
charging = self.vehicle.charging
if charging is None:
Expand Down Expand Up @@ -129,6 +140,7 @@ class BatteryCareMode(ChargingSwitch):
name="Battery Care Mode",
icon="mdi:battery-heart-variant",
device_class=SwitchDeviceClass.SWITCH,
translation_key="battery_care_mode",
)

@property
Expand Down Expand Up @@ -156,6 +168,7 @@ class ReducedCurrent(ChargingSwitch):
name="Reduced Current",
icon="mdi:current-ac",
device_class=SwitchDeviceClass.SWITCH,
translation_key="reduced_current",
)

@property
Expand Down Expand Up @@ -183,6 +196,7 @@ class EnableCharging(ChargingSwitch):
name="Charging",
icon="mdi:power-plug-battery",
device_class=SwitchDeviceClass.SWITCH,
translation_key="charging",
)

@property
Expand Down
104 changes: 104 additions & 0 deletions custom_components/myskoda/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,110 @@
}
}
},
"entity": {
"binary_sensor": {
"charger_connected": {
"name": "Charger Connected"
},
"charger_locked": {
"name": "Charge Lock"
},
"locked": {
"name": "Vehicle Locked"
},
"doors_locked": {
"name": "Doors Locked"
},
"doors_open": {
"name": "Doors Open"
},
"windows_open": {
"name": "Windows"
},
"trunk_open": {
"name": "Trunk"
},
"bonnet_open": {
"name": "Bonnet"
},
"sunroof_open": {
"name": "Sunroof"
},
"lights_on": {
"name": "Lights"
}
},
"climate": {
"climate": {
"name": "Air Conditioning"
}
},
"device_tracker": {
"device_tracker": {
"name": "Positition"
}
},
"number": {
"charge_limit": {
"name": "Charge Limit"
}
},
"sensor": {
"software_version": {
"name": "Software Version"
},
"battery_percentage": {
"name": "Battery Percentage"
},
"charging_power": {
"name": "Charging Power"
},
"charging_state": {
"name": "Charging State",
"state": {
"connect_cable": "Cable Disconnected",
"ready_for_charging": "Ready for Charging",
"conserving": "Conserving Charge",
"charging": "Charging"
}
},
"range": {
"name": "Range"
},
"target_battery_percentage": {
"name": "Target Battery Percentage"
},
"mileage": {
"name": "Mileage"
},
"charge_type": {
"name": "Charge Type"
},
"remaining_charging_time": {
"name": "Remaining Charging Time"
},
"car_captured": {
"name": "Last Updated"
}
},
"switch": {
"window_heating": {
"name": "Window Heating"
},
"charging_switch": {
"name": "Charging"
},
"battery_care_mode": {
"name": "Battery Care"
},
"reduced_current": {
"name": "Reduced Current"
},
"charging": {
"name": "Charging"
}
}
},
"options": {
"step": {
"init": {
Expand Down
Loading