This might be a bug I think… I’m trying to make a keypad with numbers 0-9 and a decimal. This is working fine until I use the decimal. If I enter 1 and then press the decimal, I get 1.0 so impossible to enter 1.5 as the system added the 0 by itself. I’m sure it is some sort of internal decision to automatically convert it to a number (some sort of AI ). It is strange to do that with an entity called INPUT_TEXT.
I use custom buttons. like this:
type: custom:button-card
color_type: icon
entity: input_text.keypad_input
aspect_ratio: 1/1
show_label: true
show_name: false
show_icon: false
show_state: false
tap_action:
action: call-service
service: script.keypad_input_2
service_data:
number: "7"
size: 80%
name: ""
label: "7"
styles:
card:
- border-radius: 10%
- padding: 10%
- font-size: 80px
- text-shadow: 0px 0px 5px black
name:
- font-size: 40px
- text-transform: uppercase
- letter-spacing: 0.5em
- font-familly: cursive
- padding: 0px 5px
The “Service_data Number” is set to the digit I want. Same thing for the decimal place. The script.keypad_input_2 is as follow:
data_template:
entity_id: input_text.keypad_input
value: |
{% set current_value = states('input_text.keypad_input') %}
{% if current_value != 'None' and current_value != 'unknown' %}
{{ current_value ~ number | string }}
{% else %}
{{ number | string }}
{% endif %}
action: input_text.set_value
if I press 1, I get 1
then I press . I get 1.0
but if I press again ., I get 1.0.
I clear
I press . I get .
I press 2 I get 0.2
It means that I the text entered is valid number, it format it as a number. So if I put a letter at the beginning, then it stays as a text.
Anyone has a solution to bypass this bug?