Skip to content

Commit

Permalink
Merge pull request #1395 from UI-Lovelace-Minimalist/release
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
basbruss authored Nov 2, 2023
2 parents 72f6f39 + edc05b0 commit 3438d15
Show file tree
Hide file tree
Showing 34 changed files with 368 additions and 305 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ card_media_player_chromecast:
- "icon_info"
- "blue_not_unavailable"
- "ulm_translation_engine"
label: "[[[ return variables.ulm_translation_state_unit ]]]"
label: "[[[ return variables.ulm_translation_state ]]]"
card_media_player_chromecast_with_controls:
variables:
ulm_card_media_player_with_controls_name: "No name set"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ custom_card_haven_washer_delayed_text:
show_icon: false
show_label: true
show_name: false
label: "[[[ return variables.ulm_translation_state_unit ]]]"
label: "[[[ return variables.ulm_translation_state ]]]"
styles:
state:
- color: "rgba(var(--color-theme),0.9)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ widget_text:
show_icon: false
show_label: true
show_name: false
label: "[[[ return variables.ulm_translation_state_unit ]]]"
label: "[[[ return variables.ulm_translation_state ]]]"
styles:
grid:
- grid-template-areas: "'l'"
Expand Down
30 changes: 15 additions & 15 deletions custom_cards/custom_card_input_number/card_input_number.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ card_input_number:
tap_action:
action: "call-service"
service: |
[[[
if( entity.entity_id.startsWith("input_number.") )
return "input_number.decrement";
if( entity.entity_id.startsWith("counter.") )
return "counter.decrement";
return "";
]]]
[[[
if( entity.entity_id.startsWith("input_number.") )
return "input_number.decrement";
if( entity.entity_id.startsWith("counter.") )
return "counter.decrement";
return "";
]]]
service_data:
entity_id: "[[[ return entity.entity_id ]]]"
icon: "mdi:arrow-down"
Expand All @@ -67,13 +67,13 @@ card_input_number:
tap_action:
action: "call-service"
service: |
[[[
if( entity.entity_id.startsWith("input_number.") )
return "input_number.increment";
if( entity.entity_id.startsWith("counter.") )
return "counter.increment";
return "";
]]]
[[[
if( entity.entity_id.startsWith("input_number.") )
return "input_number.increment";
if( entity.entity_id.startsWith("counter.") )
return "counter.increment";
return "";
]]]
service_data:
entity_id: "[[[ return entity.entity_id ]]]"
icon: "mdi:arrow-up"
Expand All @@ -91,7 +91,7 @@ widget_text:
show_icon: false
show_label: true
show_name: false
label: "[[[ return variables.ulm_translation_state_unit ]]]"
label: "[[[ return variables.ulm_translation_state ]]]"
styles:
grid:
- grid-template-areas: "'l'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ custom_card_irmajavi_entities:
custom_widget_irmajavi:
show_label: true
show_icon: false
label: "[[[ return variables.ulm_translation_state_unit ]]]"
label: "[[[ return variables.ulm_translation_state ]]]"
styles:
name:
- justify-self: "center"
Expand Down

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions custom_components/ui_lovelace_minimalist/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
"German": "de",
"English (GB)": "en",
"Spanish": "es",
"Català": "ca",
"French": "fr",
"Italian": "it",
"Dutch": "nl",
"Hebrew": "he",
"Norwegian": "no",
"Polish": "pl",
"Portuguese": "pt",
Expand All @@ -45,9 +47,11 @@
"German",
"English (GB)",
"Spanish",
"Català",
"French",
"Italian",
"Dutch",
"Hebrew",
"Norwegian",
"Polish",
"Portuguese",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,84 +22,27 @@ ulm_translation_engine:
return (!not_active.includes(entity.state) && !containsNumbers(entity.state))
}
]]]
ulm_translation_hour: >
[[[
var number = hass.resources[hass['language']]["ui.duration.hour"];
var matches = number.match(/[^{\}]+(?=})/g);
var hour = "Hour";
if (matches) {
var hour = matches[1];
}
return(hour);
]]]
ulm_translation_hours: >
[[[
var number = hass.resources[hass['language']]["ui.duration.hour"];
var matches = number.match(/[^{\}]+(?=})/g);
var hour = "Hours";
if (matches) {
var hour = matches[2];
}
return(hour);
]]]
ulm_translation_hvac: >
[[[
if (typeof(entity) !== 'undefined' && entity !== undefined){
let state = entity.state;
let d_class = entity.attributes.device_class;
let def = ["unknown", "unavailable"];
let lang = hass["language"];
let action = entity.attributes.hvac_action;
let domain = entity.entity_id.substr(0, entity.entity_id.indexOf("."));
var mode = hass.resources[lang]["state_attributes." + domain + ".hvac_action." + action];
if (def.includes(state)) {
var mode = hass.resources[lang]["state.default." + state ];
}
var label = hass.resources[lang]["component." + domain + ".state._." + state];
var translation = label ? label : state;
return (entity.attributes.current_temperature ) + '°' + ' • ' + translation + ((entity.state !='off' && mode !== undefined) ? ' (' + mode + ')' : '');
}
]]]
ulm_translation_off: "[[[ return hass.resources[hass['language']]['state.default.off']; ]]]"
ulm_translation_on: "[[[ return hass.resources[hass['language']]['state.default.on']; ]]]"
ulm_translation_state: >
[[[
if (typeof(entity) !== 'undefined' && entity !== undefined){
let state = entity.state;
let d_class = entity.attributes.device_class;
let def = ["unknown", "unavailable"];
let device_class = entity.attributes.device_class;
let lang = hass["language"];
let action = entity.attributes.hvac_action;
let domain = entity.entity_id.substr(0, entity.entity_id.indexOf("."));
var translation = hass.resources[lang]["component." + domain + ".entity_component._.state." + state]
let display_precision = hass.entities[entity.entity_id]?.display_precision
const now = new Date();
const timestamp = (new Date(state)).getTime();
const nowTimeStamp = now.getTime();
const microSecondsDiff = Math.round(timestamp - nowTimeStamp);
const daysDiff = Math.round(microSecondsDiff / (1000 * 60 * 60 * 24));
const hoursDiff = Math.round(microSecondsDiff / (1000 * 60 * 60));
const minutesDiff = Math.round(microSecondsDiff / (1000 * 60));
const secondsDiff = Math.round(microSecondsDiff / (1000));
const formatter = new Intl.RelativeTimeFormat(lang, { numeric: 'auto' });
var scale = 'day'
var diff = daysDiff
if (Math.abs(secondsDiff) < 60){ scale = 'second'; diff = secondsDiff }
else if (Math.abs(minutesDiff) < 60){ scale = 'minute'; diff = minutesDiff }
else if (Math.abs(hoursDiff) < 24){ scale = 'hour'; diff = hoursDiff }
if (def.includes(state)) {
var translation = hass.resources[lang]["state.default." + state ];
}
else if (domain == "binary_sensor" && d_class != ''){
var translation = hass.resources[lang]["component." + domain + ".entity_component." + d_class + ".state." + state]
let mode = hass.resources[lang]["state_attributes." + domain + ".hvac_action." + action];
if(variables.ulm_show_last_changed){
return helpers.relativeTime(entity.last_changed, true)
}
else if (d_class == 'timestamp'){
var translation = formatter.format(diff, scale)
if(device_class == 'timestamp'){
return helpers.relativeTime(entity.state, true)
}
else if (parseFloat(display_precision) >=0){
var translation = parseFloat(entity.state).toFixed(display_precision?.toString())
if(entity.entity_id.startsWith("climate.")){
return helpers.localize(entity, entity.attributes.current_temperature) + ' • ' +
helpers.localize(entity) + ((entity.state !='off' && mode !== undefined) ? ' (' + mode + ')' : '');
}
return translation ? translation.charAt(0).toUpperCase() + translation.slice(1) : state;
return helpers.localize(entity)
}
]]]
ulm_translation_state_reverse: >
Expand All @@ -119,59 +62,6 @@ ulm_translation_engine:
return translation ? translation : state;
}
]]]
ulm_translation_state_unit: >
[[[
if (typeof(entity) !== 'undefined' && entity !== undefined){
let state = entity.state;
let d_class = entity.attributes.device_class;
let def = ["unknown", "unavailable"];
let lang = hass["language"];
let domain = entity.entity_id.substr(0, entity.entity_id.indexOf("."));
let unit = entity.attributes.unit_of_measurement != null ? " " + entity.attributes.unit_of_measurement : "";
let display_precision = hass.entities[entity.entity_id]?.display_precision
const now = new Date();
const timestamp = (new Date(state)).getTime();
const nowTimeStamp = now.getTime();
const microSecondsDiff = Math.round(timestamp - nowTimeStamp);
const daysDiff = Math.round(microSecondsDiff / (1000 * 60 * 60 * 24));
const hoursDiff = Math.round(microSecondsDiff / (1000 * 60 * 60));
const minutesDiff = Math.round(microSecondsDiff / (1000 * 60));
const secondsDiff = Math.round(microSecondsDiff / (1000));
const formatter = new Intl.RelativeTimeFormat(lang, { numeric: 'auto' });
var scale = 'day'
var diff = daysDiff
if (Math.abs(secondsDiff) < 60){ scale = 'second'; diff = secondsDiff }
else if (Math.abs(minutesDiff) < 60){ scale = 'minute'; diff = minutesDiff }
else if (Math.abs(hoursDiff) < 24){ scale = 'hour'; diff = hoursDiff }
if(hass.resources[lang]["component." + domain + ".entity_component._.state." + state]){
var translation = hass.resources[lang]["component." + domain + ".entity_component._.state." + state] + unit
} else {
var translation = state + unit;
}
if (def.includes(state)) {
var translation = hass.resources[lang]["state.default." + state ];
}
else if (domain == "binary_sensor" && d_class != ''){
var translation = hass.resources[lang]["component." + domain + ".entity_component." + d_class + ".state." + state]
}
else if (domain == "media_player" && d_class != ''){
if (state == 'idle' || state == 'paused')
var translation = hass.resources[lang]["component." + domain + ".entity_component._.state." + state];
else {
var translation = (entity.attributes.source) + ' • ' + ( Math.round(entity.attributes.volume_level / 0.01)) + '%' ;
}
}
else if (d_class == 'timestamp'){
var translation = formatter.format(diff, scale);
}
else if (parseFloat(display_precision) >=0){
var translation = parseFloat(entity.state).toFixed(display_precision?.toString()) + unit
}
return translation ? translation.charAt(0).toUpperCase() + translation.slice(1) : state;
}
]]]
ulm_translation_statistics: "[[[ return hass.resources[hass['language']]['ui.components.statistic-picker.statistic']; ]]]"
ulm_translation_unavailable: "[[[ return hass.resources[hass['language']]['state.default.unavailable']; ]]]"
ulm_translation_currency: >
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
ulm_language_variables:
variables:
ulm_currency: ""
ulm_updates_available: "יש עדכונים"
ulm_no_updates_available: "אין עדכונים"
ulm_ophaling: "יש איסוף אשפה!"
ulm_geen_ophaling: "אין איסוף אשפה"
ulm_volgende_ophaling: "איסופי אשפה קרובים"
ulm_morning: "בוקר טוב"
ulm_afternoon: "צהריים טובים"
ulm_evening: "ערב טוב"
ulm_hello: "שלום"
ulm_volume: "ווליום"
ulm_popups_color: "צבע"
ulm_radar: "רדאר"
ulm_popup_total: "סך הכל"
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ ulm_actions_name:
'entity_id': entity.entity_id
};
}
return variables.ulm_card_name_service_data;
return variables.ulm_name_hold_service_data;
]]]
browser_mod:
service: "browser_mod.popup"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ card_graph:
ulm_card_graph_group_by: "interval"
ulm_card_graph_line_width: 5
ulm_card_graph_icon_color: ""
triggers_update: "all"
triggers_update:
- "[[[ return variables.ulm_card_graph_entity2 ]]]"
custom_fields:
item1:
card:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ card_battery:
ulm_card_battery_color_battery_level_warning: "var(--google-yellow)"
ulm_card_battery_color_battery_level_ok: "var(--google-green)"
ulm_outlet_power_enable_popup: false
triggers_update: "all"
triggers_update:
- "[[[ return variables?.ulm_card_battery_battery_state_entity_id ]]]"
- "[[[ return variables?.ulm_card_battery_charger_type_entity_id ]]]"
custom_fields:
item1:
card:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ card_generic:
card:
type: "custom:button-card"
entity: "[[[ return entity.entity_id ]]]"
name: "[[[ return variables.ulm_translation_state_unit ]]]"
name: "[[[ return variables.ulm_translation_state ]]]"
label: "[[[ return variables.ulm_card_generic_name ]]]"
variables: >
[[[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ card_generic_swap:
card:
type: "custom:button-card"
entity: "[[[ return entity.entity_id ]]]"
label: "[[[ return variables.ulm_translation_state_unit ]]]"
label: "[[[ return variables.ulm_translation_state ]]]"
name: "[[[ return variables.ulm_card_generic_swap_name ]]]"
variables: >
[[[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ card_media_player:
ulm_card_media_player_enable_controls: false
ulm_card_media_player_enable_volume_slider: false
ulm_card_media_player_enable_volume_buttons: false
ulm_card_media_player_enable_volume_adjust: false
ulm_card_media_player_enable_volume_adjust: 0
ulm_card_media_player_collapsible: false
ulm_card_media_player_player_controls_entity: "[[[ return entity.entity_id ]]]"
ulm_card_media_player_enable_popup: false
ulm_card_media_player_more_info: false
ulm_card_media_player_power_button: false
ulm_card_media_player_force_background_color: false
ulm_card_media_player_color: "blue"
triggers_update: "all"
show_icon: false
show_name: false
show_label: false
Expand Down Expand Up @@ -769,8 +768,8 @@ card_media_player:
volume_level: |
[[[
var volume = states[entity.entity_id].attributes.volume_level;
if (variables.ulm_card_media_player_enable_volume_adjust) {
volume = states[entity.entity_id].attributes.volume_level + ulm_card_media_player_enable_volume_adjust;
if (variables.ulm_card_media_player_enable_volume_adjust != 0) {
volume = states[entity.entity_id].attributes.volume_level - variables.ulm_card_media_player_enable_volume_adjust;
} else {
if (states[entity.entity_id].attributes.device_class === "tv") {
volume = states[entity.entity_id].attributes.volume_level - 0.01;
Expand Down Expand Up @@ -849,8 +848,8 @@ card_media_player:
volume_level: |
[[[
var volume = states[entity.entity_id].attributes.volume_level;
if (variables.ulm_card_media_player_enable_volume_adjust) {
volume = states[entity.entity_id].attributes.volume_level + ulm_card_media_player_enable_volume_adjust;
if (variables.ulm_card_media_player_enable_volume_adjust != 0) {
volume = states[entity.entity_id].attributes.volume_level + variables.ulm_card_media_player_enable_volume_adjust;
} else {
if (states[entity.entity_id].attributes.device_class === "tv") {
volume = states[entity.entity_id].attributes.volume_level + 0.01;
Expand Down
Loading

0 comments on commit 3438d15

Please sign in to comment.