Merge pull request #38 from jlayec/feature-hybrid_compatibility

fix units, otp, position and add C5 Aircross for hybrid cars
This commit is contained in:
Florian BEZANNIER
2021-03-06 21:12:09 +01:00
committed by GitHub
7 changed files with 37 additions and 22 deletions
+3 -3
View File
@@ -12,9 +12,8 @@ A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. what solution did you use (solution 1 or 2)
2. what command did you use
3. when the bug append ?
1. what command did you use
2. when the bug append ?
**Config file**
Give the anonymize content of the config file
@@ -22,6 +21,7 @@ Give the anonymize content of the config file
**Environment (please complete the following information):**
- OS: [e.g. Windows]
- Android app Version [e.g. 26.0]
- Brand and model of car
**Additional context**
Add any other context about the problem here.
+2
View File
@@ -139,9 +139,11 @@ cython_debug/
.idea/
backup.ab
*.apk
info.db
otp.bin
charge_config1.json
config.json
test.json
charge_config.json
cars.json
+1
View File
@@ -3,6 +3,7 @@ import json
from MyLogger import logger
ENERGY_CAPACITY = {'SUV 3008': {'BATTERY_POWER': 10.8, 'FUEL_CAPACITY': 43},
'C5 Aircross': {'BATTERY_POWER': 10.8, 'FUEL_CAPACITY': 43},
'e-208': {'BATTERY_POWER': 46, 'FUEL_CAPACITY': 0},
'e-2008': {'BATTERY_POWER': 46, 'FUEL_CAPACITY': 0}
}
+12 -8
View File
@@ -227,7 +227,7 @@ class MyPSACC:
headers={
"Connection": "Keep-Alive",
"User-Agent": "okhttp/4.8.0",
"x-introspect-realm": "clientsB2CPeugeot"
"x-introspect-realm": self.realm
})
return res
@@ -362,13 +362,17 @@ class MyPSACC:
reg = r"PT([0-9]{1,2})H([0-9]{1,2})?"
data = self.get_vehicle_info(vin)
hour_str = data.get_energy('Electric').charging.next_delayed_time
hour = re.findall(reg, hour_str)[0]
h = int(hour[0])
if hour[1] == '':
m = 0
else:
m = hour[1]
return h, m
try:
hour = re.findall(reg, hour_str)[0]
h = int(hour[0])
if hour[1] == '':
m = 0
else:
m = hour[1]
return h, m
except IndexError:
logger.error(traceback.format_exc())
logger.error(f"Can't get charge hour: {hour_str}")
def get_charge_status(self, vin):
data = self.get_vehicle_info(vin)
+2 -2
View File
@@ -143,7 +143,7 @@ class Trips(list):
elif distance == 0 and charge > 2:
end_trip = True
if DEBUG:
logger.debug(f"charge detected {charge}")
logger.debug(f"charge detected")
elif speed_average < 0.2 and duration > 0.05:
# (distance == 0 and duration > 0.08) or duration > 2 or
# check the speed to handle missing point
@@ -183,7 +183,7 @@ class Trips(list):
if DEBUG:
logger.debug(
f"Trip: {tr.start_at} -> {tr.end_at} {tr.distance:.1f}km {tr.duration:.2f}h {tr.speed_average:.0f}km/h "
f"{tr.consumption:.2f}kw {tr.consumption_km:.2f}kw/100km {tr.consumption_fuel}L {tr.consumption_fuel_km}L/100km "
f"{tr.consumption:.2f}kWh {tr.consumption_km:.2f}kWh/100km {tr.consumption_fuel}L {tr.consumption_fuel_km}L/100km "
f"{tr.mileage:.1f}km")
# filter bad value
if tr.consumption_km < 70 and (
+11 -4
View File
@@ -36,7 +36,7 @@ def display_value(value):
filtered_trips.append(trip)
filtered_chargings = MyPSACC.get_chargings(min,max)
figures.get_figures(filtered_trips,filtered_chargings)
consumption = "Average consumption: {:.1f} kW/100km".format(float(figures.consumption_df.mean(numeric_only=True)))
consumption = "Average consumption: {:.1f} kWh/100km".format(float(figures.consumption_df.mean(numeric_only=True)))
return figures.trips_map, figures.consumption_fig, figures.consumption_fig_by_speed, consumption, figures.table_fig, figures.battery_info
@@ -78,9 +78,16 @@ def preconditioning(vin, activate):
@app.route('/position/<string:vin>')
def get_position(vin):
res = myp.get_vehicle_info(vin)
longitude, latitude = res.last_position.geometry.coordinates
return jsonify(
{"longitude": longitude, "latitude": latitude, "url": f"http://maps.google.com/maps?q={latitude},{longitude}"})
coordinates=res.last_position.geometry.coordinates
if len(coordinates)==3: # altitude is not always availlable
longitude, latitude, altitude = coordinates
return jsonify(
{"longitude": longitude, "latitude": latitude, "altitude": altitude, "url": f"http://maps.google.com/maps?q={latitude},{longitude}"})
else:
longitude, latitude = coordinates
return jsonify(
{"longitude": longitude, "latitude": latitude, "url": f"http://maps.google.com/maps?q={latitude},{longitude}"})
# Set a battery threshold and schedule an hour to stop the charge
+6 -5
View File
@@ -77,7 +77,7 @@ def get_figures(trips: List[Trip], charging: List[dict]):
{'id': 'speed_average', 'name': 'average speed', 'type': 'numeric',
'format': deepcopy(nb_format).symbol_suffix(" km/h").precision(0)},
{'id': 'consumption_km', 'name': 'average consumption', 'type': 'numeric',
'format': deepcopy(nb_format).symbol_suffix(" kw/100km")},
'format': deepcopy(nb_format).symbol_suffix(" kWh/100km")},
{'id': 'consumption_fuel_km', 'name': 'average consumption fuel', 'type': 'numeric',
'format': deepcopy(nb_format).symbol_suffix(" L/100km")},
{'id': 'distance', 'name': 'distance', 'type': 'numeric', 'format': nb_format.symbol_suffix(" km").precision(1)},
@@ -100,7 +100,7 @@ def get_figures(trips: List[Trip], charging: List[dict]):
name="Trips"))
consumption_fig_by_speed.update_layout(xaxis_title="average Speed km/h", yaxis_title="Consumption kWh/100Km")
kw_per_km = float(consumption_df.mean(numeric_only=True))
info = "Average consumption: {:.1f} kW/100km".format(kw_per_km)
info = "Average consumption: {:.1f} kWh/100km".format(kw_per_km)
# charging
charging_data = DataFrame.from_records(charging)
@@ -118,6 +118,7 @@ def get_figures(trips: List[Trip], charging: List[dict]):
charge_speed = 0
except KeyError: # when there is no data yet:
charge_speed = 0
battery_info = html.Div(children=[html.P("Average gC02/kW: {:.1f}".format(co2_per_kw)),
html.P("Average gC02/km: {:1f}".format(co2_per_km)),
html.P("Average Charge SPEED {:1f} kW/h".format(charge_speed))])
battery_info = html.Div(children=[
html.P("Average C02 emission: {:.1f} g/kWh".format(co2_per_kw)),
html.P("Average CO2 emission: {:.1f} g/km".format(co2_per_km)),
html.P("Average charge speed: {:.3f} kW".format(charge_speed))])