Templating Time Sensor

I want to be able to calculate when my next bus leaves the bus comes every hour on 44 mins past the hour. I would like a sensor that tells me time until next bus arrives.

How about this:

sensor:
  - platform: time_date
    display_options:
      - 'time'
  - platform: template
    sensors:
      next_bus:
        friendly_name: Time to next bus
        unit_of_measurement: min
        value_template: >
          {% set min_now = states('sensor.time').split(':')[1]|int %}
          {{ 44 - min_now if min_now < 44 else 104 - min_now }}
2 Likes

thanks I had the top line of the value template now seeing the 44min reference it makes sense thanks for the learning.