Copy a timestamp from input_datetime(1) to input_datetime(2)


I want to copy the time of a timestamp to a second timestamp when I push on a button.

For this situation i made 2 input_datetime’s with heplpers.

For now i can’t figure out how i have to do this. It have to be 2 different timestamps and is has to copy the timestamp input_datetime(1) to input_datetime(2) only when i push a specifiek button. The moment to synchronise when i push on a button did i make with an automation.

Thanks in advance!

Here’s an example of an automation that’s triggered by input_button.your_button and sets value of input_datetime.your_second_datetime to the same value as input_datetime.your_first_datetime.

alias: example
  - platform: state
    entity_id: input_button.your_button
condition: []
  - service: input_datetime.set_datetime
      entity_id: input_datetime.your_second_datetime
      timestamp: "{{ state_attr('input_datetime.your_first_datetime', 'timestamp') }}"

Reference: Input Datetime