Skip to content

Commit

Permalink
Make remaining time sensors numeric, for easier history tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
golles committed Dec 2, 2024
1 parent 374fb9e commit 8dc94f4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
11 changes: 7 additions & 4 deletions blueprints/automation/golles/awtrix_clock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ blueprint:
- Display informative apps, including:
- Real-time room temperature.
- External temperature with weather-dependent icons.
- Appliance remaining time.
### Weather Icons
Get a variety of weather icons on your clock by running my [awtrix](https://github.com/golles/Home-Assistant-Config/blob/main/scripts/awtrix) script.
Expand Down Expand Up @@ -172,10 +173,11 @@ actions:
data:
topic: "{{ topic }}/custom/dishwasher"
payload: >-
{% if states(dishwasher_entity) not in ["unknown", "unavailable"] %}
{% set minutes = states(dishwasher_entity) %}
{% if minutes not in ["-1", "unknown", "unavailable"] %}
{{
dict(
text = states(dishwasher_entity) | replace("minuten", ""),
text = iif(minutes == "0", "Klaar", minutes),
icon = "dishwasher",
)
}}
Expand All @@ -186,10 +188,11 @@ actions:
data:
topic: "{{ topic }}/custom/washing_machine"
payload: >-
{% if states(washing_machine_entity) not in ["unknown", "unavailable"] %}
{% set minutes = states(washing_machine_entity) %}
{% if minutes not in ["-1", "unknown", "unavailable"] %}
{{
dict(
text = states(washing_machine_entity) | replace("minuten", ""),
text = iif(minutes == "0", "Klaar", minutes),
icon = "washing_machine",
)
}}
Expand Down
17 changes: 5 additions & 12 deletions custom_templates/home_connect.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,19 @@ Params:
powerstate_sensor: the power switch from the integration.
Returns:
When the powerstate_sensor evaluates falsy the result will be `unavailable`.
When the time is not computable, it will also result in `unavailable`.
Else it will return `x minuten`, `1 minuut` or `klaar`
- 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"] %}
unavailable
-1
{%- else -%}
{% set end_time = states(remaining_program_time_sensor) %}
{% if end_time in ["unknown", "unavailable"] %}
unavailable
-1
{% else %}
{% set minutes = ((as_timestamp(end_time) - as_timestamp(now())) / 60) | int %}
{%- if minutes <= 0 -%}
Klaar
{%- elif minutes == 1 -%}
1 minuut
{%- else -%}
{{ minutes }} minuten
{%- endif -%}
{{ minutes if minutes > 0 else 0 }}
{% endif %}
{% endif %}
{% endmacro %}
12 changes: 9 additions & 3 deletions packages/home_connect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ template:
"sensor.bosch_wawh2643nl_68a40e31630b_bsh_common_setting_powerstate"
)
}}
unit_of_measurement: minuten

- name: Vaatwasser resterende minuten
icon: mdi:clock
Expand All @@ -21,6 +22,7 @@ template:
"sensor.bosch_sbv88tx36e_68a40e0cd8f6_bsh_common_setting_powerstate"
)
}}
unit_of_measurement: minuten

- name: Oven resterende minuten
icon: mdi:clock
Expand All @@ -32,6 +34,7 @@ template:
"sensor.384090532720002735_001_bsh_common_setting_powerstate"
)
}}
unit_of_measurement: minuten

- name: Wasmachine status
icon: mdi:washing-machine
Expand All @@ -41,7 +44,8 @@ template:
{% elif is_state("binary_sensor.bosch_wawh2643nl_68a40e31630b_bsh_common_status_doorstate", "on") -%}
Deur open
{% elif is_state("sensor.bosch_wawh2643nl_68a40e31630b_bsh_common_status_operationstate", "Loopt") -%}
{{ states("sensor.wasmachine_resterende_minuten") }}
{% set minuten = states("sensor.wasmachine_resterende_minuten") %}
{{ minuten ~ " " ~ iif(minuten == "1", "minuut", "minuten") }}
{% elif is_state("binary_sensor.bosch_wawh2643nl_68a40e31630b_bsh_common_status_remotecontrolstartallowed", "on") -%}
Uitgestelde start
{%- else -%}
Expand Down Expand Up @@ -85,7 +89,8 @@ template:
{% elif is_state("binary_sensor.bosch_sbv88tx36e_68a40e0cd8f6_bsh_common_status_doorstate", "on") -%}
Deur open
{% elif is_state("sensor.bosch_sbv88tx36e_68a40e0cd8f6_bsh_common_status_operationstate", "Loopt") -%}
{{ states("sensor.vaatwasser_resterende_minuten") }}
{% set minuten = states("sensor.vaatwasser_resterende_minuten") %}
{{ minuten ~ " " ~ iif(minuten == "1", "minuut", "minuten") }}
{% elif is_state("binary_sensor.bosch_sbv88tx36e_68a40e0cd8f6_bsh_common_status_remotecontrolstartallowed", "on") -%}
Uitgestelde start
{% elif is_state("switch.bosch_sbv88tx36e_68a40e0cd8f6_bsh_common_setting_powerstate", "off") -%}
Expand Down Expand Up @@ -134,7 +139,8 @@ template:
{% if is_state("sensor.oven_resterende_minuten", "unavailable") -%}
{{ states("sensor.384090532720002735_001_bsh_common_status_operationstate") }}
{%- else -%}
{{ states("sensor.oven_resterende_minuten") }}
{% set minuten = states("sensor.oven_resterende_minuten") %}
{{ minuten ~ " " ~ iif(minuten == "1", "minuut", "minuten") }}
{%- endif %}
{% elif states("sensor.384090532720002735_001_bsh_common_setting_powerstate") != "Aan" -%}
off
Expand Down

0 comments on commit 8dc94f4

Please sign in to comment.