Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 96121

Convert String value for time to an integer (duration_in_traffic)

$
0
0

@ptdalen wrote:

I’m trying to do an automation using the google travel sensor. I want to do some basic math based on two attributes. duration_in_traffic and duration. The value is something like

54 mins, 1 min, or 5 hours 26 mins, etc.

For me most the time the value is less than an hour, so my sensor should work, but today it was longer than an hour and did not work.

Here is an what works for me with a value of less than an hour

{{ state_attr('sensor.pauls_time_to_work_google','duration_in_traffic') | replace(" mins","") | replace(" min","") | int}}

Ultimately I’d love just to get total minutes.

Any ideas how to convert a text string like this to minutes?

Thanks in advance

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 96121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>