The Home Assistant Intent Language parser
Project description
HassIL
The Home Assistant Intent Language (HassIL) parser.
Dependencies
- antlr4-python3-runtime
- PyYAML
- dataclasses-json
Installation
Create a virtual environment:
python3 -m venv .venv
.venv/bin/pip3 install --upgrade pip
.venv/bin/pip3 install --upgrade wheel setuptools
Install dependencies:
.venv/bin/pip3 install -r requirements.txt
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:
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 sentences/en --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 sentences/en -n 1
{"intent": "HassTurnOff", "text": "turn off all the fan in the area"}
{"intent": "HassTurnOn", "text": "turn on the light in the area"}
{"intent": "HassCloseCover", "text": "close the entity"}
{"intent": "HassClimateSetTemperature", "text": "set the temp to 0 degrees celsius"}
{"intent": "HassLightSet", "text": "set the entity brightness to 0 percent"}
{"intent": "HassOpenCover", "text": "open the entity"}
{"intent": "HassClimateGetTemperature", "text": "what's the temp"}
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
- Expansion Rules
<rule_name>
- Refers to a pre-defined expansion rule in YAML
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.1.tar.gz
.
File metadata
- Download URL: hassil-0.1.1.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7de9e8099354bf06a7121eaaceefb5d2607e274c9717056886eaf451c7e800b5 |
|
MD5 | 7f09384fe5b74226beafae0e720b0ce8 |
|
BLAKE2b-256 | c401e3ad40f6fa62bf9be8330e61a53b33251b6a3d8c254c587900e5884b5aa9 |