# 🚧 Building an EV Smart Routing Request with Charging Station Filters (csfs) This tutorial explains how to construct a request for the **EV Smart Routing API** that includes **charging station filters (csfs)**. Filters allow you to restrict or prioritize which charging stations are considered during route planning. ## 🧱 Basic Structure with csfs A request including charging station filters looks like this: ``` { "geoserver": "osm", "csps": ["ecoMovement"], "csfs": [ "chargingPoint.nominalPower >= 50", "pool.brand != Electra" ], "vehicle": { "initBatLvl": 100, "key": "eb1e9464-8654-4c01-bedd-b2f95412a60d", "payload": 75 }, "start": { "lon": 2.34755, "lat": 48.85708 }, "stop": { "lon": 4.35497, "lat": 50.83857 }, "condition": { "chargePluggingTime": 300 }, "routingVehicleProfile": { "transportMode": "CAR" } } ``` ## 🧩 1. csfs β€” Charging Station Filters The `csfs` parameter is an array of string filters. Each filter follows the syntax: ``` CLASS.FIELD OPERATOR VALUE ``` - **CLASS** β†’ `pool`, `station`, `chargingPoint`, `vehicleAccess` - **FIELD** β†’ a supported field (e.g. `brand`, `nominalPower`, `creditCardPayment`) - **OPERATOR** β†’ `==`, `!=`, `>=`, `/=/` (regex), … - **VALUE** β†’ the value to compare against πŸ‘‰ Multiple filters can be listed in the array. πŸ‘‰ Use `||` for OR conditions between filters. βœ… Example: Keep only fast charging stations ``` "csfs": [ "chargingPoint.nominalPower >= 50" ] ``` > ➑️ Keeps only stations with at least 50 kW. βœ… Example: Prefer IONITY or Tesla stations ``` "csfs": [ "pool.brand /= /IONITY|TESLA/" ] ``` > ➑️ Prioritizes stations operated by IONITY or Tesla. βœ… Example: Exclude a specific brand ``` "csfs": [ "pool.brand != Electra" ] ``` > ➑️ Excludes stations operated by Electra. βœ… Example: Select stations based on the total number of charging points available in the pool. ``` "csfs": [ "pool.numberOfChargingPoint >= 4" ] ``` > ➑️ Keeps only pools that have at least 4 charging points. βœ… Example: Keep only charging stations currently reported as available ``` "csfs": [ "station.available == true" ] ``` ➑️ Excludes stations flagged as unavailable. βœ… Example: Filter charging points by the supported billing currency. ``` "csfs": [ "chargingPoint.currency IN EUR;GBP;DKK" ] ``` ➑️ Keeps only charging points that accept EUR, GBP, or DKK. ## 🎯 2. Actions in CSFS Besides simple filters, you can also define **actions** that are executed when a condition is matched. The syntax is: Multiple actions can be chained with `->`. ### βš–οΈ `prefCoeff` The `prefCoeff` (**preference coefficient**) is used to **prioritize** or **deprioritize** charging stations when a filter matches. It does not exclude stations but adjusts their **weight** in the selection process. - **Neutral value:** `1.0` β†’ default, no preference. - **Preferred:** `]1.0, 10.0]` β†’ increases priority. - Example: `prefCoeff=5.0;` β†’ station is 5x more likely to be chosen. - **Avoided:** `[0.1, 1.0[` β†’ decreases priority. - Example: `prefCoeff=0.5;` β†’ station is half as likely to be chosen. - **Bounds:** - Minimum: `0.1` (cannot be 0 or negative). - Maximum: `10.0`. βœ… Use `prefCoeff > 1` to **encourage** preferred partners/networks. ❌ Use `prefCoeff < 1` to **discourage** costly or unwanted stations. πŸ“Š **Quick reference** | **Value** | **Meaning** | **Example usage** | | --- | --- | --- | | `1.0` | Neutral (default, no preference) | No preference | | `0.5` | Avoid (half as likely) | Discourage expensive networks | | `0.1` | Strongly avoid (minimum) | Last resort only | | `2.0` | Prefer (2x more likely) | Encourage trusted partners | | `5.0` | Strong preference | Prioritize IONITY or Tesla | | `10.0` | Maximum preference (cap) | Force ultra-fast chargers | ### 🧩 Example with `prefCoeff` ``` "csfs": [ "pool.brand == IONITY -> prefCoeff=5.0;" ] ``` ➑️ In this case, IONITY stations are prioritized. Another combined example: ``` "csfs": [ "chargingPoint.nominalPower >= 7", "chargingPoint.nominalPower >= 50 -> prefCoeff=6.0;", "pool.brand == IONITY -> prefCoeff=5.0;", "pool.brand == TESLA -> prefCoeff=5.0;", "chargingPoint.currency IN EUR;GBP;DKK -> prefCoeff=3.0;" ] ``` ➑️ This keeps only charging points with **β‰₯7 kW**, prefers **fast chargers (β‰₯50 kW)**, gives higher priority to **IONITY** and **TESLA** networks, and favors charging points that accept **EUR, GBP, or DKK** currencies. **Full Example with prefCoeff** ``` { "geoserver": "osm", "csps": [ "ecoMovement" ], "csfs": [ "chargingPoint.nominalPower >= 50", "pool.brand /= /Electra/-> prefCoeff=9.0;" ], "vehicle": { "initBatLvl": 40, "key": "4d4f1d56-5014-4840-b5cf-7c42aad2d309", "payload": 75 }, "start": { "lon": 7.23521295426402, "lat": 44.0040293 }, "stop": { "lon": -4.48656, "lat": 48.39043 }, "condition": { "minBatLvl": 10, "minArrivalBatLvl": 15, "temperature": 20, "currency": "EUR", "encodedGeometry": true, "departureTime": 1758877080000, "chargePluggingTime": 300, "allowNaStatus": true } } ``` ## πŸš— 2. vehicle ``` "vehicle": { "initBatLvl": 100, "key": "d729502b-12ba-4adb-89bd-cff6a2d00919", "payload": 75 } ``` ## πŸ—ΊοΈ 3. start & stop ``` "start": { "lon": 7.27768, "lat": 43.70032 }, "stop": { "lon": 1.44863, "lat": 43.60579 } ``` ## βš™οΈ 4. condition ``` "condition": { "minBatLvl": 10, "minArrivalBatLvl": 15, "chargePluggingTime": 300 } ``` ## πŸ› οΈ 5. routingVehicleProfile ``` "routingVehicleProfile": { "transportMode": "CAR" } ``` ## πŸ“Œ Full Example ``` { "geoserver": "osm", "csps": ["ecoMovement"], "csfs": [ "chargingPoint.nominalPower >= 50", "pool.brand /= /IONITY/" ], "vehicle": { "initBatLvl": 100, "key": "d729502b-12ba-4adb-89bd-cff6a2d00919", "payload": 75 }, "start": { "lon": 7.27768, "lat": 43.70032 }, "stop": { "lon": 1.44863, "lat": 43.60579 }, "condition": { "minBatLvl": 10, "minArrivalBatLvl": 15, "temperature": 20, "chargePluggingTime": 300 }, "routingVehicleProfile": { "transportMode": "CAR" } } ```