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

Not able to start remote transaction #656

Closed
sauravkhakurel opened this issue Sep 5, 2024 · 2 comments
Closed

Not able to start remote transaction #656

sauravkhakurel opened this issue Sep 5, 2024 · 2 comments

Comments

@sauravkhakurel
Copy link

sauravkhakurel commented Sep 5, 2024

I have written an implementation for OCPP 1.6 by using this library and this is the code for that. On top of that the code does not seem to work when call is used to initiate request

async def remote_start_transaction(self, id_tag, connector_id):
    logger.info("Received RemoteStartTransaction for id_tag: %s", id_tag)
    try:
        payload = call.RemoteStartTransaction(
            id_tag=id_tag,
            connector_id=connector_id,
            charging_profile={
                "chargingProfileId": 1,  # Unique identifier of the charging profile
                "transactionId": 123456,  # (Optional) ID of the transaction to which this profile applies
                "stackLevel": 1,  # Priority level of the charging profile; higher numbers have higher priority
                "chargingProfilePurpose": "TxDefaultProfile",  # Purpose of the charging profile (TxProfile, TxDefaultProfile, ChargePointMaxProfile)
                "chargingProfileKind": "Absolute",  # Kind of charging profile (Absolute, Recurring, Relative)
                "recurrencyKind": "Daily",  # (Optional) Recurring pattern for the schedule (Daily, Weekly)
                "validFrom": "2024-09-04T12:00:00Z",  # (Optional) Start date and time from which the profile is valid
                "validTo": "2024-09-04T14:00:00Z",  # (Optional) End date and time until which the profile is valid
                "chargingSchedule": {
                    "duration": 7200,  # (Optional) Duration of the schedule in seconds
                    "startSchedule": "2024-09-04T12:00:00Z",  # (Optional) Start date and time of the schedule
                    "chargingRateUnit": "W",  # Unit for charging rate (A for Amps, W for Watts)
                    "chargingSchedulePeriod": [
                        {
                            "startPeriod": 0,  # Start time of the period in seconds from the beginning of the schedule
                            "limit": 32.0,  # Power or current limit during the period
                            "numberPhases": 3,  # (Optional) Number of phases for which the current should be applied
                        },
                        {
                            "startPeriod": 3600,  # Another period starting at 3600 seconds (1 hour)
                            "limit": 16.0,  # Reduced power limit
                            "numberPhases": 3,
                        },
                    ],
                    "minChargingRate": 5.0,  # (Optional) Minimum charging rate during the schedule
                },
            },
        )
        response = await self.call(payload)
        if response.status == RemoteStartStopStatus.accepted:
            logger.info(
                "Remote Start Transaction accepted for id_tag: %s",
                id_tag,
            )
        else:
            logger.warning(
                "Remote Start Transaction rejected for id_tag: %s",
                id_tag,
            )
        return response.status
    except Exception as e:
        logger.error("Failed to start remote transaction: %s", e)
        return RemoteStartStopStatus.rejected
INFO 2024-09-05 02:50:03,431 charge_point 10 125289594051456 charge_point_id: send [2,"af92451a-09e9-480b-90d2-158224cbed97","RemoteStartTransaction",{"idTag":"1","connectorId":0,"chargingProfile":{"chargingProfileId":1,"transactionId":123456,"stackLevel":1,"chargingProfilePurpose":"TxDefaultProfile","chargingProfileKind":"Absolute","recurrencyKind":"Daily","validFrom":"2024-09-04T12:00:00Z","validTo":"2024-09-04T14:00:00Z","chargingSchedule":{"duration":7200,"startSchedule":"2024-09-04T12:00:00Z","chargingRateUnit":"W","chargingSchedulePeriod":[{"startPeriod":0,"limit":32.0,"numberPhases":3},{"startPeriod":3600,"limit":16.0,"numberPhases":3}],"minChargingRate":5.0}}}]

Exception is raised when the await self.call(payload) is executed with the following error

ERROR 2024-09-05 02:58:21,204 consumer 10 139506699139968 Failed to start remote transaction: 'NoneType' object has no attribute 'send

I am not able to figure out what NoneType this is referring to. Even when sending only the id_tag in the payload the same error is returned even if the other fields connectorID and chargingProfile are optional.

Any help is appreciated, thanks

@jainmohit2001
Copy link
Collaborator

jainmohit2001 commented Sep 24, 2024

Hi @sauravkhakurel, can you confirm that the ChargePoint class is initiated with the right parameters? It requires a connection parameter which should not be None.

@sauravkhakurel
Copy link
Author

Hi @sauravkhakurel, can you confirm that the ChargePoint class is initiated with the right parameters? It requires a connection parameter which should not be None.

Its solved now. After inspecting the flow in the OCPP package I was able to figure out the issue of websocket not being passed as the connection parameter. Thanks for the info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants