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:

` sh python3 -m venv .venv .venv/bin/pip3 install --upgrade pip .venv/bin/pip3 install --upgrade wheel setuptools `

Install dependencies:

` sh .venv/bin/pip3 install -r requirements.txt `

# Running

` sh 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:

` sh 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.

` sh 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:

` sh 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](https://www.antlr.org) grammar (see [HassILGrammar.g4](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.0.tar.gz (19.9 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: hassil-0.1.0.tar.gz
  • Upload date:
  • Size: 19.9 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.0.tar.gz
Algorithm Hash digest
SHA256 d36c9503bea184ab25bdfb38a47e7ea7b329834c2b6489c4e951642cedad9613
MD5 3658b7689ac2a0b01da48cc84ad7c104
BLAKE2b-256 9171c8d0087dbe6b03284a97f77ce80bd87b0d3a462dc886a056ea52e71fc541

See more details on using hashes here.

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