Merge branch 'flobz:master' into feature/#386-mileage-in-charge-table

This commit is contained in:
stevoh6
2023-05-04 16:07:30 +02:00
committed by GitHub
15 changed files with 117 additions and 2394 deletions
+2 -2
View File
@@ -9,7 +9,7 @@ on:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- name: Set up python
id: setup-python
@@ -48,4 +48,4 @@ jobs:
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r cobertura.xml
else
echo no CODACY_PROJECT_TOKEN
fi
fi
+5 -4
View File
@@ -29,14 +29,15 @@ The official api is documented [here](https://developer.groupe-psa.io/webapi/b2c
- [Installation on Linux or Windows](docs/Install.md)
- [Instalation as Home Assistant addon](https://github.com/flobz/psacc-ha/blob/main/psacc-ha/README.md)
- [Installation in Docker](docs/Docker.md)
- [Installation on Raspberry Pi with docker-compose (external Tutorial)](https://return2.net/opel-peugeot-electric-vehicle-set-charging-threshold-limit/)
## II. Use the app
2.1 Get the car state :
http://localhost:5000/get_vehicleinfo/YOURVIN
2.2 Get the car state from cache to avoid to use psa api too much
http://localhost:5000/get_vehicleinfo/YOURVIN?from_cache=1
2.2 Stop charge
http://localhost:5000/charge_now/YOURVIN/0
@@ -45,7 +46,7 @@ The official api is documented [here](https://developer.groupe-psa.io/webapi/b2c
2.4 Change car charge threshold to 80 percent
http://localhost:5000/charge_control?vin=YOURVIN&percentage=80
2.5 See the dashboard (only if record is enabled)
http://localhost:5000
@@ -60,7 +61,7 @@ The official api is documented [here](https://developer.groupe-psa.io/webapi/b2c
## III. Use the dashboard
You can add the -r argument to record the position of the vehicle and retrieve this information in a dashboard.
``python3 psa-car-controller -f config.json -c charge_config.json -r``
Generated
-2353
View File
File diff suppressed because it is too large Load Diff
+9 -3
View File
@@ -1,4 +1,10 @@
from pathlib import Path
from single_source import get_version
import sys
__version__ = get_version(__name__, Path(__file__), default_return="dev")
if sys.version_info[:2] >= (3, 8):
from importlib import metadata
else:
import importlib_metadata as metadata
__version__ = metadata.version(__package__)
del metadata, sys
@@ -42,7 +42,7 @@ class Energy(object):
}
attribute_map = {
'updated_at': 'updatedAt',
'updated_at': 'createdAt',
'autonomy': 'autonomy',
'battery': 'battery',
'charging': 'charging',
@@ -41,7 +41,7 @@ class PositionProperties(object):
'heading': 'heading',
'signal_quality': 'signalQuality',
'type': 'type',
'updated_at': 'updatedAt'
'updated_at': 'createdAt'
}
def __init__(self, heading=None, signal_quality=None, type=None, updated_at=None): # noqa: E501
@@ -126,7 +126,7 @@ class PositionProperties(object):
:param type: The type of this PositionProperties. # noqa: E501
:type: str
"""
allowed_values = ["Estimated", "Acquired", "Estimate", "Aquire"] # noqa: E501
allowed_values = ["Estimated", "Acquired", "Estimate", "Acquire"] # noqa: E501
if type not in allowed_values:
raise ValueError(
"Invalid value for `type` ({0}), must be one of {1}" # noqa: E501
@@ -31,20 +31,18 @@ class PreconditioningAirConditioning(object):
and the value is json key in definition.
"""
swagger_types = {
'failure_cause': 'str',
'programs': 'list[PreconditioningProgram]',
'status': 'str',
'updated_at': 'datetime'
'updated_at': 'datetime',
'created_at': 'datetime'
}
attribute_map = {
'failure_cause': 'failureCause',
'programs': 'programs',
'status': 'status',
'updated_at': 'updatedAt'
'updated_at': 'updatedAt',
'created_at': 'createdAt',
}
def __init__(self, failure_cause=None, programs=None, status=None, updated_at=None): # noqa: E501
def __init__(self, status=None, updated_at=None, created_at=None): # noqa: E501
"""PreconditioningAirConditioning - a model defined in Swagger""" # noqa: E501
self._failure_cause = None
@@ -53,14 +51,11 @@ class PreconditioningAirConditioning(object):
self._updated_at = None
self.discriminator = None
if failure_cause is not None:
self.failure_cause = failure_cause
if programs is not None:
self.programs = programs
if status is not None:
self.status = status
if updated_at is not None:
self.updated_at = updated_at
self.created_at = created_at
@property
def failure_cause(self):
@@ -57,11 +57,11 @@ class Status(object):
'ignition': 'ignition',
'kinetic': 'kinetic',
'last_position': 'lastPosition',
'preconditionning': 'preconditionning',
'preconditionning': 'preconditioning',
'privacy': 'privacy',
'safety': 'safety',
'service': 'service',
'timed_odometer': 'timed.odometer'
'timed_odometer': 'odometer'
}
def __init__(self, embedded=None, links=None, battery=None, doors_state=None, energy=None, environment=None, ignition=None, kinetic=None, last_position=None, preconditionning=None, privacy=None, safety=None, service=None, timed_odometer=None): # noqa: E501
@@ -36,7 +36,7 @@ class VehicleOdometer(object):
}
attribute_map = {
'updated_at': 'updatedAt',
'updated_at': 'createdAt',
'mileage': 'mileage'
}
@@ -88,7 +88,7 @@ class ChargeControl:
if status == INPROGRESS:
logger.info("charging status of %s is %s, battery level: %d", self.vin, status, level)
self.force_update(vehicle_status)
if hit_threshold and self.retry_count < 2:
if has_threshold and hit_threshold and self.retry_count < 2:
logger.info("Charge threshold is reached, stop the charge")
self.control_charge_with_ack(False)
elif self._next_stop_hour is not None:
+5 -1
View File
@@ -105,8 +105,12 @@ class Cars(list):
return None
def add(self, car: Car):
if self.get_car_by_id(car.vehicle_id) is None:
car_with_same_vin = self.get_car_by_vin(car.vin)
if not car_with_same_vin:
self.append(car)
elif car_with_same_vin.vehicle_id != car.vehicle_id:
logger.warning("Vehicle ID changed !")
car_with_same_vin.vehicle_id = car.vehicle_id
@classmethod
def from_json(cls, data: list):
@@ -1,3 +1,10 @@
- !ElecModel
name: Vivaro-e panel van L1
battery_power: 68
fuel_capacity: 0
abrp_name: opel:vivaroe:22:75:l
reg: VXEV1ZKXZN.*
max_elec_consumption: 70
- !ElecModel
name: e-jumpy
battery_power: 68
@@ -82,6 +89,13 @@
abrp_name: opel:comboe:22:50:peugeot
reg: VR3EZZKXZ.*
max_elec_consumption: 70
- !ElecModel
name: ION
battery_power: 14.5
fuel_capacity: 0
abrp_name: peugeot:ion:12:14:other
reg: VF31NZKY.*
max_elec_consumption: 70
- !CarModel
name: SUV 3008 Hybrid 225
battery_power: 13.2
@@ -114,6 +128,14 @@
reg: VR3UPHN[SEK].*
max_elec_consumption: 70
max_fuel_consumption: 30
- !CarModel
name: '208'
battery_power: 0
fuel_capacity: 44
abrp_name:
reg: VF3CCBHY6H.*
max_elec_consumption: 70
max_fuel_consumption: 30
- !CarModel
name: '2008'
battery_power: 0
@@ -122,6 +144,14 @@
reg: VR3USHNS.*
max_elec_consumption: 70
max_fuel_consumption: 30
- !CarModel
name: '2008'
battery_power: 0
fuel_capacity: 44
abrp_name:
reg: VF3CU9HP.*
max_elec_consumption: 70
max_fuel_consumption: 30
- !CarModel
name: 2008 II
battery_power: 0
@@ -143,7 +173,15 @@
battery_power: 0
fuel_capacity: 56
abrp_name:
reg: VF3MRHNY.*
reg: VF3MRHNYHH.*
max_elec_consumption: 70
max_fuel_consumption: 30
- !CarModel
name: SUV 3008 II
battery_power: 0
fuel_capacity: 53
abrp_name:
reg: VF3MRHNYHJ.*
max_elec_consumption: 70
max_fuel_consumption: 30
- !CarModel
@@ -226,6 +264,14 @@
reg: VF72RHNPXK.*
max_elec_consumption: 70
max_fuel_consumption: 30
- !CarModel
name: 308 Hybrid
battery_power: 12.4
fuel_capacity: 40
abrp_name:
reg: VR3F3DGYT.*
max_elec_consumption: 70
max_fuel_consumption: 30
- !CarModel
name: 308 SW Hybrid
battery_power: 12.4
@@ -259,9 +305,33 @@
max_elec_consumption: 45
- !CarModel
name: Astra L Hybrid
battery_power: 12.4
battery_power: 11.3
fuel_capacity: 42
abrp_name:
reg: VXKF3DGXTN.*
max_elec_consumption: 70
max_fuel_consumption: 30
- !CarModel
name: 308 SW Hybrid
battery_power: 12.4
fuel_capacity: 40
abrp_name:
reg: VR3F4DGXTN.*
max_elec_consumption: 70
max_fuel_consumption: 30
- !CarModel
name: DS4 E-Tense
battery_power: 12.4
fuel_capacity: 40
abrp_name:
reg: VR1F4DGYTM.*
max_elec_consumption: 70
max_fuel_consumption: 30
- !CarModel
name: New 308
battery_power: 0
fuel_capacity: 56
abrp_name:
reg: VR3FPHNSTN.*
max_elec_consumption: 70
max_fuel_consumption: 30
+1 -1
View File
@@ -114,7 +114,7 @@ function updateMap (data, oldFigure, x, y, lastPos) {
for (trip of trips) {
const xPos = trip.positions[xLabel]
figure.data[0].lat.push(...xPos, null)
figure.data[0].lon.push(...trip.positions[yLabel[0]])
figure.data[0].lon.push(...trip.positions[yLabel[0]], null)
figure.data[0].hovertext.push(...Array(xPos.length).fill(trip[yLabel[1]]), null)
}
if (trip) {
+2 -2
View File
@@ -13,7 +13,7 @@ include = [
[tool.poetry.dependencies]
python = ">=3.7.0, <4.0.0"
paho-mqtt = ">=1.5.0"
dash = ">=2"
dash = ">2.0.0, <2.9.0"
dash-daq = "^0.5.0"
plotly = ">=5"
cryptography = ">=2.6"
@@ -36,7 +36,7 @@ certifi = ">=14.05.14"
six = ">=1.10"
python-dateutil = ">=2.5.3"
urllib3 = ">=1.15.1"
single-source = "^0.3.0"
importlib-metadata = {version = ">=1.7.0", python = "<3.8"}
[tool.poetry.dev-dependencies]
prospector = ">=1.3.0"
+8 -8
View File
@@ -5,8 +5,8 @@ FUEL_CAR_STATUS = {
'airConditioning': {'updatedAt': '2021-04-01T16:17:01Z', 'status': 'Disabled', 'programs': [
{'enabled': False, 'slot': 1, 'recurrence': 'Daily', 'start': 'PT21H40M',
'occurence': {'day': ['Sat']}}]}},
'energy': [{'updatedAt': '2021-02-23T22:29:03Z', 'type': 'Fuel', 'level': 0},
{'updatedAt': '2021-04-01T16:17:01Z', 'type': 'Electric', 'level': 70, 'autonomy': 192,
'energy': [{'createdAt': '2021-02-23T22:29:03Z', 'type': 'Fuel', 'level': 0},
{'createdAt': '2021-04-01T16:17:01Z', 'type': 'Electric', 'level': 70, 'autonomy': 192,
'charging': {'plugged': True, 'status': 'InProgress', 'remainingTime': 'PT0S',
'chargingRate': 20, 'chargingMode': 'Slow', 'nextDelayedTime': 'PT21H30M'}}],
'createdAt': '2021-04-01T16:17:01Z',
@@ -18,22 +18,22 @@ FUEL_CAR_STATUS = {
'href': 'https://api.groupe-psa.com/connectedcar/v4/user/vehicles/myid/status'},
'vehicles': {
'href': 'https://api.groupe-psa.com/connectedcar/v4/user/vehicles/myid'}},
'timed.odometer': {'createdAt': None, 'mileage': 1107.1}, 'updatedAt': '2021-04-01T16:17:01Z'}
'odometer': {'createdAt': None, 'mileage': 1107.1}, 'updatedAt': '2021-04-01T16:17:01Z'}
ELECTRIC_CAR_STATUS = {
"lastPosition": {"type": "Feature", "geometry": {"type": "Point", "coordinates": [-1.59008, 47.274, 30]},
"properties": {"updatedAt": "2021-03-29T06:22:51Z", "type": "Aquire", "signalQuality": 9}},
"properties": {"updatedAt": "2021-03-29T06:22:51Z", "type": "Acquire", "signalQuality": 9}},
"preconditionning": {"airConditioning": {"updatedAt": "2022-03-26T10:52:11Z", "status": "Disabled"}},
"energy": [{"updatedAt": "2021-09-14T20:39:06Z", "type": "Fuel", "level": 0},
{"updatedAt": "2022-03-26T11:02:54Z", "type": "Electric", "level": 59, "autonomy": 122,
"energy": [{"createdAt": "2021-09-14T20:39:06Z", "type": "Fuel", "level": 0},
{"createdAt": "2022-03-26T11:02:54Z", "type": "Electric", "level": 59, "autonomy": 122,
"charging": {"plugged": False, "status": "Disconnected", "remainingTime": "PT0S", "chargingRate": 0,
"chargingMode": "No", "nextDelayedTime": "PT22H31M"}}],
"createdAt": "2022-03-26T11:02:54Z",
"battery": {"voltage": 83.5, "current": 0, "createdAt": "2022-03-26T10:52:11Z"},
"kinetic": {"createdAt": "2021-03-29T06:22:51Z", "moving": True},
"privacy": {"createdAt": "2022-03-26T11:02:53Z", "state": "None"},
"service": {"type": "Electric", "updatedAt": "2022-03-26T11:02:54Z"}, "_links": {"self": {
"service": {"type": "Electric", "createdAt": "2022-03-26T11:02:54Z"}, "_links": {"self": {
"href": "https://api.groupe-psa.com/connectedcar/v4/user/vehicles/aa/status"},
"vehicles": {
"href": "https://api.groupe-psa.com/connectedcar/v4/user/vehicles/aa"}},
"timed.odometer": {"createdAt": None, "mileage": 3196.5}, "updatedAt": "2022-03-26T11:02:54Z"}
"odometer": {"createdAt": None, "mileage": 3196.5}, "updatedAt": "2022-03-26T11:02:54Z"}