Skip to content

Commit 3605616

Browse files
authored
Merge pull request #1595 from UI-Lovelace-Minimalist/release
Sync release with main
2 parents 3528d66 + 5bb82d9 commit 3605616

15 files changed

+315
-288
lines changed

custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml

+24-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,31 @@ ulm_translation_engine:
3333
let domain = entity.entity_id.substr(0, entity.entity_id.indexOf("."));
3434
let mode = hass.resources[lang]["state_attributes." + domain + ".hvac_action." + action];
3535
if(variables.ulm_show_last_changed){
36-
return helpers.relativeTime(entity.last_changed, true)
36+
let dt = new Intl.RelativeTimeFormat(lang, { style: "long" });
37+
let delta = (Date.parse(entity.last_changed) - Date.now()) / 1000
38+
let days = 0
39+
if (delta > 1000)
40+
days = parseInt(delta / (60 * 60 * 24));
41+
let hours = parseInt(Math.round(delta / (60 * 60)) % 24);
42+
let hours_unrounded = parseInt((delta / (60 * 60)) % 24);
43+
let minutes = parseInt(Math.round(delta / 60) % 60);
44+
let minutes_unrounded = parseInt((delta / 60) % 60);
45+
let seconds = parseInt(Math.round(delta) % 60);
46+
if (days != 0)
47+
return dt.format(days,"days");
48+
else if (hours_unrounded != 0)
49+
return dt.format(hours,"hours");
50+
else if (minutes_unrounded != 0)
51+
return dt.format(minutes,"minutes");
52+
return dt.format(seconds,"seconds");
3753
}
38-
if(device_class == 'timestamp'){
39-
return helpers.relativeTime(entity.state, true)
54+
if(device_class == ('timestamp' || 'date')){
55+
let dt = new Intl.DateTimeFormat(lang, {
56+
dateStyle: "long",
57+
timeStyle: "short"
58+
});
59+
let formatted_date = dt.format(Date.parse(entity.state))
60+
return formatted_date;
4061
}
4162
if(entity.entity_id.startsWith("climate.")){
4263
return helpers.localize(entity, entity.attributes.current_temperature) + ' • ' +

custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/actions/actions_card.yaml

+75-75
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ ulm_actions_card:
1616
action = 'popup'
1717
}
1818
if (action == 'adaptive'){
19-
action = 'call-service'
19+
action = 'perform-action'
2020
}
2121
if (domain == "media_player" && action == 'toggle'){
22-
action = 'call-service';
22+
action = 'perform-action';
2323
}
2424
if (action == 'popup' && (variables.ulm_custom_popup != null )){
2525
let popup_config = variables.ulm_custom_popup;
@@ -36,34 +36,34 @@ ulm_actions_card:
3636
]]]
3737
navigation_path: "[[[ return variables.ulm_card_tap_action == 'navigate' ? variables.ulm_card_tap_navigate_path : '/0' ]]]"
3838
haptic: "[[[ return variables.ulm_card_tap_haptic != null ? variables.ulm_card_tap_haptic : 'none' ]]]"
39-
service: >
39+
perform_action: >
4040
[[[
41-
var action = variables.ulm_card_tap_action;
42-
43-
if (action == 'adaptive'){
41+
if (variables.ulm_card_tap_action == 'adaptive')
4442
return 'input_select.select_option';
45-
}
46-
if((entity != null) && entity.entity_id.startsWith("media_player.")){
43+
else if (variables.ulm_card_tap_service !== undefined)
44+
return variables.ulm_card_tap_service;
45+
else if ((entity != null) && entity.entity_id.startsWith("media_player."))
4746
return 'media_player.media_play_pause';
48-
}
49-
return variables.ulm_card_tap_service;
47+
return "";
5048
]]]
51-
service_data: >
49+
target:
50+
entity_id: >
51+
[[[
52+
if (variables.ulm_card_tap_action == 'adaptive')
53+
return variables.ulm_input_select;
54+
else if (variables.ulm_card_tap_target !== undefined)
55+
return variables.ulm_card_tap_target;
56+
else if ((entity != null) && entity.entity_id.startsWith("media_player."))
57+
return entity.entity_id;
58+
return "";
59+
]]]
60+
data: >
5261
[[[
53-
var action = variables.ulm_card_tap_action;
54-
55-
if (action == 'adaptive'){
56-
return {
57-
'option': variables.ulm_input_select_option,
58-
'entity_id': variables.ulm_input_select
59-
};
60-
}
61-
if((entity != null) && entity.entity_id.startsWith("media_player.")){
62-
return {
63-
'entity_id': entity.entity_id
64-
};
65-
}
66-
return variables.ulm_card_tap_service_data;
62+
if (variables.ulm_card_tap_action == 'adaptive'){
63+
return {'option': variables.ulm_input_select_option };
64+
else if (variables.ulm_card_tap_service_data !== undefined)
65+
return variables.ulm_card_tap_service_data;
66+
return "";
6767
]]]
6868
browser_mod:
6969
service: "browser_mod.popup"
@@ -129,10 +129,10 @@ ulm_actions_card:
129129
action = 'popup'
130130
}
131131
if (action == 'adaptive'){
132-
action = 'call-service'
132+
action = 'perform-action'
133133
}
134134
if (domain == "media_player" && action == 'toggle'){
135-
action = 'call-service';
135+
action = 'perform-action';
136136
}
137137
if (action == 'popup' && (variables.ulm_custom_popup != null )){
138138
let popup_config = variables.ulm_custom_popup;
@@ -149,34 +149,34 @@ ulm_actions_card:
149149
]]]
150150
navigation_path: "[[[ return variables.ulm_card_hold_action == 'navigate' ? variables.ulm_card_hold_navigate_path : '/0' ]]]"
151151
haptic: "[[[ return variables.ulm_card_hold_haptic != null ? variables.ulm_card_hold_haptic : 'none' ]]]"
152-
service: >
152+
perform_action: >
153153
[[[
154-
var action = variables.ulm_card_hold_action;
155-
156-
if (action == 'adaptive'){
154+
if (variables.ulm_card_hold_action == 'adaptive')
157155
return 'input_select.select_option';
158-
}
159-
if((entity != null) && entity.entity_id.startsWith("media_player.")){
156+
else if (variables.ulm_card_hold_service !== undefined)
157+
return variables.ulm_card_hold_service;
158+
else if ((entity != null) && entity.entity_id.startsWith("media_player."))
160159
return 'media_player.media_play_pause';
161-
}
162-
return variables.ulm_card_hold_service;
160+
return "";
163161
]]]
164-
service_data: >
162+
target:
163+
entity_id: >
164+
[[[
165+
if (variables.ulm_card_hold_action == 'adaptive')
166+
return variables.ulm_input_select;
167+
else if (variables.ulm_card_hold_target !== undefined)
168+
return variables.ulm_card_hold_target;
169+
else if ((entity != null) && entity.entity_id.startsWith("media_player."))
170+
return entity.entity_id;
171+
return "";
172+
]]]
173+
data: >
165174
[[[
166-
var action = variables.ulm_card_hold_action;
167-
168-
if (action == 'adaptive'){
169-
return {
170-
'option': variables.ulm_input_select_option,
171-
'entity_id': variables.ulm_input_select
172-
};
173-
}
174-
if((entity != null) && entity.entity_id.startsWith("media_player.")){
175-
return {
176-
'entity_id': entity.entity_id
177-
};
178-
}
179-
return variables.ulm_card_hold_service_data;
175+
if (variables.ulm_card_hold_action == 'adaptive')
176+
return { 'option': variables.ulm_input_select_option };
177+
else if (variables.ulm_card_hold_service_data !== undefined)
178+
return variables.ulm_card_hold_service_data;
179+
return "";
180180
]]]
181181
browser_mod:
182182
service: "browser_mod.popup"
@@ -242,10 +242,10 @@ ulm_actions_card:
242242
action = 'popup'
243243
}
244244
if (action == 'adaptive'){
245-
action = 'call-service'
245+
action = 'perform-action'
246246
}
247247
if (domain == "media_player" && action == 'toggle'){
248-
action = 'call-service';
248+
action = 'perform-action';
249249
}
250250
if (action == 'popup' && (variables.ulm_custom_popup != null )){
251251
let popup_config = variables.ulm_custom_popup;
@@ -262,34 +262,34 @@ ulm_actions_card:
262262
]]]
263263
navigation_path: "[[[ return variables.ulm_card_double_tap_action == 'navigate' ? variables.ulm_card_double_tap_navigate_path : '/0' ]]]"
264264
haptic: "[[[ return variables.ulm_card_double_tap_haptic != null ? variables.ulm_card_double_tap_haptic : 'none' ]]]"
265-
service: >
265+
perform_action: >
266266
[[[
267-
var action = variables.ulm_card_double_tap_action;
268-
269-
if (action == 'adaptive'){
267+
if (variables.ulm_card_double_tap_action == 'adaptive')
270268
return 'input_select.select_option';
271-
}
272-
if((entity != null) && entity.entity_id.startsWith("media_player.")){
269+
else if (variables.ulm_card_double_tap_service !== undefined)
270+
return variables.ulm_card_double_tap_service;
271+
else if ((entity != null) && entity.entity_id.startsWith("media_player."))
273272
return 'media_player.media_play_pause';
274-
}
275-
return variables.ulm_card_double_tap_service;
273+
return "";
276274
]]]
277-
service_data: >
275+
target:
276+
entity_id: >
277+
[[[
278+
if (variables.ulm_card_double_tap_action == 'adaptive')
279+
return variables.ulm_input_select;
280+
else if (variables.ulm_card_double_tap_target !== undefined)
281+
return variables.ulm_card_double_tap_target;
282+
else if ((entity != null) && entity.entity_id.startsWith("media_player."))
283+
return entity.entity_id;
284+
return "";
285+
]]]
286+
data: >
278287
[[[
279-
var action = variables.ulm_card_double_tap_action;
280-
281-
if (action == 'adaptive'){
282-
return {
283-
'option': variables.ulm_input_select_option,
284-
'entity_id': variables.ulm_input_select
285-
};
286-
}
287-
if((entity != null) && entity.entity_id.startsWith("media_player.")){
288-
return {
289-
'entity_id': entity.entity_id
290-
};
291-
}
292-
return variables.ulm_card_double_tap_service_data;
288+
if (variables.ulm_card_double_tap_action == 'adaptive')
289+
return { 'option': variables.ulm_input_select_option };
290+
else if (variables.ulm_card_double_tap_service_data !== undefined)
291+
return variables.ulm_card_double_tap_service_data;
292+
return "";
293293
]]]
294294
browser_mod:
295295
service: "browser_mod.popup"

0 commit comments

Comments
 (0)