#Ok Nabu - Turn on the patio light for 5 minutes

1 messages · Page 1 of 1 (latest)

hollow sage
#

I am trying to move over from Alexa, we have multiple HA voice assistants working. The correct entities are exposed, and I have had to wrap some external api calls as yaml switches. I am now going through all our popular Alexa commands. The above command cannot process the “for 5 minutes” the lights are left on ,with no error. Any ideas how to solve this?

candid marlin
#

If it's okay to use an LLM based Assist pipeline you could write a script that takes 2 parameters (a list of lights and a duration) and expose that script to Assist. Provide details for the AI on how to use the script in the script's description. It should then pick up your request and call the script and provide the mentioned lights and duration.

hollow sage
#

Thanks , I will try to unpick your answer . I wonder how Alexa does it.

verbal thicket
cobalt elbow
#

Generally, we already have pending commands, and you can say “turn off the lights in 5 minutes”. But this functionality seems to be broken if the llm agent is selected😕 .
Your request is a bit more complex, I think creating custom sentences would completely solve your problem if you are using built-in intents.

hollow sage
#

I tried this , but It is matching HassTurnOn intent_script:
TurnOnLightWithTimer:
speech:
text: "Turn [on] [the] {{ name }} lights for {{ duration }}"
action:
- service: light.turn_on
target:
entity_id: "light.{{ name | lower | replace(' ', '') }}"
- delay: "{{ duration }}"
- service: light.turn_off
target:
entity_id: "light.{{ name | lower | replace(' ', '
') }}"

cobalt elbow
#

It would be interesting to solve the problem, but I encountered a problem when using the {name} variable.

  turnontimer:
    data:
      - sentences:
          - “Turn on {name} for {tm}”

turnontimer:
  action:
    - action: light.turn_on
      target:
        entity_id: “{{ name }}”
  speech:
    text: “ok”

I'm pretty sure I was getting the entity_id in the script a year ago, not the requested name (friendly_name or aliases).
Apparently I need to proceed by analogy with rooms - area_entities(area), but there is no such function for entities. And the documentation on this issue has not been updated.
Or am I missing something? The sentence parser understands that it should return id for the {name} variable, but it doesn't pass targets: to the script.

intent:
  name: turnontimer
slots:
  name: torch
  tm: 5 minutes
details:
  name:
    name: name
    value: torch
    text: torch
  tm:
    name: tm
    value: 5 minutes
    text: 5 minutes
targets:
  light.yeelight_ceil26_0x12ebfa38:
    matched: true
match: true
sentence_template: turn on {name} for {tm}
unmatched_slots: {}
source: custom

When actually running the intent, the target gets the torch value and everything fails.

@verbal thicket I know you solved the problem with aliases for area and floors, maybe you can clarify this issue too?

cobalt elbow
# hollow sage I tried this , but It is matching HassTurnOn intent_script: TurnOnLightWit...

if we manage to deal with the previous question (I would like to find a simple solution rather than parsing core.entity_registry), it is better to use a script.turn_on - this will finalize the intent, and the actions will be run in a parallel process.

    action: script.turn_on
    data:
      entity_id: script.turn_off_light_with_delay
      variables:
        name: “{{ name }}”
        time: “{{ tm }}”

Additionally, the script will need to organize the logic to handle the time variable to account for seconds, minutes and hours.

hollow sage
#

From the output of developer / assist it does not not appear to be even considering my intent script

cobalt elbow
verbal thicket
cobalt elbow
# verbal thicket I guess you can check how inbuilt intents work (HassTurnOn). I guess for entity ...

The point is, I looked at the homeassistant\helpers\intent.py file. The logic of its operation is clear (async_match_targets and _filter_by_name), but based on the actual result, these mechanisms don’t apply to custom sentences. It seems we need another function, say get_entity_id(name_or_alias_or_id), that should perform similar target-matching actions, but this hasn’t been implemented to date. So, the question is withdrawn.

hollow sage
#

just had a quick look at the code, final question - where are the individual internal intents definded eg HassTurnOn

#

sorry - found it

cobalt elbow
hollow sage
#

Looks great thanks , will get my head around it tomorrow

quartz peak
cobalt elbow
quartz peak
# cobalt elbow Did you replace unit.startswith('сек') with unit.startswith('sec')? And similar...

I just looked at the yaml code. It is showing tons of errors. Here is what i did. I DL the yaml file from your link. Using File Browser I imported it to the Custom Sentences directory. When I then opened it it shows multiple errors. I tried to copy some of it to post but the errors dont copy. I think one of the messages when i first opened it was that it couldn't be parsed so was being ignored. I'm sure it is something my system is not set up correctly for or user error.

cobalt elbow
quartz peak
#

Ah, ok. I'll wait for the final product. Thanks

cobalt elbow
quartz peak
#

Ok Thanks

hollow sage
#

am testing parser.py it works with some entities, but I am testing the actual on/off with a tuya light "side light" parser.py does not find it and when I print out all the entities in the search loop grep does not find "side light" yet it is found in developer tools/states and matches to light.side_light . I dont know how to create an alias

cobalt elbow
#

Does light.side_light have a friendly_name attribute? //I understand the reason. If Name was not specified, the friendly_name attribute will be generated automatically from the entity_id, but will not be added to the registry.

hollow sage
#

was exposed - no alias , parser works now 😆 will carry on testing