Adjust calculate leave time template

Hi all! Quick question,

I have this sensor:
calc_leave_time:
value_template: ‘{{ (as_timestamp(states.calendar.google_cal.attributes.start_time) - states.sensor.current_location_to_next_calendar_event.attributes.duration.split(" “)[0] | int *60 ) | timestamp_custom(”%Y-%m-%d %H:%M") }}’
unit_of_measurement: ‘time’

How can i make another template sensor that takes whatever the cal_leave_time is and add an additional 40 mins?

So for example, if the calculated leave time is 12:00PM. The new sensor’s output would be 11:20AM.

Pretty much the same way you did the first one:

value_template: >
  {{ (as_timestamp('sensor.calc_leave_time') - 40*60)
     |timestamp_custom('%Y-%m-%d %H:%M') }}

Thank you! I actually borrowed the code i posted from another project. Got it to work but got lost figuring out exactly what the specific parts (timestamp, int, etc) are doing.

When i put what you posted, i’m getting an “unknown” value even those sensor.calc_leave_time states “2018-10-11 08:51”

Oops, that’s because I forgot one important part. It should be:

value_template: >
  {{ (as_timestamp(states('sensor.calc_leave_time')) - 40*60)
     |timestamp_custom('%Y-%m-%d %H:%M') }}

Sorry about that.

Sorry for the delay. Been swamped at work.
This worked! Thanks for your time and your help!!!