The Home Assistant Intent Language parser
Project description
HassIL
The Home Assistant Intent Language (HassIL) parser for intents.
Dependencies
- antlr4-python3-runtime
- PyYAML
- dataclasses-json
Installation
Run the script/setup
script to automatically create a virtual environment and install the requirements.
Running
python3 -m hassil <yaml_file_or_directory> [<yaml_file_or_directory> ...]
Once loaded, you may type in a sentence and see what intent it matches. For example:
python3 -m hassil examples/en.yaml
what is the temperature in the living room
{'intent': 'HassClimateGetTemperature', 'area': 'living room', 'domain': 'climate'}
By default, the areas "kitchen", "bedroom", and "living room" are available. You can override this with --areas
. Device or entity names can be provided with --names
.
python3 -m hassil examples/en.yaml --areas office --names trapdoor
open the trapdoor in the office
{'intent': 'HassOpenCover', 'name': 'trapdoor', 'area': 'office'}
Sampling Sentences
Sentences for each intent can be sampled from the intent YAML files:
python3 -m hassil.sample examples/en.yaml -n 1
{"intent": "HassTurnOn", "text": "turn on the entity"}
{"intent": "HassTurnOff", "text": "turn off the entity"}
{"intent": "HassOpenCover", "text": "open the entity in the area"}
{"intent": "HassCloseCover", "text": "close the entity in the area"}
{"intent": "HassLightsSet", "text": "set the entity color to red"}
{"intent": "HassClimateSetTemperature", "text": "set temperature to 0 degree s in the area"}
{"intent": "HassClimateGetTemperature", "text": "what is the temperature in the area"}
The --areas
and --names
arguments are the same from python3 -m hassil
, but default to generic "area" and "entity" terms.
Exclude the -n
argument to sample all possible sentences.
Sentence Templates
Parsed using a custom ANTLR grammar (see HassILGrammar.g4
).
- Alternative words or phrases
(red | green | blue)
- Optional words or phrases
[the]
[this | that]
- Slot Lists
{list_name}
{list_name:slot_name}
- Refers to a pre-defined list of values in YAML (
lists
)
- Expansion Rules
<rule_name>
- Refers to a pre-defined expansion rule in YAML (
expansion_rules
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file hassil-0.1.3.tar.gz
.
File metadata
- Download URL: hassil-0.1.3.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2969331d6328e74388ad9da4c05861a834a5785164003eff26e823bd2c82930c |
|
MD5 | 0a6babf44468a40c57d1c55215a41451 |
|
BLAKE2b-256 | 8e619c9995cc54b5f8c40a4bf496103f1282b025afd92417c68c76c3a91b2003 |