Skip to content

Commit 2b5fad9

Browse files
authoredApr 5, 2023
Merge pull request #1239 from UI-Lovelace-Minimalist/release
Release
2 parents a2d8c90 + 75312f7 commit 2b5fad9

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
 

‎custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_battery.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ card_battery:
99
ulm_card_battery_attribute:
1010
ulm_card_battery_battery_state_entity_id:
1111
ulm_card_battery_charger_type_entity_id:
12+
ulm_card_battery_charging_animation: false
1213
ulm_card_battery_battery_level_danger:
1314
ulm_card_battery_battery_level_warning:
1415
ulm_card_battery_color_battery_level_danger: "var(--google-red)"
@@ -52,6 +53,7 @@ card_battery:
5253
if (variables.ulm_card_battery_charger_type_entity_id == null) {
5354
// Check wether the battery state is charging
5455
infix = variables.ulm_card_battery_battery_state_entity_id !== null &&
56+
variables.ulm_card_battery_charging_animation === false &&
5557
states[variables.ulm_card_battery_battery_state_entity_id].state.toLowerCase() === "charging" ?
5658
"-charging" : ""
5759
} else {
@@ -86,6 +88,17 @@ card_battery:
8688
}
8789
return icon;
8890
]]]
91+
extra_styles: |
92+
@keyframes charge {
93+
0%, 80% { clip-path: inset(0 0 0 0); }
94+
10% { clip-path: polygon(0% 0%, 0% 100%, 34% 100%, 34% 40%, 66% 40%, 66% 66%, 34% 66%, 34% 100%, 100% 100%, 100% 0%); }
95+
20% { clip-path: polygon(0% 0%, 0% 100%, 34% 100%, 34% 40%, 66% 40%, 66% 62%, 34% 62%, 34% 100%, 100% 100%, 100% 0%); }
96+
30% { clip-path: polygon(0% 0%, 0% 100%, 34% 100%, 34% 40%, 66% 40%, 66% 58%, 34% 58%, 34% 100%, 100% 100%, 100% 0%); }
97+
40% { clip-path: polygon(0% 0%, 0% 100%, 34% 100%, 34% 40%, 66% 40%, 66% 54%, 34% 54%, 34% 100%, 100% 100%, 100% 0%); }
98+
50% { clip-path: polygon(0% 0%, 0% 100%, 34% 100%, 34% 40%, 66% 40%, 66% 50%, 34% 50%, 34% 100%, 100% 100%, 100% 0%); }
99+
60% { clip-path: polygon(0% 0%, 0% 100%, 34% 100%, 34% 40%, 66% 40%, 66% 46%, 34% 46%, 34% 100%, 100% 100%, 100% 0%); }
100+
70% { clip-path: polygon(0% 0%, 0% 100%, 34% 100%, 34% 40%, 66% 40%, 66% 40%, 34% 40%, 34% 100%, 100% 100%, 100% 0%); }
101+
}
89102
styles:
90103
icon:
91104
- color: |
@@ -108,6 +121,15 @@ card_battery:
108121
}
109122
return color;
110123
]]]
124+
- animation: |
125+
[[[
126+
if (variables.ulm_card_battery_battery_state_entity_id !== null &&
127+
variables.ulm_card_battery_charging_animation === true &&
128+
states[variables.ulm_card_battery_battery_state_entity_id].state.toLowerCase() === "charging"){
129+
return "charge 3s linear infinite"
130+
}
131+
return "none"
132+
]]]
111133
item2:
112134
card:
113135
type: "custom:button-card"

‎docs/usage/cards/card_battery.md

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ hide:
99

1010
![example-image](../../assets/img/ulm_cards/card_battery.png){ width="500" }
1111

12+
Charging animation if `ulm_card_battery_charging_animation` is true:
13+
14+
<img src="https://user-images.githubusercontent.com/63370033/224753515-2dd8ca0e-42b9-4385-add9-4a1c42addaca.gif" width="475" />
15+
1216
The `battery-card` is a slightly enhanced `generic-card`, that can indicate whether and how a device is being charged and colors the icon based on the battery level.
1317

1418
## Variables
@@ -20,6 +24,7 @@ The `battery-card` is a slightly enhanced `generic-card`, that can indicate whet
2024
| ulm_card_battery_attribute | | :material-close: | If your entity provides the battery percent in an attribute (= not as an own sensor), fill in the attribute's name here. E.g. if you have `sensor.livingroom_thermometer` and the attribute for your battery power is `sensor.livingroom_thermometer.attributes.battery_percent`, you fill in battery_percent here. |
2125
| ulm_card_battery_battery_state_entity_id | | :material-close: | Entity that holds the battery state (charging/discharging). If provided, the Icon will display the current status. |
2226
| ulm_card_battery_charger_type_entity_id | | :material-close: | Entity that holds the charger type (ac/wireless/none). This Entity replaces the need for the `ulm_card_battery_battery_state_entity_id` entity. If provided, the Icon will display the current charger type. This is only useful if you charge your devices Wireless and with cable. |
27+
| ulm_card_battery_charging_animation | `false` | :material-close: | Weather to show charging animation or not. If set to `true`, `ulm_card_battery_battery_state_entity_id` needs to be defined and `ulm_card_battery_charger_type_entity_id` will be ignored. |
2328
| ulm_card_battery_battery_level_danger | | :material-check: | Changes the color of the Icon, if the battery level falls below the provided value. Must be higher than `ulm_card_battery_battery_level_waring` |
2429
| ulm_card_battery_battery_level_waring | | :material-check: | Changes the color of the Icon, if the battery level falls below the provided value. |
2530
| ulm_card_battery_color_battery_level_danger | var(--google-red) | :material-close: | Color of icon if battery level is within the 'danger' zone. |

0 commit comments

Comments
 (0)
Please sign in to comment.