9
9
10
10
This is a ` custom-card ` that works in switch logic with a ` lock ` entity. Card structure uses ` lock ` , ` unlock ` (optional ` open ` ) actions and ` lock ` ,` unlock ` ,` locking ` ,` unlocking ` , ` jammed ` states.
11
11
12
- ![ Generic] ( ../../assets/img/custom_card_eraycetinay_lock_locked.png )
13
- ![ Generic] ( ../../assets/img/custom_card_eraycetinay_lock_unlocked.png )
12
+ ![ Generic] ( ../../assets/img/custom_card_eraycetinay_lock.png )
14
13
15
14
## Credits
16
15
17
16
Author: eraycetinay - 2022
18
- Version: 0.0.1
17
+ Version: 0.0.3
19
18
20
19
## Changelog
21
20
21
+ <details >
22
+ <summary >0.0.3</summary >
23
+ <ul >
24
+ <h4>Contributor: <a href="https://github.com/sisimomo">Sisimomo</a> - 2022-06-14</h4>
25
+ <li>Now can displays a warning when the battery is low.</li>
26
+ <li>Now can displays a warning when the door is lock but the door is still open.</li>
27
+ <li>Code refactoring to fit <a href="https://ui-lovelace-minimalist.github.io/UI/development/custom_cards/#order">framework structure</a>.</li>
28
+ <li>Documentation clean up.</li>
29
+ <li>Code clean up.</li>
30
+ </ul >
31
+ </details >
22
32
<details >
23
33
<summary >0.0.2</summary >
24
34
Added option to only use lock.open
35
+ </details >
36
+ <details >
25
37
<summary >0.0.1</summary >
26
38
Initial release
27
39
</details >
@@ -34,127 +46,72 @@ Version: 0.0.1
34
46
template : " custom_card_eraycetinay_lock"
35
47
name : " Door Lock"
36
48
variables :
37
- ulm_custom_card_eraycetinay_lock_tap_control : true
38
- ulm_custom_card_eraycetinay_lock_open : true
49
+ custom_card_eraycetinay_lock_tap_control : true
50
+ custom_card_eraycetinay_lock_battery_level : sensor.door_battery
51
+ custom_card_eraycetinay_lock_door_open : binary_sensor.door_open
52
+ triggers_update :
53
+ - " sensor.door_battery"
54
+ - " binary_sensor.door_open"
39
55
` ` `
40
56
41
57
## Variables
42
58
43
59
<table>
44
- <tr>
45
- <th>Variable</th>
46
- <th>Example</th>
47
- <th>Required</th>
48
- <th>Explanation</th>
49
- </tr>
50
- <tr>
51
- <td>ulm_custom_card_eraycetinay_lock_tap_control</td>
52
- <td>true</td>
53
- <td>no</td>
54
- <td>Lock/Unlock on tap action</td>
55
- </tr>
56
- <tr>
57
- <td>ulm_custom_card_eraycetinay_lock_open</td>
58
- <td>true</td>
59
- <td>no</td>
60
- <td>Only use the card to open the door (always sends lock.open on tap)</td>
61
- </tr>
60
+ <tr>
61
+ <th>Variable</th>
62
+ <th>Example</th>
63
+ <th>Default</th>
64
+ <th>Required</th>
65
+ <th>Explanation</th>
66
+ </tr>
67
+ <tr>
68
+ <td>custom_card_eraycetinay_lock_tap_control</td>
69
+ <td>true</td>
70
+ <td>false</td>
71
+ <td>no</td>
72
+ <td>Lock/Unlock on tap action</td>
73
+ </tr>
74
+ <tr>
75
+ <td>custom_card_eraycetinay_lock_only_open</td>
76
+ <td>true</td>
77
+ <td>false</td>
78
+ <td>no</td>
79
+ <td>Only use the card to open the door (always sends lock.open on tap)</td>
80
+ </tr>
81
+ <tr>
82
+ <td>custom_card_eraycetinay_lock_battery_level</td>
83
+ <td>sensor.door_battery</td>
84
+ <td></td>
85
+ <td>no</td>
86
+ <td>Displays a warning when the battery is low.</td>
87
+ </tr>
88
+ <tr>
89
+ <td>custom_card_eraycetinay_lock_battery_warning</td>
90
+ <td>25</td>
91
+ <td>20</td>
92
+ <td>no</td>
93
+ <td>At what battery percentage should the low battery warning appear.</td>
94
+ </tr>
95
+ <tr>
96
+ <td>custom_card_eraycetinay_lock_battery_warning_low</td>
97
+ <td>10</td>
98
+ <td>5</td>
99
+ <td>no</td>
100
+ <td>At what battery percentage should the very low battery warning appear.</td>
101
+ </tr>
102
+ <tr>
103
+ <td>custom_card_eraycetinay_lock_door_open</td>
104
+ <td>binary_sensor.door_open</td>
105
+ <td></td>
106
+ <td>no</td>
107
+ <td>Displays a warning when the door is lock but the door is still open.</td>
108
+ </tr>
62
109
</table>
63
110
64
111
## Template code
65
112
66
- ` ` ` yaml
67
- ---
68
- custom_card_eraycetinay_lock :
69
- template :
70
- - " ulm_custom_card_eraycetinay_lock_language_variables"
71
- - " icon_info_bg"
72
- - " ulm_language_variables"
73
- tap_action :
74
- action : |
75
- [[[
76
- if(variables.ulm_custom_card_eraycetinay_lock_tap_control == true){
77
- return "call-service";
78
- } else {
79
- return "more-info";
80
- }
81
- ]]]
82
- # only related with call-service action
83
- service : |
84
- [[[
85
- if(variables.ulm_custom_card_eraycetinay_lock_tap_control == true){
86
- if(variables.ulm_custom_card_eraycetinay_lock_open == true){
87
- return "lock.open"
88
- } else {
89
- if (entity.state == "locked"){
90
- return "lock.unlock"
91
- }
92
- } else if (entity.state == "unlocked"){
93
- return "lock.lock"
94
- }
95
- }
96
- } else {
97
- return;
98
- }
99
- ]]]
100
- # only related with call-service action
101
- service_data :
102
- entity_id : |
103
- [[[ return entity.entity_id ]]]
104
- show_label : true
105
- show_name : true
106
- triggers_update :
107
- - " [[[ return entity.entity_id ]]]"
108
- label : |
109
- [[[
110
- if (entity.state != "unavailable"){
111
- if (entity.state == "locked"){
112
- return variables.custom_card_eraycetinay_lock_locked;
113
- } else if (entity.state == "unlocked"){
114
- return variables.custom_card_eraycetinay_lock_unlocked;
115
- } else if (entity.state == "open"){
116
- return variables.ulm_open;
117
- } else if (entity.state == "unlocking"){
118
- return variables.custom_card_eraycetinay_lock_unlocking;
119
- } else if (entity.state == "locking"){
120
- return variables.custom_card_eraycetinay_lock_locking;
121
- } else if (entity.state == "jammed"){
122
- return variables.custom_card_eraycetinay_lock_jammed;
123
- } else {
124
- return entity.state;
125
- }
126
- } else {
127
- return custom_card_eraycetinay_lock_unavailable;
128
- }
129
- ]]]
130
- state :
131
- - operator : " template"
132
- value : |
133
- [[[
134
- return entity.state == "unlocked";
135
- ]]]
136
- styles :
137
- icon :
138
- - color : " [[[ return `rgba(var(--color-yellow), 1)`; ]]]"
139
- img_cell :
140
- - background-color : " [[[ return `rgba(var(--color-yellow), 0.2)`; ]]]"
141
- - operator : " template"
142
- value : |
143
- [[[
144
- return entity.state == "locked";
145
- ]]]
146
- styles :
147
- icon :
148
- - color : " [[[ return `rgba(var(--color-green), 1)`; ]]]"
149
- img_cell :
150
- - background-color : " [[[ return `rgba(var(--color-green), 0.2)`; ]]]"
151
- styles :
152
- icon :
153
- - color : " rgba(var(--color-theme),0.2)"
154
- img_cell :
155
- - background-color : " rgba(var(--color-theme),0.05)"
156
- - border-radius : " 50%"
157
- - place-self : " center"
158
- - width : " 42px"
159
- - height : " 42px"
160
- ` ` `
113
+ ??? note "Template Code"
114
+
115
+ ` ` ` yaml title="custom_card_eraycetinay_lock.yaml"
116
+ --8<-- "custom_cards/custom_card_eraycetinay_lock/custom_card_eraycetinay_lock.yaml"
117
+ ```
0 commit comments