-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome_connect.jinja
More file actions
24 lines (22 loc) · 846 Bytes
/
Copy pathhome_connect.jinja
File metadata and controls
24 lines (22 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{#
Home Connect remaining program time.
Params:
remaining_program_time_sensor: the timestamp sensor from the integration.
powerstate_sensor: the power switch from the integration.
Returns:
- When the powerstate_sensor evaluates falsy or the time is not computable, it will return `-1`.
- Otherwise, it returns the remaining time in minutes as an integer.
#}
{% macro remaining_time(remaining_program_time_sensor, powerstate_sensor) %}
{% if states(powerstate_sensor) | lower in ["unknown", "unavailable", "off", "uit"] %}
-1
{%- else -%}
{% set end_time = states(remaining_program_time_sensor) %}
{% if end_time in ["unknown", "unavailable"] %}
-1
{% else %}
{% set minutes = ((as_timestamp(end_time) - as_timestamp(now())) / 60) | int %}
{{ minutes if minutes > 0 else 0 }}
{% endif %}
{% endif %}
{% endmacro %}