Advertisement
Guest User

Keypad

a guest
Jun 12th, 2025
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.14 KB | None | 0 0
  1. Just built a virtual keypad to go with my physical one, seems to work:
  2.  
  3. type: vertical-stack
  4. cards:
  5. - type: grid
  6. columns: 3
  7. square: false
  8. cards:
  9. - type: custom:button-card
  10. name: "1"
  11. tap_action:
  12. action: call-service
  13. service: input_text.set_value
  14. data:
  15. value: "[[[ return states['input_text.entered_pin'].state + '1'; ]]]"
  16. target:
  17. entity_id: input_text.entered_pin
  18. styles:
  19. card:
  20. - height: 80px
  21. - font-size: 32px
  22. - background-color: "#2196f3"
  23. - color: white
  24. - border-radius: 12px
  25. - type: custom:button-card
  26. name: "2"
  27. tap_action:
  28. action: call-service
  29. service: input_text.set_value
  30. data:
  31. value: "[[[ return states['input_text.entered_pin'].state + '2'; ]]]"
  32. target:
  33. entity_id: input_text.entered_pin
  34. styles:
  35. card:
  36. - height: 80px
  37. - font-size: 32px
  38. - background-color: "#2196f3"
  39. - color: white
  40. - border-radius: 12px
  41. - type: custom:button-card
  42. name: "3"
  43. tap_action:
  44. action: call-service
  45. service: input_text.set_value
  46. data:
  47. value: "[[[ return states['input_text.entered_pin'].state + '3'; ]]]"
  48. target:
  49. entity_id: input_text.entered_pin
  50. styles:
  51. card:
  52. - height: 80px
  53. - font-size: 32px
  54. - background-color: "#2196f3"
  55. - color: white
  56. - border-radius: 12px
  57. - type: custom:button-card
  58. name: "4"
  59. tap_action:
  60. action: call-service
  61. service: input_text.set_value
  62. data:
  63. value: "[[[ return states['input_text.entered_pin'].state + '4'; ]]]"
  64. target:
  65. entity_id: input_text.entered_pin
  66. styles:
  67. card:
  68. - height: 80px
  69. - font-size: 32px
  70. - background-color: "#2196f3"
  71. - color: white
  72. - border-radius: 12px
  73. - type: custom:button-card
  74. name: "5"
  75. tap_action:
  76. action: call-service
  77. service: input_text.set_value
  78. data:
  79. value: "[[[ return states['input_text.entered_pin'].state + '5'; ]]]"
  80. target:
  81. entity_id: input_text.entered_pin
  82. styles:
  83. card:
  84. - height: 80px
  85. - font-size: 32px
  86. - background-color: "#2196f3"
  87. - color: white
  88. - border-radius: 12px
  89. - type: custom:button-card
  90. name: "6"
  91. tap_action:
  92. action: call-service
  93. service: input_text.set_value
  94. data:
  95. value: "[[[ return states['input_text.entered_pin'].state + '6'; ]]]"
  96. target:
  97. entity_id: input_text.entered_pin
  98. styles:
  99. card:
  100. - height: 80px
  101. - font-size: 32px
  102. - background-color: "#2196f3"
  103. - color: white
  104. - border-radius: 12px
  105. - type: custom:button-card
  106. name: "7"
  107. tap_action:
  108. action: call-service
  109. service: input_text.set_value
  110. data:
  111. value: "[[[ return states['input_text.entered_pin'].state + '7'; ]]]"
  112. target:
  113. entity_id: input_text.entered_pin
  114. styles:
  115. card:
  116. - height: 80px
  117. - font-size: 32px
  118. - background-color: "#2196f3"
  119. - color: white
  120. - border-radius: 12px
  121. - type: custom:button-card
  122. name: "8"
  123. tap_action:
  124. action: call-service
  125. service: input_text.set_value
  126. data:
  127. value: "[[[ return states['input_text.entered_pin'].state + '8'; ]]]"
  128. target:
  129. entity_id: input_text.entered_pin
  130. styles:
  131. card:
  132. - height: 80px
  133. - font-size: 32px
  134. - background-color: "#2196f3"
  135. - color: white
  136. - border-radius: 12px
  137. - type: custom:button-card
  138. name: "9"
  139. tap_action:
  140. action: call-service
  141. service: input_text.set_value
  142. data:
  143. value: "[[[ return states['input_text.entered_pin'].state + '9'; ]]]"
  144. target:
  145. entity_id: input_text.entered_pin
  146. styles:
  147. card:
  148. - height: 80px
  149. - font-size: 32px
  150. - background-color: "#2196f3"
  151. - color: white
  152. - border-radius: 12px
  153. - type: custom:button-card
  154. name: Clear
  155. tap_action:
  156. action: call-service
  157. service: input_text.set_value
  158. data:
  159. value: ""
  160. target:
  161. entity_id: input_text.entered_pin
  162. styles:
  163. card:
  164. - height: 80px
  165. - font-size: 26px
  166. - background-color: "#f44336"
  167. - color: white
  168. - border-radius: 12px
  169. - type: custom:button-card
  170. name: "0"
  171. tap_action:
  172. action: call-service
  173. service: input_text.set_value
  174. data:
  175. value: "[[[ return states['input_text.entered_pin'].state + '0'; ]]]"
  176. target:
  177. entity_id: input_text.entered_pin
  178. styles:
  179. card:
  180. - height: 80px
  181. - font-size: 32px
  182. - background-color: "#2196f3"
  183. - color: white
  184. - border-radius: 12px
  185. - type: custom:button-card
  186. name: Enter
  187. tap_action:
  188. action: call-service
  189. service: script.turn_on
  190. target:
  191. entity_id: script.validate_pin
  192. styles:
  193. card:
  194. - height: 80px
  195. - font-size: 26px
  196. - background-color: "#4caf50"
  197. - color: white
  198. - border-radius: 12px
  199.  
  200. There's probably a better way to go about it but, just a POC.
  201.  
  202. Requires
  203.  
  204. input_text:
  205. entered_pin:
  206. name: Entered PIN
  207. initial: ""
  208. max: 20
  209. correct_pin:
  210. name: Correct PIN
  211. max: 20
  212.  
  213. and a script validate\_pin to do the validation against correct\_pin - I have an input box where I can set that on my admin dash.
  214.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement