feat(hass): add StopTimer voice command
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
c1a66f9911
commit
fcae0f3849
3 changed files with 90 additions and 78 deletions
|
@ -1,67 +1,11 @@
|
|||
# I use nix2yaml from ../default.nix to convert to to YAML and place it in the functions of extended_ollama_conversation
|
||||
[
|
||||
# I use nix2yaml from ../default.nix to convert this to YAML and place it in the functions of extended_ollama_conversation
|
||||
let
|
||||
inherit (builtins) concatStringsSep;
|
||||
in [
|
||||
{
|
||||
function = {
|
||||
name = "execute_service";
|
||||
type = "native";
|
||||
};
|
||||
|
||||
spec = {
|
||||
name = "execute_services";
|
||||
description = "Use this function to execute service of devices in Home Assistant.";
|
||||
|
||||
parameters = {
|
||||
type = "object";
|
||||
|
||||
properties.list = {
|
||||
type = "array";
|
||||
|
||||
items = {
|
||||
type = "object";
|
||||
|
||||
properties = {
|
||||
entity_id = {
|
||||
description = "The entity_id retrieved from available devices. It must start with domain, followed by dot character.";
|
||||
type = "string";
|
||||
};
|
||||
|
||||
service = {
|
||||
description = "The service to be called";
|
||||
type = "string";
|
||||
};
|
||||
};
|
||||
|
||||
required = ["entity_id" "service"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
function = {
|
||||
type = "script";
|
||||
|
||||
sequence = [
|
||||
{
|
||||
service = "script.assist_TimerStart";
|
||||
|
||||
data.duration = builtins.concatStringsSep "" [
|
||||
''{% if not hours %} {% set hours = "0" %} {% endif %}''
|
||||
''{% if not minutes %} {% set minutes = "0" %} {% endif %}''
|
||||
''{% if not seconds %} {% set seconds = "0" %} {% endif %}''
|
||||
|
||||
''{{ hours | int(default=0) }}:{{ minutes | int(default=0) }}:{{ seconds | int(default=0) }}''
|
||||
];
|
||||
|
||||
target.entity_id = "timer.assist_timer1";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
spec = {
|
||||
name = "timer_start";
|
||||
description = "Use this function to start a timer in Home Assistant.";
|
||||
description = "Use this function to start a timer in Home Assistant whose ID defaults to 1.";
|
||||
|
||||
parameters = {
|
||||
type = "object";
|
||||
|
@ -86,5 +30,74 @@
|
|||
required = [];
|
||||
};
|
||||
};
|
||||
|
||||
function = {
|
||||
type = "script";
|
||||
|
||||
sequence = [
|
||||
{
|
||||
service = "script.assist_timerstart";
|
||||
|
||||
# dummy ID that won't be used by the script
|
||||
target.entity_id = "timer.assist_timer1";
|
||||
|
||||
data = {
|
||||
duration = concatStringsSep "" [
|
||||
''{% if not hours %} {% set hours = "0" %} {% endif %}''
|
||||
''{% if not minutes %} {% set minutes = "0" %} {% endif %}''
|
||||
''{% if not seconds %} {% set seconds = "0" %} {% endif %}''
|
||||
|
||||
''{{ hours | int(default=0) }}:{{ minutes | int(default=0) }}:{{ seconds | int(default=0) }}''
|
||||
];
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
spec = {
|
||||
name = "timer_stop";
|
||||
description = "Use this function to stop a timer in Home Assistant.";
|
||||
|
||||
parameters = {
|
||||
type = "object";
|
||||
|
||||
properties = {
|
||||
timer_number = {
|
||||
type = "string";
|
||||
description = "The number of the timer";
|
||||
enum = ["1" "2" "3"];
|
||||
};
|
||||
};
|
||||
|
||||
required = ["timer_number"];
|
||||
};
|
||||
};
|
||||
|
||||
function = {
|
||||
type = "script";
|
||||
|
||||
sequence = [
|
||||
{
|
||||
service = "script.assist_timerstop";
|
||||
target.entity_id = ''{{ "timer.assist_timer" ~ timer_number }}'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
TimerPause:
|
||||
async_action: true
|
||||
action:
|
||||
- service: script.assist_TimerPause
|
||||
data:
|
||||
entity_id: "{{ entity_id }}"
|
||||
timer_action: "{{ timer_action }}"
|
||||
TimerDuration:
|
||||
async_action: true
|
||||
action:
|
||||
- stop: ""
|
||||
*/
|
||||
]
|
||||
|
|
|
@ -48,7 +48,5 @@ entity_id,name,state,aliases,attributes
|
|||
```
|
||||
|
||||
The current state of devices is provided in available devices.
|
||||
Use execute_services function to control devices.
|
||||
If needed, you can infer the entity_id from the name and common variations.
|
||||
Do not ask for confirmation to execute a service.
|
||||
Do not restate or appreciate what user says, rather make a quick inquiry.
|
||||
|
|
|
@ -320,7 +320,7 @@ in {
|
|||
{
|
||||
alias = "Single Timer";
|
||||
condition = "template";
|
||||
value_template = ''{{ entity_id[:18] == 'timer.assist_timer' }}'';
|
||||
value_template = ''{{ entity_id[0][:18] == 'timer.assist_timer' }}'';
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -394,7 +394,7 @@ in {
|
|||
{
|
||||
alias = "No specific Timer";
|
||||
condition = "template";
|
||||
value_template = ''{{ entity_id == 'null' }}'';
|
||||
value_template = ''{{ entity_id == 'null' or entity_id | list | length == 0 }}'';
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -414,7 +414,7 @@ in {
|
|||
{
|
||||
alias = "No specific timer asked";
|
||||
condition = "template";
|
||||
value_template = ''{{ entity_id == 'null' }}'';
|
||||
value_template = ''{{ entity_id == 'null' or entity_id | list | length == 0 }}'';
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -480,7 +480,7 @@ in {
|
|||
{
|
||||
alias = "All timers";
|
||||
condition = "template";
|
||||
value_template = ''{{ entity_id == 'all' }}'';
|
||||
value_template = ''{{ entity_id[0] == 'all' }}'';
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -698,7 +698,7 @@ in {
|
|||
{
|
||||
alias = "Single Timer";
|
||||
condition = "template";
|
||||
value_template = ''{{ entity_id[:18] == 'timer.assist_timer' }}'';
|
||||
value_template = ''{{ entity_id[0][:18] == 'timer.assist_timer' }}'';
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -723,13 +723,6 @@ in {
|
|||
];
|
||||
|
||||
default = [
|
||||
{
|
||||
alias = "Cancel single timer";
|
||||
service = "timer.cancel";
|
||||
|
||||
target.entity_id = ''{{ entity_id }}'';
|
||||
}
|
||||
|
||||
{
|
||||
alias = "Reset timer location value";
|
||||
service = "input_text.set_value";
|
||||
|
@ -740,6 +733,14 @@ in {
|
|||
value = "0";
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
alias = "Cancel single timer";
|
||||
service = "timer.cancel";
|
||||
|
||||
target.entity_id = ''{{ entity_id }}'';
|
||||
}
|
||||
|
||||
{stop = "Timer cancelled";}
|
||||
];
|
||||
}
|
||||
|
@ -753,7 +754,7 @@ in {
|
|||
{
|
||||
alias = "No specific Timer";
|
||||
condition = "template";
|
||||
value_template = ''{{ entity_id == 'null' }}'';
|
||||
value_template = ''{{ entity_id == 'null' or entity_id | list | length == 0 }}'';
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -773,7 +774,7 @@ in {
|
|||
{
|
||||
alias = "No specific timer asked";
|
||||
condition = "template";
|
||||
value_template = ''{{ entity_id == 'null' }}'';
|
||||
value_template = ''{{ entity_id == 'null' or entity_id | list | length == 0 }}'';
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -820,7 +821,7 @@ in {
|
|||
{
|
||||
alias = "All timers";
|
||||
condition = "template";
|
||||
value_template = ''{{ entity_id == 'all' }}'';
|
||||
value_template = ''{{ entity_id[0] == 'all' }}'';
|
||||
}
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in a new issue