This looks like a bug in the frontend.
I did a quick test. I created a script that set an input_datetime just like you do. If I run the script I see that the service is called with the timestamp being a number resulting from the template being evaluated. And I see the input_datetime state changing accordingly.
Next, if I open the “more info” dialog for the input_datetime, I see the input_datetime.set_datetime service being called, twice, and the input_datetime’s state changing when it shouldn’t be!
Here is what happens when the script is run:
2021-04-05 14:36:56 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=script, service=turn_on, service_data=entity_id=script.test>
2021-04-05 14:36:56 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event script_started[L]: name=test, entity_id=script.test>
2021-04-05 14:36:56 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=script.test, old_state=<state script.test=off; last_triggered=2021-04-05T14:35:04.873679-05:00, mode=single, current=0, friendly_name=test @ 2021-04-05T14:35:04.886389-05:00>, new_state=<state script.test=on; last_triggered=2021-04-05T14:36:56.067788-05:00, mode=single, current=1, friendly_name=test @ 2021-04-05T14:36:56.067920-05:00>>
2021-04-05 14:36:56 INFO (MainThread) [homeassistant.components.script.test] test: Running script sequence
2021-04-05 14:36:56 INFO (MainThread) [homeassistant.components.script.test] test: Executing step call service
2021-04-05 14:36:56 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=input_datetime, service=set_datetime, service_data=timestamp=1617651416.069873, entity_id=['input_datetime.test']>
2021-04-05 14:36:56 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=input_datetime.test, old_state=<state input_datetime.test=2021-04-05 14:35:00; editable=True, has_date=True, has_time=True, year=2021, month=4, day=5, hour=14, minute=35, second=0, timestamp=1617651300.0, friendly_name=test @ 2021-04-05T14:35:32.549968-05:00>, new_state=<state input_datetime.test=2021-04-05 14:36:56; editable=True, has_date=True, has_time=True, year=2021, month=4, day=5, hour=14, minute=36, second=56, timestamp=1617651416.069873, friendly_name=test @ 2021-04-05T14:36:56.077197-05:00>>
2021-04-05 14:36:56 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=script.test, old_state=<state script.test=on; last_triggered=2021-04-05T14:36:56.067788-05:00, mode=single, current=1, friendly_name=test @ 2021-04-05T14:36:56.067920-05:00>, new_state=<state script.test=off; last_triggered=2021-04-05T14:36:56.067788-05:00, mode=single, current=0, friendly_name=test @ 2021-04-05T14:36:56.079006-05:00>>
And, believe it or not, here is what happens when the “more info” window is opened on the input_datetime entity:
2021-04-05 14:37:08 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=input_datetime, service=set_datetime, service_data=entity_id=input_datetime.test, time=14:36, date=2021-04-05>
2021-04-05 14:37:08 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=input_datetime, service=set_datetime, service_data=entity_id=input_datetime.test, time=14:36, date=2021-04-05>
2021-04-05 14:37:08 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=input_datetime.test, old_state=<state input_datetime.test=2021-04-05 14:36:56; editable=True, has_date=True, has_time=True, year=2021, month=4, day=5, hour=14, minute=36, second=56, timestamp=1617651416.069873, friendly_name=test @ 2021-04-05T14:36:56.077197-05:00>, new_state=<state input_datetime.test=2021-04-05 14:36:00; editable=True, has_date=True, has_time=True, year=2021, month=4, day=5, hour=14, minute=36, second=0, timestamp=1617651360.0, friendly_name=test @ 2021-04-05T14:37:08.052903-05:00>>