Skip to main content

The Home Assistant Intent Language parser

Project description

HassIL

The Home Assistant Intent Language (HassIL) parser for intents.

Template syntax

Dependencies

  • PyYAML

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 --areas 'living room'
what is the temperature in the living room
{'intent': 'HassClimateGetTemperature', 'area': 'living room', 'domain': 'climate'}

Make sure to provide area names 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 degrees 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

Uses a custom parser written in Python.

  • Alternative words or phrases
    • (red|green|blue)
    • turn(s|ed|ing)
  • Optional words or phrases
    • [the]
    • [this|that]
    • light[s]
  • Permutations of words or phrases
    • (patience; you must have) my young Padawan
    • is [the] light (on; in <area>)
  • Slot Lists
    • {list_name}
    • {list_name:slot_name}
    • Refers to a pre-defined list of values in YAML (lists), either global or local (particular to the intent to which the sentence refers)
  • Expansion Rules
    • <rule_name>
    • Refers to a pre-defined expansion rule in YAML (expansion_rules), either global or local (particular to the intent to which the sentence refers)

YAML Format

language: "<language code>"
intents:
  <intent name>:
    data:
      # List of sentences/slots/etc.
      - sentences:
          - "<sentence template>"
          - "<sentence template>"
        # Optional
        slots:
          # Fixed slots for the recognized intent
          <name>: <value>
        requires_context:
          # Must be present in match context
          <name>: # Any provided value is good
        excludes_context:
          # Must NOT be present in match context
          <name>: <value or list>
        expansion_rules:
          # Expansion rules which only apply to the intent, referenced as <rule_name>
          <rule_name>: <sentence template>
        lists:
          # Lists which apply only to the current set of sentences, referenced as {list_name} or {list_name:slot_name}
          <list name>:
            values:
              # See below for other possible types
              - "items"
              - "in list"
        metadata:
          # Arbitrary key/value pairs that will be available in the result
          <key>: <value>

# Optional lists of items that become alternatives in sentence templates
lists:
  # Referenced as {list_name} or {list_name:slot_name}
  <list name>:
    values:
      - "items"
      - "in list"
      - in: "text in"
        out: <value for slot>
        # Optional
        context:
          <name>: <value>
        metadata:
          # Arbitrary key/value pairs that will be available in the result
          <key>: <value>
  <range_name>
    range:
      type: "number"
      from: 0
      to: 100  # inclusive
      multiplier: 1.0  # multiply to get final value
  <wildcard_name>
    wildcard: true

# Optional rules that are expanded in sentence templates
expansion_rules:
  # Referenced as <rule_name>
  <rule_name>: "<sentence template>"

# Optional words that the intent recognizer can skip during recognition
skip_words:
  - "<word>"

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-3.5.0.tar.gz (61.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hassil-3.5.0-py3-none-any.whl (51.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hassil-3.5.0.tar.gz
  • Upload date:
  • Size: 61.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hassil-3.5.0.tar.gz
Algorithm Hash digest
SHA256 bed39573626d76bfc0681a709a6b64e4de82a680371bd29238473f6711392597
MD5 7799a969072a634cbb2135f045b3ca36
BLAKE2b-256 87bf9630f99bcc3dca337e3905571d1e06f0317fcc1aec2d3b5a0933b810f9cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for hassil-3.5.0.tar.gz:

Publisher: publish.yml on OHF-Voice/hassil

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hassil-3.5.0-py3-none-any.whl.

File metadata

  • Download URL: hassil-3.5.0-py3-none-any.whl
  • Upload date:
  • Size: 51.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hassil-3.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87b2a48164b2de1d693edbe4204b3a7c3b72dc7c5c3829774de8824ecc62ab96
MD5 b19e49ebc32ce5eba908b9294ecff39f
BLAKE2b-256 7a4e94d688f7fb23b6e898922a077d7e32a6f412372ff285567d890a8791de7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for hassil-3.5.0-py3-none-any.whl:

Publisher: publish.yml on OHF-Voice/hassil

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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