Conditional display lovelace

You could use the scheduler card that allows you to choose either option (sunrise/sunset or a time).

It also does away with the need to write an automation.