Difference in seconds between input_datetime and now()

  • now() reports the current date and time as a datetime object.
  • Your input_datetime entity reports time as a string.

You can’t subtract a string from a datetime object.

You have to ensure both are datetime objects or integers representing their respective Unix timestamps.

Try this version which converts the input_datetime’s value to a datetime object.

{{ now() - now().replace(hour=state_attr('input_datetime.volume_night_alexas', 'hour'), minute=state_attr('input_datetime.volume_night_alexas', 'minute')) < timedelta(seconds=60) }}
1 Like