Convert "time" value (HH:MM) to real "time" value

Hey all,

need some help with time please.
I’m trying to work out the “total time” (so end - start)
however I keep getting an error when i try and subtract the values?
maybe because the “time” is only in “hh:mm” and not actually a “time” value?

Question1: How do I convert “HH:MM” value to an actual timestamp, so I can use it to work out the total duration? in the below example its starting at 10:49am, finishing at 13:08pm, so a total run time of 2h 19min

Question2: Every stage that the dishwasher goes through, it changes the “start_time”, as its relative to what is doing (cleaning, drying, etc…) So if i want to have a clear idea of real “start_time” is best to log this against a value using “now”, based on the start of the dishwasher trigger?

end goal here is to get the values, so i can apply this :slight_smile:

{{ states.sensor.dishwasher_g7310_status }}

finish time: {{ states.sensor.dishwasher_g7310_status.attributes.finishTime}}
kickoff time: {{states.sensor.dishwasher_g7310_status.attributes.kickoffTime}}
remaining time: {{ states.sensor.dishwasher_g7310_remaining_time.state }}

results:

<template TemplateState(<state sensor.dishwasher_g7310_status=In use; programType=Operation mode, rawProgramType=0, programPhase=Main Wash, rawProgramPhase=1795, dryingStep=, rawDryingStep=None, spinningSpeed=None, rawSpinningSpeed=None, ventilationStep=, rawVentilationStep=None, progress=0.0, finishTime=13:08, kickoffTime=10:49, friendly_name=Dishwasher G7310 Status @ 2020-10-08T09:43:16.002482+01:00>)>

finish time: 13:08
kickoff time: 10:49
remaining time: 02:19

I don’t have an answer for you, but if one exists it’ll probably be here:

Dont you already have what you need in the time remaining ?

hey, aftaid not, as i want to know the “total” time to start with, so i can then use the “remaining time” for a nice card (eg. showing how much time is left overall

You don’t show where the “{{ states.sensor.dishwasher_g7310_remaining_time.state }}” sensor is coming from so is that not the actual “remaining time” (end - start)? Or is it really the total time and the sensor is mislabeled?

its the total time left for the whole cycle.

sorry, I’m still not understanding.

Can you better define those times and which one of those first two is equal to the last?

Does the “remaining time” sensor that you posted change as the minutes count down or is it a static time based on the start and end times of the total cycle?

It sounds like you also (maybe?) want to see the time left for each “phase” of the total cycle as well?

sorry, was waiting for a time when i had the dishwasher going and was by the computer.

these are the values i have.
the one im missing is the “total run time” for the wash overall.
i can then do a calculation of “total time” / “remaining time” to give me a % left for the whole wash, if that makes sense?

the sensor for “elapsed time” and “start time” never seem to work and are always 00:00
the sensor for remaining time, seems to be useful.

however the attributes for
finishTime:
kickoffTime:

are not ideal, as they are relative to the current cycle stage, not the overall dishwasher process.

OK, I’ll go from there…

The answer to question 1 is (from the link to my post above):

{{ strptime('13:08', '%H:%M') - strptime('10:49', '%H:%M') }}

that will give you the total time (2:19:00)

for question 2 what I would do is to set the value of an input_datetime to the actual start time. then you can reference everything after that to that input_datetime.

But it won’t do you any good if you don’t have a reliable way of getting the actual start time in the first place.

If the start time sensor doesn’t work then I would probably use the status sensor state going to “In use” to set the above input_datetime to now() (i.e. when the sensor switches to in use).

But again, how are you determining the finishing time? I don’t see any way to do that using the entities you listed above in the screenshot.

Unless the kickoff time really is the actual overall start time and the finish time is the the actual overall finish time for the cycle (in hours:minutes)? The way you described it sounded like that was only for the current phase of the cycle not the overall but that seems strange since in the screenshot that would mean the current phase (main wash?) would last a total of over an hour and a half. Obviously, I don’t know your dishwasher and that may be realistic for only that one phase of the overall run time, tho, but it seems pretty long to me. I just want to make sure I know exactly what the numbers represent.

1 Like