We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Current usage:
vehicle.fuel_driving_range = (get_child_value(state,"vehicleStatus.dte.value",),DISTANCE_UNITS[get_child_value(state, "vehicleStatus.dte.unit")]) vehicle.ev_target_range_charge_DC = ( get_child_value( state, "vehicleStatus.evStatus.reservChargeInfos.targetSOClist.0.dte.rangeByFuel.totalAvailableRange.value", ), DISTANCE_UNITS[ get_child_value( state, "vehicleStatus.evStatus.reservChargeInfos.targetSOClist.0.dte.rangeByFuel.totalAvailableRange.unit", ) ], )
New proposal:
@dataclass class UnitMapper: value_field: str unit_field: str = None def __post_init__(self): if self.unit_field is None: splitted = self.value_field.rsplit(".", 1) splitted[1] = "unit" self.unit_field = ".".join(b) class UnitBasedFieldDefinition(Enum): fuel_driving_range= UnitMapper("vehicleStatus.dte.value") ev_target_range_charge_DC= UnitMapper("vehicleStatus.evStatus.reservChargeInfos.targetSOClist.0.dte.rangeByFuel.totalAvailableRange.value") some_other = UnitMapper("vehicleStatus.field","VehicleStatus.some_other_unit_field") for key, value in UnitBasedFieldDefinition: setattr(vehicle, key, get_child_value(value.value_field), get_child_value(value.unit_field))
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Current usage:
New proposal:
The text was updated successfully, but these errors were encountered: