Estimated completion time from time remaining

Hi,

I’m trying to create a notification with the estimated completion time of my washing machine… however I cant figure out how to add the remaining time to the current time
the remaining time is in the format H:MM as an attribute to sensor.washer
Ive tried loads of different combos of as_timestamp or .timestamp() but always resulting in type errors

{{ now() + strptime(state_attr('sensor.washer', 'remain_time'),  '%H:%M') | timestamp_custom('%H:%M') }}

ive had a good read through the EPIC time conversion topic, but still cant make this work. There are several other topics asking for similar things but cant find a working solution

Try this:

{{ now() + timedelta(hours=state_attr('sensor.washer', 'remain_time').split(':')[0]|int(0)), minutes=state_attr('sensor.washer', 'remain_time').split(':')[1]int(0) }}
{% set t = strptime(state_attr('sensor.washer', 'remain_time'), '%H:%M', today_at()).time() %}
{{ now() + timedelta(hours=t.hour, minutes=t.minute, seconds=t.second) }}

EDIT

Correction. Overlooked to include the attribute.

Removed unnecessary argument for today_at (see tom_l’s post below).

1 Like

Can you not just use: today_at() instead of today_at('00:00:00')?

Also it’s an attribute of sensor.washer, not the state.

1 Like

My mistake: I copy-pasted it from a nearby identical post I made elsewhere. Fixed.

1 Like

Also since when does strptime() take 3 arguments?

The third argument is the default in case the conversion fails.

You’re right; today_at() returns today at zero-hour so the argument I supplied is unnecessary (I have removed it).

Ah of course it is. Thanks.

Thanks both for your help, I hadn’t seen the timedelta thing…

    {% set t = strptime(state_attr('sensor.washer', 'remain_time'), '%H:%M', today_at()).time() %}
    {{ as_timestamp(now() + timedelta(hours=t.hour, minutes=t.minute, seconds=t.second)) | timestamp_custom('%H:%M') }}

To get a nice looking time for the notification I had to convert it back to a timestamp to be able to use the timestamp custom format.

Next fun task will be to use the initial time and the remain time to calculate how many % through the wash it is.

Hello,
That’s nice !
Could you share your code for the timestamp value as a notification:

  - service: notify.mobile_app
    data_template:
      title: Washing machine time remaining
      data:
        chronometer: true
        when: "{% set t = strptime(state_attr('sensor.washer', 'remain_time'), '%H:%M', today_at()).time() %}
    {{ as_timestamp(now() + timedelta(hours=t.hour, minutes=t.minute, seconds=t.second)) | timestamp_custom('%H:%M') }}"

Here you go,

service: notify.mobile_app_chris
data:
  message: >-
    {% set t = strptime(state_attr('sensor.washer', 'remain_time'), '%H:%M:%S',
    today_at()).time() %} Cycle {{ states('sensor.washer_current_course') }}
    <br> Currently {{ states('sensor.washer_run_state') }} <br> Estimated
    completion time: {{ as_timestamp(now() + timedelta(hours=t.hour,
    minutes=t.minute, seconds=t.second)) | timestamp_custom('%H:%M') }}
  title: Washing Machine Running
  data:
    tag: washing_machine
    notification_icon: mdi:washing-machine
1 Like