mirror of
https://github.com/flobz/psa_car_controller.git
synced 2026-08-21 17:06:18 +00:00
fix: #726 chc is None
This commit is contained in:
committed by
Florian BEZANNIER
parent
cfeb719ba9
commit
e9b5a84437
@@ -48,7 +48,7 @@ class PSACarController(metaclass=Singleton):
|
||||
def __init__(self):
|
||||
self.args = parse_args()
|
||||
self.myp: PSAClient
|
||||
self.chc: ChargeControls
|
||||
self.chc: ChargeControls = None
|
||||
self.config_name = DEFAULT_NAME
|
||||
self.is_good: bool = True
|
||||
self.offline = self.args.offline
|
||||
|
||||
@@ -106,15 +106,19 @@ def get_position(vin):
|
||||
def get_charge_control():
|
||||
logger.info(request)
|
||||
vin = request.args['vin']
|
||||
charge_control = APP.chc.get(vin)
|
||||
if charge_control is None:
|
||||
return jsonify("error: VIN not in list")
|
||||
if 'hour' in request.args and 'minute' in request.args:
|
||||
charge_control.set_stop_hour([int(request.args["hour"]), int(request.args["minute"])])
|
||||
if 'percentage' in request.args:
|
||||
charge_control.percentage_threshold = int(request.args['percentage'])
|
||||
APP.chc.save_config()
|
||||
return jsonify(charge_control.get_dict())
|
||||
if APP.chc:
|
||||
charge_control = APP.chc.get(vin)
|
||||
if charge_control is None:
|
||||
return jsonify({"error": "VIN not in list"})
|
||||
if 'hour' in request.args and 'minute' in request.args:
|
||||
charge_control.set_stop_hour([int(request.args["hour"]), int(request.args["minute"])])
|
||||
if 'percentage' in request.args:
|
||||
charge_control.percentage_threshold = int(request.args['percentage'])
|
||||
APP.chc.save_config()
|
||||
return jsonify(charge_control.get_dict())
|
||||
error = "Charge control not setup check your PSACC configuration and logs"
|
||||
logger.error(error)
|
||||
return jsonify({"error": error})
|
||||
|
||||
|
||||
@app.route('/positions')
|
||||
|
||||
Reference in New Issue
Block a user