Skip to content

Commit

Permalink
[EN] Add duration added or removed from timer (home-assistant#2521)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFes authored Nov 13, 2024
1 parent 16719ff commit 31dae61
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
12 changes: 11 additions & 1 deletion responses/en/HassDecreaseTimer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,14 @@ language: en
responses:
intents:
HassDecreaseTimer:
default: "Timer updated"
default: >
{% set h = slots.hours if slots.hours is defined else none %}
{% set m = slots.minutes if slots.minutes is defined else none %}
{% set s = slots.seconds if slots.seconds is defined else none %}
{% set h_text = h ~ (' hour' if h in [ "1", 'one'] else ' hours') if h else '' %}
{% set m_text = (30 if m in ['half', '1/2'] else m) ~ (' minute' if m in [ "1", 'one'] else ' minutes') if m else '' %}
{% set s_text = (30 if s in ['half', '1/2'] else s) ~ (' second' if s in [ "1", 'one'] else ' seconds') if s else '' %}
{% set text_list = [ h_text, m_text, s_text] | select() | list %}
{% set text = text_list[:-1] | join(', ') ~ ' and ' ~ text_list[-1] if text_list | count > 2 else text_list | join(' and ') %}
{% set name = (' named ' ~ slots.name | trim) if slots.name is defined else '' %}
{{ text }} removed from timer{{ name }}
12 changes: 11 additions & 1 deletion responses/en/HassIncreaseTimer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,14 @@ language: en
responses:
intents:
HassIncreaseTimer:
default: "Timer updated"
default: >
{% set h = slots.hours if slots.hours is defined else none %}
{% set m = slots.minutes if slots.minutes is defined else none %}
{% set s = slots.seconds if slots.seconds is defined else none %}
{% set h_text = h ~ (' hour' if h in [ "1", 'one'] else ' hours') if h else '' %}
{% set m_text = (30 if m in ['half', '1/2'] else m) ~ (' minute' if m in [ "1", 'one'] else ' minutes') if m else '' %}
{% set s_text = (30 if s in ['half', '1/2'] else s) ~ (' second' if s in [ "1", 'one'] else ' seconds') if s else '' %}
{% set text_list = [ h_text, m_text, s_text] | select() | list %}
{% set text = text_list[:-1] | join(', ') ~ ' and ' ~ text_list[-1] if text_list | count > 2 else text_list | join(' and ') %}
{% set name = (' named ' ~ slots.name | trim) if slots.name is defined else '' %}
{{ text }} added to timer{{ name }}
8 changes: 4 additions & 4 deletions tests/en/homeassistant_HassDecreaseTimer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tests:
name: HassDecreaseTimer
slots:
minutes: 5
response: Timer updated
response: 5 minutes removed from timer

- sentences:
- "remove 5 minutes from 1 hour timer"
Expand All @@ -24,7 +24,7 @@ tests:
slots:
minutes: 5
start_hours: 1
response: Timer updated
response: 5 minutes removed from timer

- sentences:
- "remove 5 minutes from pizza timer"
Expand All @@ -40,7 +40,7 @@ tests:
name:
- "pizza "
- "pizza"
response: Timer updated
response: 5 minutes removed from timer named pizza

- sentences:
- "remove 5 minutes from kitchen timer"
Expand All @@ -54,4 +54,4 @@ tests:
slots:
minutes: 5
area: Kitchen
response: Timer updated
response: 5 minutes removed from timer
9 changes: 4 additions & 5 deletions tests/en/homeassistant_HassIncreaseTimer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tests:
name: HassIncreaseTimer
slots:
minutes: 5
response: Timer updated
response: 5 minutes added to timer

- sentences:
- "add 5 minutes to 1 hour timer"
Expand All @@ -20,7 +20,7 @@ tests:
slots:
minutes: 5
start_hours: 1
response: Timer updated
response: 5 minutes added to timer

- sentences:
- "add 5 minutes to pizza timer"
Expand All @@ -32,9 +32,8 @@ tests:
slots:
minutes: 5
name:
- "pizza "
- "pizza"
response: Timer updated
response: 5 minutes added to timer named pizza

- sentences:
- "add 5 minutes to kitchen timer"
Expand All @@ -46,4 +45,4 @@ tests:
slots:
minutes: 5
area: Kitchen
response: Timer updated
response: 5 minutes added to timer

0 comments on commit 31dae61

Please sign in to comment.