Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Sentence templates #32

Open
tetele opened this issue Mar 1, 2023 · 0 comments
Open

[Feature] Sentence templates #32

tetele opened this issue Mar 1, 2023 · 0 comments

Comments

@tetele
Copy link
Contributor

tetele commented Mar 1, 2023

When setting up sentences for binary sensors, it's usually a repetitive process, but with slight variations.

      - sentences:
          - "(is|are) <name> [battery] {bs_battery_states:state} [in <area>]"
        response: one_yesno
        requires_context:
          domain: binary_sensor
          device_class: battery
        slots:
          domain: binary_sensor
          device_class: battery

...

      - sentences:
          - "(is|are) <name> {bs_gas_states:state} [in <area>]"
        response: one_yesno
        requires_context:
          domain: binary_sensor
          device_class: gas
        slots:
          domain: binary_sensor
          device_class: gas

We could define a template sentence in _common.yaml

    sentence_templates:
      is_name_state_in_area:
        sentence: "(is|are) <name> <state> [in <area>]"
        defaults:
          state: "{state}"

write these sentences in a more extensible manner like this

      - sentences:
          - template: is_name_state_in_area
            data:
              name: "<name> [battery]"
              state: "{bs_battery_states:state}"
        response: one_yesno
        requires_context:
          domain: binary_sensor
          device_class: battery
        slots:
          domain: binary_sensor
          device_class: battery

...

      - sentences:
          - template: is_name_state_in_area
            data:
              name: "<name>"
              state: "{bs_gas_states:state}"
        response: one_yesno
        requires_context:
          domain: binary_sensor
          device_class: gas
        slots:
          domain: binary_sensor
          device_class: gas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant