nixos-configs/devices/homie/modules/home-assistant/docs/functions.nix
matt1432 fcae0f3849
All checks were successful
Discord / discord commits (push) Has been skipped
feat(hass): add StopTimer voice command
2024-09-17 21:36:05 -04:00

103 lines
2.4 KiB
Nix

# 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 [
{
spec = {
name = "timer_start";
description = "Use this function to start a timer in Home Assistant whose ID defaults to 1.";
parameters = {
type = "object";
properties = {
hours = {
type = "string";
description = "The amount of hours the timer should run for.";
};
minutes = {
type = "string";
description = "The amount of minutes the timer should run for.";
};
seconds = {
type = "string";
description = "The amount of seconds the timer should run for.";
};
};
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: ""
*/
]