home-assistant / intents

Intents to be used with Home Assistant
https://developers.home-assistant.io/docs/voice/overview/
Creative Commons Attribution 4.0 International
461 stars 527 forks source link

In the case of covers, the "which" / "how many" questions do not work. #1948

Open v1k70rk4 opened 9 months ago

v1k70rk4 commented 9 months ago

Hello, I noticed something that I think used to work: If I ask whether the living room door is open, I get a correct answer that it is. But if I ask how many doors are open, it says 0 and it's as if it doesn't see a single door at all. The question seems to be language-independent because I get a similar result in English as well.

Q: A nappali ajtó nyitva van? [living room door is open] R: yes

intent:
  name: HassGetState
slots:
  name: nappali ajtó
  state: nyitva
  domain: binary_sensor
  device_class: door
details:
  name:
    name: name
    value: Nappali ajtó
    text: nappali ajtó
  state:
    name: state
    value: 'on'
    text: nyitva
  domain:
    name: domain
    value: binary_sensor
    text: ''
  device_class:
    name: device_class
    value: door
    text: ''
targets:
  binary_sensor.nyitaserzekelo_nappali_ajto_contact:
    matched: true
match: true
sentence_template: <name> {bs_door_states:state} van [<area>]
unmatched_slots: {}
source: builtin

Q: Hány ajtó van nyitva? [ how many doors are open] R: 0 It shows here that there are no targets even though there are 3 doors that I am monitoring.

intent:
  name: HassGetState
slots:
  device_class: ajtó
  state: nyitva
  domain: cover
details:
  device_class:
    name: device_class
    value: door
    text: ajtó
  state:
    name: state
    value: open
    text: nyitva
  domain:
    name: domain
    value: cover
    text: ''
targets: {}
match: true
sentence_template: <mennyi> {cover_classes:device_class} van {cover_states:state} [<area>]
unmatched_slots: {}
source: builtin
tetele commented 9 months ago

There are a few types of devices for which the entity selection is difficult, the implementation lacking and, thus, they produce unexpected result.

The root of the issue is selecting entities across multiple "filters" (e.g. domain or domain+device_class). Let's say we're talking about windows and you want to know "how many windows are open".

In HA there are 2 types of "windows"

A comprehensive query would take all of these entities, filter on state and count all of the matched entities. However, due to the way the recognition engine is set up, we can only have a single "filter" defined by requires_context/excludes_context and the current implementation (for windows, at least) is to count all cover entities, having no equivalent for binary_sensor.

It is indeed an issue, but the solution is not in the intents repo, but rather in how we should query for entities.

v1k70rk4 commented 9 months ago

Hi, now I understand everything. Should I open a bug in the core for this, or should we consider it correct behavior?