How do I set the attributes of a time of day sensor?

I have a time of day sensor that I edit to adjust the time of day on and off in the dashboard.
but want to automate the setting of these values, but cannot find anything to show me how todo this.

How do you automate the setting of the after and before attributes?

Any help much appritiated

This is a very strange question to ask. Normally you set the ToD options and leave them. Indicating this could be a case of https://xyproblem.info/

Don’t tell us the difficulties with your chosen solution (editing the ToD sensor grammatically).

Tell us what problem you are trying to solve with the constantly edited ToD sensor. Why do you need to edit it?

There is probably a more appropriate solution than using the ToD sensor.