I am trying to create a custom intent that can match and capture a decimal value. It appears as though the intent parser does not recognise numerics containing a decimal point. Is this intentional or am I missing something?
The reason I would like this is so that I can set my thermostat to [say] 18.5 degrees.
My custom intent looks like this;
"<numeric_value_set> [the] (heat|heating|thermostat) to <temperature>"
I can “set heat to 18”, but not “set heat to 18.5”.
Rather strangely, if I create an automation that is triggered by a sentence, then it does work, although the processing is clearly somewhat different as the intent expansion rules are not available, so it is being parsed differently. Long term I’d rather not use automations to support sentences since the intent infrastructure is there.
OK, well, in case anyone comes here. This is what I had to do to get decimal places recognised for my thermostat. To be clear, I am doing this because HassClimateSetTemperature is not supported [yet].
I had to switch from a custom intent in configuration.yaml to using custom_sentences since they support more features and I needed the ability to use slots.
I ended up with this intent;
language: "en"
intents:
CustomSetHeat:
data:
- sentences:
- "<numeric_value_set> [the] (heat|heating|thermostat) to {degrees}[.{fraction}]
[degrees]"
slots:
fraction: 0
domain: "climate"
lists:
degrees:
range:
from: 5
to: 30
fraction:
range:
from: 0
to: 9
The use of the slot allows me to default the fraction to zero in the case that it was not specified.
I don’t feel as though this level of understanding of lexical tokenising and parsing is something that the user should have to understand. Hassil should support this. However, the parser in Hassil is hand coded which is… a bold move in 2024!
Given that Hassil doesn’t currently support this, here we are.
For completeness, my intent script in configuration.yaml looks like this;
intent_script:
CustomSetHeat:
action:
- service: climate.set_temperature
target:
entity_id: climate.actual
data:
temperature: "{{ int(degrees) + int(fraction)/10 }}"
speech:
text: "Heat set to {{ state_attr('climate.actual', 'temperature') }}"