Hello! I hope this isn’t too dumb of a question but I’ve been banging my head against the wall trying to figure this out for the past couple of hours. Any help would be most appreciated.
I have a Samsung Smartthings washer/dryer and both are connected to HA. There are entities for estimated completion time generated as a timestamp:
The auto-generated lovelace frontend shows this estimated completion time as “in XX minutes”:
However, when I try to add this information to my custom lovelace frontend as an entity card, it just displays the timestamp like so:
How can I get this card to show the estimated completion time as ‘in XX minutes’ like the auto-generated lovelace frontend? This is important because I’m in the process of making this jumble of entities useful on mobile for my wife
Thanks for any help you can provide!
Ahhh thank you, I was using the ‘entity’ card not the ‘entities ’ card.
Cafun
November 7, 2020, 2:18pm
4
So, I’m struggling with the same, but I need to convert it to minutes in a template (to use it in the HomeAppliance card: https://github.com/ShunichiSan/HomeAssistantApplianceCard ).
I’m trying to try it in the Developers Tools, but I get the error:
TypeError: unsupported operand type(s) for -: ‘NoneType’ and ‘float’
My code is:
{{ as_timestamp(states.sensor.droger_remaining_program_time.state) | timestamp_custom(' %H:%M ') }}
{{ (states.sensor.time.state) }}
{% set currenttime = (states.sensor.time.state) %}
{% set dryerfinished = (as_timestamp(states.sensor.droger_remaining_program_time.state) | timestamp_custom(' %H:%M ')) %}
{{ (((as_timestamp(strptime(dryerfinished, "%H:%M"))) - as_timestamp(strptime(currenttime, "%H:%M") )) /60) | int}}
So the first line is giving me the exact time it will be finished: 15:06.
If I try to add it in a variable “dryerfinished” I get the error I posted.
I’m a beginner in the use of Home Assistant, so I hope someone can help me out!
Thanks in advance!
peetipablo
(Peetipablo)
November 8, 2020, 11:46am
5
Hi Cafun,
Sorry but I don’t know if I can help. That card does look neat, but all I did was change which card I was using (entities not entity) and that solved my issue. I was looking for a timestamp of estimated completion that was being reported by SmartThings, it seems like your use case is a little different.
Cafun
November 9, 2020, 7:05pm
6
Hi peetipablo,
Indeed it is a little different, although I hope someone can help me out.
But thank you for your reaction
gidadavid
(Gidadavid)
January 25, 2021, 8:28pm
7
Is there already a solution ? I have no clue
kostas2911
(Kostas Injeyan)
February 6, 2021, 4:52pm
8
I use below code to create a new sensor. Then i use that sensor to lovelace
Found original code here
- platform: template
sensors:
washing_machine_remaining_time:
friendly_name: "Washing Machine Remaing Time"
value_template: >-
{% set timestamp = as_timestamp(states('sensor.dryer_remaining_program_time')) | int %}
{%- macro pluralize(value, phrase) %}
{{- '{} {}{}'.format(value, phrase, end) if value > 0 else '' }}
{%- endmacro %}
{% if timestamp %}
{% set time = timestamp -now().timestamp() %}
{% if time | regex_search("^-") == True %}
End
{% else %}
{% set seconds = pluralize((time|int % 60) // 1, 'second') %}
{% set minutes = pluralize((time|int % 3600) // 60) %}
{% set hours = pluralize((time|int % 86400) // 3600,':') %}
{% set days = pluralize(time|int // 86400, 'day') %}
{% set tlist = [ days, hours, minutes, seconds ] | select('!=', '') | list %}
{% set phrase = tlist[:-1] | join('')%}
{% endif %}
{{ phrase }}
{% else %}
End
{% endif %}
icon_template: mdi:calendar-clock
torsteinhs
(Torstein Solhaug)
March 6, 2021, 1:40pm
9
Hi, I have found something that seems to work for me. I am a novice when it comes to coding, so there is probably a better way of solving this:
sensor:
- platform: template
sensors:
vaskemaskin_gjenst_tid:
friendly_name: "Gjenstående tid"
value_template: >
{{ relative_time(now() - timedelta( seconds = as_timestamp(states('sensor.vaskemaskin_washer_completion_time')) - as_timestamp(now()))) }}
amermels
(Alex)
February 13, 2023, 4:52am
10
Is there any way to show this in an Entity card, since I only want a single entity on that card?
I’m using it for a time remaining card like this:
type: entities
entities:
- type: custom:template-entity-row
name: Remaining Time
state: "{{ relative_time(now() - timedelta( seconds = as_timestamp(states('input_datetime.auto_off_time')) - as_timestamp(now()))) }}"
I actually have it in a conditional card so it doesnt show when the timer isn’t enabled, but i just put the standalone entities card there for you.