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

New EVCC config isAliveAfterSession introduced #361

Merged
merged 3 commits into from
Jan 22, 2024

Conversation

touchlinux
Copy link
Contributor

Whether or not the EVCC keeps running after a charging session is finished
Default 'True' should not affect EVCC behaviour
When set it to 'False', EVCC terminates by StopNotification on 'TCP connection closed'

Tested with modified evcc_config_eim_dc.json to verify EVCC is terminated gracefully.

{
	"supportedProtocols": [
		"ISO_15118_2"
	],
	"supportedEnergyServices": [
		"DC"
	],
	"energyTransferMode": "DC_extended",
	"isCertInstallNeeded": false,
	"useTls": false,
	"isAliveAfterSession": false
}

* Whether or not the EVCC keeps running after a charging session is finished
* Default 'True' should not affect EVCC behaviour
* When set it to 'False', EVCC terminates by StopNotification on 'TCP connection closed'
@@ -306,7 +306,7 @@ async def __init__. Therefore, we need to create a separate async

logger.info("Communication session handler started")

await wait_for_tasks(self.list_of_tasks)
await wait_for_tasks(self.list_of_tasks, asyncio.ALL_COMPLETED)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this stop the session from ending if say for instance the udp server fails to start? As self.get_from_rcv_queue() wouldn't have exited.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are right, asyncio.ALL_COMPLETED is not necessary. wait_for_tasks() default argument asyncio.FIRST_EXCEPTION should suffice.
"FIRST_EXCEPTION | The function will return when any future finishes by raising an exception. If no future raises an exception then it is equivalent to ALL_COMPLETED." - https://docs.python.org/3/library/asyncio-task.html#waiting-primitives
Confirmed by testing without it.

README.md Outdated
@@ -173,6 +173,7 @@ Supported settings in EVCC configuration are given below:
| sdpRetryCycles | `1` | Indicates how often shall SDP (SECC Discovery Protocol) retries happen before reverting to using nominal duty cycle PWM-based charging |
| maxContractCerts | `3` | Maximum amount of contract certificates the EV stores. |
| maxSupportingPoints | `1024` | Indicates the maximum number of entries the EVCC supports within the sub-elements of a ScheduleTuple |
| isAliveAfterSession | `True` | Whether or not the EVCC keeps running after a charging session is finished |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies I didn't clarify this under issues. As the user can't proceed until the session is killed anyway, I don't see much value in making this a configurable field. The behaviour you have added to gracefully exit is the only change required. Do you have a use case in mind where keeping the session alive would be useful?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't have any use case in mind for keeping the session alive. I wanted to keep the session by default and stop the session when the configuration is used. However, it seems like the new configuration key is not necessary as stopping session can be the default behavior👍. I personally think, evcc should be terminated as a default after session, because evcc is not starting a new session again.

Comment on lines 553 to 555
if notification.successful:
if not self.config.is_alive_after_session:
break
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following my suggestion from above, I think this would suffice. What do you think?

Suggested change
if notification.successful:
if not self.config.is_alive_after_session:
break
if notification.successful:
break

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me. Added another commit to fix all together.

touchlinux and others added 2 commits January 22, 2024 12:08
* The isAliveAfterSession is not required anymore
* EVCC calls wait_for_tasks with default return_when=FIRST_EXCEPTION
  because wait_for_tasks returns both when
  1)Exception on any task in the list or 2)Completing all tasks
@shalinnijel2
Copy link
Contributor

Hi @touchlinux . All good. I'm merging the changes to master. Hope you don't mind. Thank you for your contribution. :).
I'll close the issue related to this as well. Feel free to reopen if there is anything more you would like to add to this.

@shalinnijel2 shalinnijel2 merged commit ebe59ca into EcoG-io:master Jan 22, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants