Skip to content

Commit

Permalink
Merge pull request #59 from louisg1337/scp-script-json
Browse files Browse the repository at this point in the history
Added in support for MaEVe scp to take in json file
  • Loading branch information
shankari authored Jun 13, 2024
2 parents 0feea2d + 1cbb904 commit 67b82a9
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 9 deletions.
52 changes: 52 additions & 0 deletions demo-scripts/charging-profile-0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"chargingProfileKind": "Absolute",
"chargingProfilePurpose": "TxProfile",
"chargingSchedule": [
{
"chargingRateUnit": "W",
"chargingSchedulePeriod": [
{
"limit": 22.5,
"startPeriod": 0,
"numberPhases": 3
},
{
"limit": 20.0,
"startPeriod": 3600,
"numberPhases": 3
}
],
"id": 1,
"minChargingRate": 5.0,
"salesTariff": {
"id": 1,
"numEPriceLevels": 2,
"salesTariffDescription": "Standard Tariff",
"salesTariffEntry": [
{
"relativeTimeInterval": {
"start": 0,
"duration": 3600
},
"consumptionCost": [
{
"cost": [
{
"amount": 15,
"costKind": "RelativePricePercentage"
}
],
"startValue": 10.0
}
]
}
]
}
}
],
"id": 1,
"stackLevel": 0,
"transactionId": "12345",
"validFrom": "2024-06-07T10:00:00Z",
"validTo": "2024-06-07T18:00:00Z"
}
75 changes: 75 additions & 0 deletions demo-scripts/charging-profile-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"chargingProfileKind": "Recurring",
"chargingProfilePurpose": "TxDefaultProfile",
"chargingSchedule": [
{
"chargingRateUnit": "A",
"chargingSchedulePeriod": [
{
"limit": 30.0,
"startPeriod": 0,
"numberPhases": 1
},
{
"limit": 25.0,
"startPeriod": 1800,
"numberPhases": 1
},
{
"limit": 15.0,
"startPeriod": 3600,
"numberPhases": 1
}
],
"id": 2,
"minChargingRate": 10.0,
"salesTariff": {
"id": 2,
"numEPriceLevels": 3,
"salesTariffDescription": "Discount Tariff",
"salesTariffEntry": [
{
"relativeTimeInterval": {
"start": 0,
"duration": 1800
},
"consumptionCost": [
{
"cost": [
{
"amount": 10,
"costKind": "RelativePricePercentage"
}
],
"startValue": 5.0
}
]
},
{
"relativeTimeInterval": {
"start": 1800,
"duration": 3600
},
"consumptionCost": [
{
"cost": [
{
"amount": 12,
"costKind": "RelativePricePercentage"
}
],
"startValue": 7.0
}
]
}
]
}
}
],
"id": 2,
"stackLevel": 1,
"transactionId": "67890",
"validFrom": "2024-06-08T08:00:00Z",
"validTo": "2024-06-08T20:00:00Z"
}

29 changes: 20 additions & 9 deletions demo-scripts/maeve-set-charging-profile.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
#!/bin/bash

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <chargingStation>"
if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
echo "Usage: $0 <chargingStation> <jsonFile>"
exit 1
fi

CS=$1

echo "setChargingProfile called with Charging Station: ${CS}"

curl -X POST \
"http://localhost:9410/api/v0/cs/${CS}/setchargingprofile" \
-H "Content-Type: application/json" \
-d '{
JSON_FILE=$2
JSON_DATA='{
"chargingProfileKind": "Absolute",
"chargingProfilePurpose": "TxProfile",
"chargingSchedule": [
Expand Down Expand Up @@ -64,3 +59,19 @@ curl -X POST \
"validFrom": "2024-06-07T10:00:00Z",
"validTo": "2024-06-07T18:00:00Z"
}'

# Read JSON file and do some error handling
if [ -n "$JSON_FILE" ]; then
if [ ! -f "$JSON_FILE" ]; then
echo "Error: JSON file '$JSON_FILE' not found!"
exit 1
fi
JSON_DATA=$(cat "$JSON_FILE")
fi

echo "setChargingProfile called with Charging Station: ${CS}"

curl -X POST \
"http://localhost:9410/api/v0/cs/${CS}/setchargingprofile" \
-H "Content-Type: application/json" \
-d "$JSON_DATA"

0 comments on commit 67b82a9

Please sign in to comment.