Skip to content

Commit

Permalink
[SL] temperature value fix for tests (#2381)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejs2 authored Aug 22, 2024
1 parent 87a0323 commit ad96c56
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 44 deletions.
22 changes: 9 additions & 13 deletions responses/sl/HassClimateGetTemperature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ responses:
HassClimateGetTemperature:
default: |
{% set temperature = state_attr(state.entity_id, 'current_temperature') %}
{% set temperature_abs = temperature | float | abs %}
{% set temperature_sl = (temperature|string).replace(".", ",") %}
{% set temperature_num = temperature | float %}
{% set temperature_abs = temperature_num | abs %}
{% if temperature_abs == 1 %}
{{ temperature }} stopinja
{% elif temperature == 0 or temperature | float % 1 != 0 or temperature | float % 100 | abs < 20 %}
{{ temperature }} stopinje
{{ temperature_sl }} stopinja
{% elif temperature_abs == 2 %}
{{ temperature_sl }} stopinji
{% elif temperature_num == 0 or temperature_num % 1 != 0 or (temperature_num % 100 | abs) < 20 %}
{{ temperature_sl }} stopinje
{% else %}
{{ temperature }} stopinj
{% if temperature | float % 1 != 0 %}
{% set decimal_part = temperature | string | regex_replace('\\d+\\.', '') %}
{% if decimal_part != '1' %}
cela {{ decimal_part }} stopinje
{% else %}
cela {{ decimal_part }} stopinja
{% endif %}
{% endif %}
{{ temperature_sl }} stopinj
{% endif %}
45 changes: 28 additions & 17 deletions responses/sl/HassGetWeather.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,32 @@ responses:
HassGetWeather:
default: >
{% set weather_condition = {
'jasno': 'in jasno',
'jasno': 'in jasno',
'oblačno': 'in oblačno',
'izjemno': 'in izjemno',
'megla': 'z meglo',
'toča': 's točo',
'strela': 'bliskovito',
'bliskovito deževno': 'bliskovito in deževno',
'delno oblačno': 'in delno oblačno',
'nalivi': 'in nalivi',
'deževno': 'in deževno',
'sneženje': 'in sneženje',
'snežno deževno': 's snegom in dežjem',
'sončno': 'in sončno',
'vetrovno': 'in vetrovno',
'vetrovna varianata': 'z vetrom in oblaki'
'clear': 'in jasno',
'clear-night': 'in jasno',
'cloudy': 'in oblačno',
'exceptional': 'in izjemno',
'fog': 'z meglo',
'hail': 's točo',
'lightning': 'bliskovito',
'lightning-rainy': 'bliskovito in deževno',
'partlycloudy': 'in delno oblačno',
'pouring': 'z nalivi',
'rainy': 'in deževno',
'snowy': 'in snežno',
'snowy-rainy': 's snegom in dežjem',
'sunny': 'in sončno',
'windy': 'in vetrovno',
'windy-variant': 'z vetrom in oblaki'
} %}
{{ state.attributes.get('temperature') }} {{ state.attributes.get('temperature_unit') }} {{ weather_condition.get((state.state | string).lower(), "") }}
{% set temperature = state.attributes.get('temperature') %}
{% set temperature_sl = (temperature|string).replace(".", ",") %}
{% set temperature_num = temperature | float %}
{% if temperature_num | abs == 1 %}
{{ temperature_sl }} stopinja
{% elif temperature_num | abs == 2 %}
{{ temperature_sl }} stopinji
{% elif temperature_num == 0 or temperature_num % 1 != 0 or temperature_num % 100 | abs < 20 %}
{{ temperature_sl }} stopinje
{% else %}
{{ temperature_sl }} stopinj
{% endif %} {{ weather_condition.get((state.state | string).lower(), "") }}
1 change: 1 addition & 0 deletions sentences/sl/weather_HassGetWeather.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ intents:
data:
- sentences:
- "<kakšno_je> vreme [[ v| na] <name>]"
- "vreme [[ v| na] <name>]"
requires_context:
domain: weather
18 changes: 9 additions & 9 deletions tests/sl/_fixtures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,21 @@ entities:
area: "living_room"
state: "heat"
attributes:
current_temperature: 21
current_temperature: 21.2

- name: "Kuhinja temperatura"
id: "sensor.kitchen_temperature"
state: "21"
area: "kitchen"
attributes:
current_temperature: 21
current_temperature: 21.2

- name: "termostat"
id: "climate.thermostat"
area: "living_room"
state: "heat"
attributes:
current_temperature: 21
current_temperature: 2
#locks
- name: "vhodna vrata"
id: "lock.front_door"
Expand Down Expand Up @@ -236,21 +236,21 @@ entities:

- name: "v Mariboru"
id: "weather.maribor"
state: "deževno"
state: "rainy"
attributes:
temperature: "21"
temperature_unit: "stopinj"
temperature: "2"
temperature_unit: "°C"

- name: "opravila|opravilom"
id: "todo.opravila"
state: ""

- name: "v Benetkah"
id: "weather.benetke"
state: "jasno"
state: "clear"
attributes:
temperature: "28"
temperature_unit: "stopinj"
temperature: "-1.3"
temperature_unit: "°C"

- name: "Lev"
id: "person.Lev"
Expand Down
6 changes: 3 additions & 3 deletions tests/sl/climate_HassClimateGetTemperature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tests:
- povej mi temperaturo?
intent:
name: HassClimateGetTemperature
response: "21 stopinj"
response: "21,2 stopinje"

- sentences:
- kakšna je temperatura v dnevni sobi?
Expand All @@ -16,7 +16,7 @@ tests:
slots:
area:
- dnevni sobi
response: "21 stopinj"
response: "21,2 stopinje"

- sentences:
- "na kakšno temperaturo je nastavljen termostat?"
Expand All @@ -25,4 +25,4 @@ tests:
name: HassClimateGetTemperature
slots:
name: termostat
response: "21 stopinj"
response: "2 stopinji"
5 changes: 3 additions & 2 deletions tests/sl/weather_HassGetWeather.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ language: sl
tests:
- sentences:
- "kakšno je vreme v Mariboru?"
- "vreme v Mariboru?"

intent:
name: HassGetWeather
slots:
name: v Mariboru
response: 21 stopinj in deževno
response: 2 stopinji in deževno

- sentences:
- "kakšno je vreme v Benetkah"
intent:
name: HassGetWeather
slots:
name: v Benetkah
response: 28 stopinj in jasno
response: -1,3 stopinje in jasno

0 comments on commit ad96c56

Please sign in to comment.