Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hassil-0.1.2.tar.gz (27.0 kB view details)

Uploaded Source

File details

Details for the file hassil-0.1.2.tar.gz.

File metadata

  • Download URL: hassil-0.1.2.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for hassil-0.1.2.tar.gz
Algorithm Hash digest
SHA256 76048ddcd4303e28880991ff2ce3ebb1b80d5dfbfc140c6052d4a9bf0519abe1
MD5 444837be49c45d25bae407933e3ce76f
BLAKE2b-256 9d258e4a38c873a45d881503f90ed422343a5787a4e9812209edf3ec67aee37b

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page