Skip to content

Commit

Permalink
Merge pull request #770 from basbruss/custom_actions
Browse files Browse the repository at this point in the history
Fix merging issue release v1.0.0
  • Loading branch information
basbruss authored Jun 23, 2022
2 parents 8443c89 + 1fe916b commit e4e104c
Show file tree
Hide file tree
Showing 19 changed files with 382 additions and 542 deletions.
8 changes: 7 additions & 1 deletion custom_components/ui_lovelace_minimalist/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,11 @@ def reload_configuration(hass):
hass.config.path(f"{combined_cards_dir}/custom_cards"),
dirs_exist_ok=True,
)

if os.path.exists(hass.config.path(f"{DOMAIN}/custom_actions")):
# Copy over manually installed custom_actions from user
shutil.copytree(
hass.config.path(f"{DOMAIN}/custom_actions"),
hass.config.path(f"{combined_cards_dir}/custom_actions"),
dirs_exist_ok=True,
)
hass.bus.async_fire("ui_lovelace_minimalist_reload")
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ ulm_translation_engine:
let domain = entity.entity_id.substr(0, entity.entity_id.indexOf("."));
let unit = entity.attributes.unit_of_measurement != null ? " " + entity.attributes.unit_of_measurement : "";
var translation = hass.resources[lang]["component." + domain + ".state._." + state] + unit || state + unit;
if(hass.resources[lang]["component." + domain + ".state._." + state]){
var translation = hass.resources[lang]["component." + domain + ".state._." + state] + unit
} else {
var translation = state + unit;
}
if (def.includes(state)) {
var translation = hass.resources[lang]["state.default." + state ];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@
### Card Battery ###
card_battery:
template:
- "icon_info_bg"
- "icon_more_info_new"
- "ulm_actions_card"
- "ulm_translation_engine"
double_tap_action:
action: "call-service"
service: "input_select.select_option"
service_data:
option: "[[[ return variables.ulm_input_select_option ]]]"
entity_id: "[[[ return variables.ulm_input_select ]]]"
tap_action:
action: "more-info"
variables:
ulm_card_battery_attribute:
ulm_card_battery_battery_state_entity_id:
Expand All @@ -22,108 +15,106 @@ card_battery:
ulm_card_battery_color_battery_level_warning: "var(--google-yellow)"
ulm_card_battery_color_battery_level_ok: "var(--google-green)"
triggers_update: "all"
icon: |
[[[
// Get battery level
const battery_level = variables.ulm_card_battery_attribute !== null ?
states[entity.entity_id].attributes[variables.ulm_card_battery_attribute] :
states[entity.entity_id].state;
// Generate icon infix
let infix = "";
if (variables.ulm_card_battery_charger_type_entity_id == null) {
// Check wether the battery state is charging
infix = variables.ulm_card_battery_battery_state_entity_id !== null &&
states[variables.ulm_card_battery_battery_state_entity_id].state.toLowerCase() === "charging" ?
"-charging" : ""
} else {
// Select the infix based on the entity charging state
switch (states[variables.ulm_card_battery_charger_type_entity_id].state.toLowerCase()) {
case "wireless":
infix = "-charging-wireless";
break;
case "charging":
infix = "-charging";
break;
case "ac":
infix = "-charging";
break;
case "usb":
infix = "-charging";
break;
default:
infix = "";
}
}
// Generate the icon based on the battery_level
let icon = "mdi:help-circle-outline";
if (battery_level == 100) {
icon = "mdi:battery";
} else if (battery_level < 10) {
icon = "mdi:battery" + infix + "-outline";
} else if (battery_level == "unknown" || battery_level == "unavailable") {
icon = "mdi:battery-off";
} else {
icon = "mdi:battery" + infix + "-" + Math.floor(battery_level / 10) * 10;
}
return icon;
]]]
label: |
[[[
const battery_level = variables.ulm_card_battery_attribute !== null
? states[entity.entity_id].attributes[variables.ulm_card_battery_attribute]
: states[entity.entity_id].state;
return battery_level + "%";
if(battery_level == "unknown")
{ return variables.ulm_translation_state; }
else
{ return battery_level + "%"; }
]]]
name: |
[[[
return states[entity.entity_id].attributes.friendly_name;
]]]
styles:
icon:
- color: |
[[[
const battery_level = variables.ulm_card_battery_attribute !== null ?
states[entity.entity_id].attributes[variables.ulm_card_battery_attribute] :
states[entity.entity_id].state;
// Get the color based on battery_level
let color = "rgba(var(--color-theme), 0.9)";
if (battery_level !== "unavailable" && (variables.ulm_card_battery_battery_level_danger !== null || variables.ulm_card_battery_battery_level_warning !== null)) {
if (battery_level <= variables.ulm_card_battery_battery_level_danger) {
color = variables.ulm_card_battery_color_battery_level_danger;
} else if (battery_level <= variables.ulm_card_battery_battery_level_warning) {
color = variables.ulm_card_battery_color_battery_level_warning;
} else if (battery_level == "unknown" || battery_level == "unavailable") {
color = variables.ulm_card_battery_color_battery_level_danger;
} else {
color = variables.ulm_card_battery_color_battery_level_ok;
}
}
return color;
]]]
label:
- align-self: "end"
- justify-self: "start"
- font-weight: "bold"
- font-size: "14px"
- margin-left: "12px"
- filter: "opacity(100%)"
name:
- justify-self: "start"
- align-self: "start"
- font-weight: "bolder"
- font-size: "12px"
- filter: "opacity(40%)"
- margin-left: "12px"
grid:
- grid-template-areas: "'i l' 'i n'"
- grid-template-columns: "min-content auto"
- grid-template-rows: "min-content min-content"
custom_fields:
item1:
card:
type: "custom:button-card"
template:
- "icon_more_info"
custom_fields:
item1:
card:
type: "custom:button-card"
variables:
ulm_input_select_option: "[[[ return variables.ulm_input_select_option; ]]]"
ulm_input_select: "[[[ return variables.ulm_input_select; ]]]"
entity: "[[[ return entity.entity_id ]]]"
icon: |
[[[
// Get battery level
const battery_level = variables.ulm_card_battery_attribute !== null ?
states[entity.entity_id].attributes[variables.ulm_card_battery_attribute] :
states[entity.entity_id].state;
// Generate icon infix
let infix = "";
if (variables.ulm_card_battery_charger_type_entity_id == null) {
// Check wether the battery state is charging
infix = variables.ulm_card_battery_battery_state_entity_id !== null &&
states[variables.ulm_card_battery_battery_state_entity_id].state.toLowerCase() === "charging" ?
"-charging" : ""
} else {
// Select the infix based on the entity charging state
switch (states[variables.ulm_card_battery_charger_type_entity_id].state.toLowerCase()) {
case "wireless":
infix = "-charging-wireless";
break;
case "charging":
infix = "-charging";
break;
case "ac":
infix = "-charging";
break;
case "usb":
infix = "-charging";
break;
default:
infix = "";
}
}
// Generate the icon based on the battery_level
let icon = "mdi:help-circle-outline";
if (battery_level == 100) {
icon = "mdi:battery";
} else if (battery_level < 10) {
icon = "mdi:battery" + infix + "-outline";
} else if (battery_level == "unknown" || battery_level == "unavailable") {
icon = "mdi:battery-off";
} else {
icon = "mdi:battery" + infix + "-" + Math.floor(battery_level / 10) * 10;
}
return icon;
]]]
styles:
icon:
- color: |
[[[
const battery_level = variables.ulm_card_battery_attribute !== null ?
states[entity.entity_id].attributes[variables.ulm_card_battery_attribute] :
states[entity.entity_id].state;
// Get the color based on battery_level
let color = "rgba(var(--color-theme), 0.9)";
if (battery_level !== "unavailable" && (variables.ulm_card_battery_battery_level_danger !== null || variables.ulm_card_battery_battery_level_warning !== null)) {
if (battery_level <= variables.ulm_card_battery_battery_level_danger) {
color = variables.ulm_card_battery_color_battery_level_danger;
} else if (battery_level <= variables.ulm_card_battery_battery_level_warning) {
color = variables.ulm_card_battery_color_battery_level_warning;
} else if (battery_level == "unknown" || battery_level == "unavailable") {
color = variables.ulm_card_battery_color_battery_level_danger;
} else {
color = variables.ulm_card_battery_color_battery_level_ok;
}
}
return color;
]]]
item2:
card:
type: "custom:button-card"
variables:
ulm_input_select_option: "[[[ return variables.ulm_input_select_option; ]]]"
ulm_input_select: "[[[ return variables.ulm_input_select; ]]]"
entity: "[[[ return entity.entity_id ]]]"
label: |
[[[
const battery_level = variables.ulm_card_battery_attribute !== null
? states[entity.entity_id].attributes[variables.ulm_card_battery_attribute]
: states[entity.entity_id].state;
return battery_level + "%";
if(battery_level == "unknown")
{ return variables.ulm_translation_state; }
else
{ return battery_level + "%"; }
]]]
name: |
[[[
return states[entity.entity_id].attributes.friendly_name;
]]]
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
### Card Binary Sensor ###
card_binary_sensor:
template:
- "icon_info_bg"
- "icon_more_info_new"
- "blue"
- "ulm_language_variables"
- "ulm_actions_card"
show_last_changed: false
variables:
ulm_show_last_changed: false
custom_fields:
item1:
card:
Expand All @@ -20,12 +22,18 @@ card_binary_sensor:
type: "custom:button-card"
template:
- "blue"
variables:
ulm_input_select_option: "[[[ return variables.ulm_input_select_option; ]]]"
ulm_input_select: "[[[ return variables.ulm_input_select; ]]]"
entity: "[[[ return entity.entity_id ]]]"
item2:
card:
type: "custom:button-card"
template:
- "blue_no_card"
variables:
ulm_input_select_option: "[[[ return variables.ulm_input_select_option; ]]]"
ulm_input_select: "[[[ return variables.ulm_input_select; ]]]"
entity: "[[[ return entity.entity_id ]]]"
name: "[[[ return entity.attributes.friendly_name != '' ? entity.attributes.friendly_name : entity.entity_id ]]]"
show_last_changed: true
show_last_changed: "[[[ return variables.ulm_show_last_changed; ]]]"
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ card_binary_sensor_alert:
- "ulm_language_variables"
- "ulm_actions_card"
show_last_changed: false
variables:
ulm_show_last_changed: false
custom_fields:
item1:
card:
Expand All @@ -20,12 +22,18 @@ card_binary_sensor_alert:
type: "custom:button-card"
template:
- "blue"
variables:
ulm_input_select_option: "[[[ return variables.ulm_input_select_option; ]]]"
ulm_input_select: "[[[ return variables.ulm_input_select; ]]]"
entity: "[[[ return entity.entity_id ]]]"
item2:
card:
type: "custom:button-card"
template:
- "blue_no_card"
variables:
ulm_input_select_option: "[[[ return variables.ulm_input_select_option; ]]]"
ulm_input_select: "[[[ return variables.ulm_input_select; ]]]"
entity: "[[[ return entity.entity_id ]]]"
name: "[[[ return entity.attributes.friendly_name != '' ? entity.attributes.friendly_name : entity.entity_id ]]]"
show_last_changed: true
show_last_changed: "[[[ return variables.ulm_show_last_changed; ]]]"
Loading

0 comments on commit e4e104c

Please sign in to comment.