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

Add AdBlue range sensor #466

Merged
merged 2 commits into from
Dec 18, 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
3 changes: 3 additions & 0 deletions custom_components/myskoda/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@
"oil_service_in_km": {
"default": "mdi:oil"
},
"adblue_range": {
"default": "mdi:gauge"
},
"combustion_range": {
"default": "mdi:gas-station"
},
Expand Down
24 changes: 24 additions & 0 deletions custom_components/myskoda/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async def async_setup_entry(
"""Set up the sensor platform."""
add_supported_entities(
available_entities=[
AddBlueRange,
BatteryPercentage,
ChargeType,
ChargingPower,
Expand Down Expand Up @@ -229,6 +230,29 @@ def forbidden_capabilities(self) -> list[CapabilityId]:
return [CapabilityId.CHARGING_MQB]


class AddBlueRange(MySkodaSensor):
"""The vehicles's AdBlue range - only for vehicles where its available."""

entity_description = SensorEntityDescription(
key="adblue_range",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfLength.KILOMETERS,
device_class=SensorDeviceClass.DISTANCE,
translation_key="adblue_range",
)

@property
def native_value(self) -> int | None: # noqa: D102
if range := self.vehicle.driving_range:
if range.ad_blue_range is not None:
return range.ad_blue_range

def is_supported(self) -> bool:
if range := self.vehicle.driving_range:
return range.ad_blue_range is not None
return False
WebSpider marked this conversation as resolved.
Show resolved Hide resolved


class CombustionRange(MySkodaSensor):
"""The vehicle's combustion range - only for hybrid vehicles."""

Expand Down
3 changes: 3 additions & 0 deletions custom_components/myskoda/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@
"fuel_level": {
"name": "Fuel Level"
},
"adblue_range": {
"name": "AdBlue Range"
},
"combustion_range": {
"name": "Combustion Range"
},
Expand Down
Loading