def _load_query(id): cp = ChargePoint.fromID(id) # constructing search query search_query = {} if (cp.sgID is not None): search_query["sgID"] = cp.sgID if (cp.stationID is not None): search_query["stationID"] = cp.stationID return search_query
def clear_shed(id): if DEBUG: print("enter clear_shed " + id) shed_query = {} cp = ChargePoint.fromID(id) if (cp.stationID is not None): station_query = {"stationID": cp.stationID} if (cp.portID is not None): # technically can provide multiple ports station_query["Ports"] = [{"Port": {"portNumber": cp.portID}}] shed_query["shedStation"] = station_query else: shed_query["shedGroup"] = {"sgID": cp.sgID} if DEBUG: print("clear_shed query = " + str(shed_query)) return _get_client().service.clearShedState(shed_query)
def process_load(load_res): res = [] sgID = load_res['sgID'] now = time.time() for station in load_res['stationData']: stationID = station['stationID'] for port in station['Port']: cp = ChargePoint(sgID, stationID, port['portNumber']) vehicle = port['credentialID'] watt = float(port['portLoad']) res.append({ 'point': cp.ID, 'vehicle': vehicle, 'watt': watt, 'measured': now, 'start': _CHARGE_SESSIONS.get_start(vehicle, watt, now) }) return res
def shed_load(id, percent_amount=0, absolute_amount=0, time_interval=0): if DEBUG: print("Enter shed_load") cp = ChargePoint.fromID(id) shed_query = {} # if station parameters present, construct the more restrictive query if (cp.stationID is not None): station_query = {"stationID": cp.stationID} if (cp.portID is not None): port_query = {"portNumber": cp.portID} if (absolute_amount is not None): port_query["allowedLoadPerPort"] = absolute_amount else: # ns0:percentShedRange ?? port_query["percentShedPerPort"] = percent_amount station_query["Ports"] = [{"Port": port_query}] shed_query["shedStation"] = station_query else: # construct a more general stationGroup query shed_query["shedGroup"] = {"sgID": cp.sgID} # shed amount if ((absolute_amount is None) and (percent_amount is None)): raise EVException( "Both absolute_amount and Percent_amount cannot be None", constants.ERR_MISSING_AMOUNT) if (absolute_amount is not None): shed_query["allowedLoadPerStation"] = absolute_amount else: # ns0:percentShedRange?? shed_query["percentShedPerStation"] = percent_amount # shed interval, 0 means no limit shed_query["timeInterval"] = time_interval if DEBUG: print("shedQuery = " + str(shed_query)) return _get_client().service.shedLoad(shed_query)
# Copyright 2020 program was created VMware, Inc. # SPDX-License-Identifier: Apache-2.0 import constants from ev import ChargePoint, get_ENV_val import cp import time sgID = get_ENV_val("sgID") stationID = get_ENV_val("stationID") portID = get_ENV_val("portID") res0 = cp.get_load(sgID) spID = ChargePoint(None, stationID, portID).ID # Experimental phase, to not affect live users, cap at 6.6 res1 = cp.shed_load(spID, absolute_amount=6.6, time_interval=10) print("Sleeping .. a bit for shed_load to take effect") time.sleep(15) LOAD2 = cp.get_load(spID) res2 = cp.clear_shed(spID) print(res2) print("Sleeping .. a bit for clear_shed to take effect") time.sleep(15) res3 = cp.get_load(spID) print("Sleeping .. a bit for clear_shed for station_group") time.sleep(10) res4 = cp.clear_shed(sgID) print(res4) res5 = cp.get_load(spID)