Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composite schedule calculation is too high, and is not published correctly #90

Open
1 of 2 tasks
shankari opened this issue Nov 17, 2024 · 4 comments
Open
1 of 2 tasks

Comments

@shankari
Copy link
Collaborator

shankari commented Nov 17, 2024

I have found at least two instances where the composite schedule calculation doesn't work as I expect. It could be that my expectation is incorrect; we need to follow up with the community.

Will keep this summary updated as I find other issues.

@shankari
Copy link
Collaborator Author

issue 2: It looks like schedules should be published under the API topic in MQTT, but they are not.

The API seems to want to publish OCPP status and schedules under the API base topic

    std::string var_ocpp_connection_status = this->api_base + "ocpp/var/connection_status";
    std::string var_ocpp_schedule = this->api_base + "ocpp/var/charging_schedules";
                

                {
                    std::scoped_lock lock(ocpp_data_mutex);
                    this->mqtt.publish(var_ocpp_connection_status, this->ocpp_connection_status);
                    if (this->ocpp_charging_schedule_updated) {
                        this->ocpp_charging_schedule_updated = false;
                        this->mqtt.publish(var_ocpp_schedule, ocpp_charging_schedule.dump());
                    }
                }

But these messages are not currently showing up (the connection status is consistently "unknown" and there are no charging schedules.
Screenshot 2024-11-17 at 12 38 15 PM

We do see charging schedules under everest/ocpp/ocpp_generic`

Screenshot 2024-11-17 at 12 39 35 PM

But they are not being returned in response to the subscriptions that the API has - the newly added log messages here never show up.

    if (this->r_ocpp.size() == 1) {
        this->r_ocpp.at(0)->subscribe_is_connected([this](bool is_connected) {
        EVLOG_info << "Received OCPP connection status callback with is_connected: " << is_connected);
            std::scoped_lock lock(ocpp_data_mutex);
            if (is_connected) {
                this->ocpp_connection_status = "connected";
            } else {
                this->ocpp_connection_status = "disconnected"; 
            }           
        });         
                
        this->r_ocpp.at(0)->subscribe_charging_schedules([this, &var_ocpp_schedule](json schedule) {
        EVLOG_info << "Received OCPP charging schedule update: " << schedule);
            std::scoped_lock lock(ocpp_data_mutex);
            this->ocpp_charging_schedule = schedule;
            this->ocpp_charging_schedule_updated = true;
        });
    }

@shankari
Copy link
Collaborator Author

shankari commented Nov 17, 2024

For the record, it looks like raw charging profiles are stored at /tmp/ocpp201/cp.db. We start after deleting, there are no profiles.

/ext/source# sqlite3 /tmp/ocpp201/cp.db 
SQLite version 3.40.1 2022-12-28 14:03:47
Enter ".help" for usage hints.
sqlite> .tables
AUTH_CACHE            LOCATION_ENUM         PHASE_ENUM          
AUTH_LIST             MEASURAND_ENUM        READING_CONTEXT_ENUM
AUTH_LIST_VERSION     METER_VALUES          TRANSACTIONS        
AVAILABILITY          METER_VALUE_ITEMS     TRANSACTION_QUEUE   
CHARGING_PROFILES     NORMAL_QUEUE        
sqlite> select * from charging_profiles;
sqlite> 

And the default profile is

2024-11-17 20:49:01.513363 [INFO] ocpp:OCPP201     :: About to publish composite charging schedules: 
2024-11-17 20:49:01.513453 [INFO] ocpp:OCPP201     :: {
    "chargingRateUnit": "A",
    "chargingSchedulePeriod": [
        {
            "limit": 48.0,
            "numberPhases": 3,
            "startPeriod": 0
        }
    ],
    "duration": 600,
    "evseId": 0,
    "scheduleStart": "2024-11-17T20:49:01.000Z"
}
2024-11-17 20:49:01.513605 [INFO] ocpp:OCPP201     :: {
    "chargingRateUnit": "A",
    "chargingSchedulePeriod": [
        {
            "limit": 48.0,
            "numberPhases": 3,
            "startPeriod": 0
        }
    ],
    "duration": 600,
    "evseId": 1,
    "scheduleStart": "2024-11-17T20:49:01.000Z"
}
Now, we set a lower limit, which works.
{
  "data": {
    "schedules": [
      {
        "charging_rate_unit": "A",
        "charging_schedule_period": [
          {
            "limit": 20,
            "number_phases": 3,
            "start_period": 0
          }
        ],
        "duration": 600,
        "evse": 0,
        "start_schedule": "2024-11-17T17:30:30.000Z"
      },
      {
        "charging_rate_unit": "A",
        "charging_schedule_period": [
          {
            "limit": 20,
            "number_phases": 3,
            "start_period": 0
          }
        ],
        "duration": 600,
        "evse": 1,
        "start_schedule": "2024-11-17T17:30:30.000Z"
      }
    ]
  },
  "name": "charging_schedules"
}
We then try to set an overlapping schedule
{"id":2000
"chargingProfileKind":"Absolute"
"chargingProfilePurpose":"ChargingStationMaxProfile"
"chargingSchedule":[{"id":0
    "chargingRateUnit":"A"
    "chargingSchedulePeriod":[{"limit":10
    "numberPhases":3
"startPeriod":0}]
"duration":3600
"minChargingRate":0
"startSchedule":"2024-11-17T17:45:00.000Z"}]
"stackLevel":0}

which seems to reset it back to the default

{
  "data": {
    "schedules": [
      {
        "charging_rate_unit": "A",
        "charging_schedule_period": [
          {
            "limit": 48,
            "number_phases": 3,
            "start_period": 0
          }
        ],
        "duration": 600,
        "evse": 0,
        "start_schedule": "2024-11-17T17:34:00.000Z"
      },
      {
        "charging_rate_unit": "A",
        "charging_schedule_period": [
          {
            "limit": 48,
            "number_phases": 3,
            "start_period": 0
          }
        ],
        "duration": 600,
        "evse": 1,
        "start_schedule": "2024-11-17T17:34:00.000Z"
      }
    ]
  },
  "name": "charging_schedules"
}

As I write this out, I wonder if the issue is that we are replacing the old profile and we are not within the time range of the new profile. Let's do a quick check.

@shankari
Copy link
Collaborator Author

shankari commented Nov 17, 2024

At 20:58, sent over 25A and it was applied correctly
2024-11-17 20:58:10.139593 [INFO] ocpp:OCPP201     :: Received SetChargingProfileRequest: {
    "chargingProfile": {
        "chargingProfileKind": "Absolute",
        "chargingProfilePurpose": "ChargingStationMaxProfile",
        "chargingSchedule": [
            {
                "chargingRateUnit": "A",
                "chargingSchedulePeriod": [
                    {
                        "limit": 25.0,
                        "numberPhases": 3,
                        "startPeriod": 0
                    }
                ],
                "duration": 3581,
                "id": 0,
                "minChargingRate": 0.0,
                "startSchedule": "2024-11-17T20:57:19.004Z"
            }
        ],
        "id": 2000,
        "stackLevel": 0
    },
    "evseId": 0
}
2024-11-17 20:58:10.147912 [INFO] ocpp:OCPP201     :: {
    "chargingRateUnit": "A",
    "chargingSchedulePeriod": [
        {
            "limit": 25.0,
            "numberPhases": 3,
            "startPeriod": 0
        }
    ],
    "duration": 600,
    "evseId": 0,
    "scheduleStart": "2024-11-17T20:58:10.000Z"
}
At 21:01, sent over 20A starting two mins earlier and it was applied correctly
2024-11-17 21:01:22.866461 [INFO] ocpp:OCPP201     :: Received SetChargingProfileRequest: {
    "chargingProfile": {
        "chargingProfileKind": "Absolute",
        "chargingProfilePurpose": "ChargingStationMaxProfile",
        "chargingSchedule": [
            {
                "chargingRateUnit": "A",
                "chargingSchedulePeriod": [
                    {
                        "limit": 25.0,
                        "numberPhases": 3,
                        "startPeriod": 0
                    }
                ],
                "duration": 3600,
                "id": 0,
                "minChargingRate": 0.0,
                "startSchedule": "2024-11-17T20:59:00.000Z"
            }
        ],
        "id": 2000,
        "stackLevel": 0
    },
    "evseId": 0
}
2024-11-17 21:01:22.876311 [INFO] ocpp:OCPP201     :: About to publish composite charging schedules: 
2024-11-17 21:01:22.876441 [INFO] ocpp:OCPP201     :: {
    "chargingRateUnit": "A",
    "chargingSchedulePeriod": [
        {
            "limit": 25.0,
            "numberPhases": 3,
            "startPeriod": 0
        }
    ],
    "duration": 600,
    "evseId": 0,
    "scheduleStart": "2024-11-17T21:01:22.000Z"
}
at 21:05, sent over 20A starting two minutes earlier, worked
2024-11-17 21:05:38.792811 [INFO] ocpp:OCPP201     :: Received SetChargingProfileRequest: {
    "chargingProfile": {
        "chargingProfileKind": "Absolute",
        "chargingProfilePurpose": "ChargingStationMaxProfile",
        "chargingSchedule": [
            {
                "chargingRateUnit": "A",
                "chargingSchedulePeriod": [
                    {
                        "limit": 20.0,
                        "numberPhases": 3,
                        "startPeriod": 0
                    }
                ],
                "duration": 3600,
                "id": 0,
                "minChargingRate": 0.0,
                "startSchedule": "2024-11-17T21:03:00.000Z"
            }
        ],
        "id": 2000,
        "stackLevel": 0
    },
    "evseId": 0
}
with messageId: fb3640a6-c371-4ea1-b4fd-80bd334ac302
2024-11-17 21:05:38.796861 [INFO] ocpp:OCPP201     :: Accepting SetChargingProfileRequest
2024-11-17 21:05:38.799799 [INFO] ocpp:OCPP201     :: About to publish composite charging schedules: 
2024-11-17 21:05:38.799888 [INFO] ocpp:OCPP201     :: {
    "chargingRateUnit": "A",
    "chargingSchedulePeriod": [
        {
            "limit": 20.0,
            "numberPhases": 3,
            "startPeriod": 0
        }
    ],
    "duration": 600,
    "evseId": 0,
    "scheduleStart": "2024-11-17T21:05:38.000Z"
}

** Note that the duration of the composite schedule is only 600 secs (10 mins), although the charging profile is for an hour.
Aha!! so that is how it should be updated **

at 21:15, sent over 15A starting at 21:20, initially set to default, then set to the clamped value later when the schedule takes effect
2024-11-17 21:15:36.826143 [INFO] ocpp:OCPP201     :: Received SetChargingProfileRequest: {
    "chargingProfile": {
        "chargingProfileKind": "Absolute",
        "chargingProfilePurpose": "ChargingStationMaxProfile",
        "chargingSchedule": [
            {
                "chargingRateUnit": "A",
                "chargingSchedulePeriod": [
                    {
                        "limit": 15.0,
                        "numberPhases": 3,
                        "startPeriod": 0
                    }
                ],
                "duration": 3600,
                "id": 0,
                "minChargingRate": 0.0,
                "startSchedule": "2024-11-17T21:20:00.000Z"
            }
        ],
        "id": 2000,
        "stackLevel": 0
    },
    "evseId": 0
}

2024-11-17 21:17:28.392118 [INFO] ocpp:OCPP201     :: {
    "chargingRateUnit": "A",
    "chargingSchedulePeriod": [
        {
            "limit": 48.0,
            "numberPhases": 3,
            "startPeriod": 0
        },
        {
            "limit": 15.0,
            "numberPhases": 3,
            "startPeriod": 152
        }
    ],
    "duration": 600,
    "evseId": 0,
    "scheduleStart": "2024-11-17T21:17:28.000Z"
}
2024-11-17 21:38:38.560528 [INFO] ocpp:OCPP201     :: About to publish composite charging schedules: 
2024-11-17 21:38:38.560625 [INFO] ocpp:OCPP201     :: {
    "chargingRateUnit": "A",
    "chargingSchedulePeriod": [
        {
            "limit": 15.0,
            "numberPhases": 3,
            "startPeriod": 0
        }
    ],
    "duration": 600,
    "evseId": 0,
    "scheduleStart": "2024-11-17T21:38:38.000Z"
}

False alarm; I just didn't understand this properly!

@shankari
Copy link
Collaborator Author

For the record, at the end of that time period, we do get the two entries showing when the curtailment will end

2024-11-17 22:17:38.712782 [INFO] ocpp:OCPP201     :: {
    "chargingRateUnit": "A",
    "chargingSchedulePeriod": [
        {
            "limit": 15.0,
            "numberPhases": 3,
            "startPeriod": 0
        },
        {
            "limit": 48.0,
            "numberPhases": 3,
            "startPeriod": 142
        }
    ],
    "duration": 600,
    "evseId": 1,
    "scheduleStart": "2024-11-17T22:17:38.000Z"
}

shankari pushed a commit to US-JOET/everest-demo that referenced this issue Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant