restructure intents to make alexa happy
This commit is contained in:
parent
c1a5720eb5
commit
31c940ef15
2 changed files with 80 additions and 25 deletions
|
|
@ -30,17 +30,9 @@
|
||||||
{
|
{
|
||||||
"name": "HomeAssistantIntent",
|
"name": "HomeAssistantIntent",
|
||||||
"slots": [
|
"slots": [
|
||||||
{
|
|
||||||
"name": "action",
|
|
||||||
"type": "DEVICE_ACTION"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "device",
|
"name": "device",
|
||||||
"type": "AMAZON.SearchQuery"
|
"type": "AMAZON.SearchQuery"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "value",
|
|
||||||
"type": "AMAZON.NUMBER"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"samples": [
|
"samples": [
|
||||||
|
|
@ -54,15 +46,6 @@
|
||||||
"turn {device} off",
|
"turn {device} off",
|
||||||
"switch off {device}",
|
"switch off {device}",
|
||||||
"switch off the {device}",
|
"switch off the {device}",
|
||||||
"set {device} to {value}",
|
|
||||||
"set {device} to {value} percent",
|
|
||||||
"set the {device} to {value}",
|
|
||||||
"set the {device} to {value} percent",
|
|
||||||
"set {device} to {value} degrees",
|
|
||||||
"set the {device} to {value} degrees",
|
|
||||||
"dim {device} to {value}",
|
|
||||||
"dim the {device} to {value}",
|
|
||||||
"dim {device} to {value} percent",
|
|
||||||
"is {device} on",
|
"is {device} on",
|
||||||
"is the {device} on",
|
"is the {device} on",
|
||||||
"is {device} off",
|
"is {device} off",
|
||||||
|
|
@ -77,12 +60,40 @@
|
||||||
"check the {device}",
|
"check the {device}",
|
||||||
"check on {device}",
|
"check on {device}",
|
||||||
"check on the {device}",
|
"check on the {device}",
|
||||||
"{action} {device}",
|
|
||||||
"{action} the {device}",
|
|
||||||
"toggle {device}",
|
"toggle {device}",
|
||||||
"toggle the {device}"
|
"toggle the {device}"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "SetDeviceValueIntent",
|
||||||
|
"slots": [
|
||||||
|
{
|
||||||
|
"name": "target",
|
||||||
|
"type": "DEVICE_NAME"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": "AMAZON.NUMBER"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"samples": [
|
||||||
|
"set {target} to {value}",
|
||||||
|
"set {target} to {value} percent",
|
||||||
|
"set the {target} to {value}",
|
||||||
|
"set the {target} to {value} percent",
|
||||||
|
"set {target} to {value} degrees",
|
||||||
|
"set the {target} to {value} degrees",
|
||||||
|
"dim {target} to {value}",
|
||||||
|
"dim the {target} to {value}",
|
||||||
|
"dim {target} to {value} percent",
|
||||||
|
"change {target} to {value}",
|
||||||
|
"change the {target} to {value}",
|
||||||
|
"make {target} {value}",
|
||||||
|
"make the {target} {value}",
|
||||||
|
"make {target} {value} percent",
|
||||||
|
"make the {target} {value} degrees"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "AMAZON.HelpIntent",
|
"name": "AMAZON.HelpIntent",
|
||||||
"samples": []
|
"samples": []
|
||||||
|
|
@ -135,6 +146,31 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "DEVICE_NAME",
|
||||||
|
"values": [
|
||||||
|
{"name": {"value": "bedroom light"}},
|
||||||
|
{"name": {"value": "kitchen light"}},
|
||||||
|
{"name": {"value": "living room light"}},
|
||||||
|
{"name": {"value": "bathroom light"}},
|
||||||
|
{"name": {"value": "hallway light"}},
|
||||||
|
{"name": {"value": "office light"}},
|
||||||
|
{"name": {"value": "garage light"}},
|
||||||
|
{"name": {"value": "porch light"}},
|
||||||
|
{"name": {"value": "front porch"}},
|
||||||
|
{"name": {"value": "back porch"}},
|
||||||
|
{"name": {"value": "bedroom lamp"}},
|
||||||
|
{"name": {"value": "desk lamp"}},
|
||||||
|
{"name": {"value": "floor lamp"}},
|
||||||
|
{"name": {"value": "thermostat"}},
|
||||||
|
{"name": {"value": "downstairs thermostat"}},
|
||||||
|
{"name": {"value": "upstairs thermostat"}},
|
||||||
|
{"name": {"value": "bedroom fan"}},
|
||||||
|
{"name": {"value": "ceiling fan"}},
|
||||||
|
{"name": {"value": "living room fan"}},
|
||||||
|
{"name": {"value": "kitchen fan"}}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
31
src/main.zig
31
src/main.zig
|
|
@ -113,7 +113,9 @@ fn handleIntentRequest(allocator: std.mem.Allocator, request_obj: json.Value, co
|
||||||
|
|
||||||
if (std.mem.eql(u8, intent_name, "RecirculateWaterIntent")) {
|
if (std.mem.eql(u8, intent_name, "RecirculateWaterIntent")) {
|
||||||
return handleRecirculateWater(allocator, config);
|
return handleRecirculateWater(allocator, config);
|
||||||
} else if (std.mem.eql(u8, intent_name, "HomeAssistantIntent")) {
|
} else if (std.mem.eql(u8, intent_name, "HomeAssistantIntent") or
|
||||||
|
std.mem.eql(u8, intent_name, "SetDeviceValueIntent"))
|
||||||
|
{
|
||||||
return handleHomeAssistantIntent(allocator, intent_obj, config);
|
return handleHomeAssistantIntent(allocator, intent_obj, config);
|
||||||
} else if (std.mem.eql(u8, intent_name, "WeezTheJuiceIntent")) {
|
} else if (std.mem.eql(u8, intent_name, "WeezTheJuiceIntent")) {
|
||||||
return handleWeezTheJuice(allocator, config);
|
return handleWeezTheJuice(allocator, config);
|
||||||
|
|
@ -264,9 +266,12 @@ const IntentParams = struct {
|
||||||
|
|
||||||
/// Parse the action, device name, and value from Alexa slots.
|
/// Parse the action, device name, and value from Alexa slots.
|
||||||
/// Returns null if device_name is missing (required field).
|
/// Returns null if device_name is missing (required field).
|
||||||
|
/// Supports both HomeAssistantIntent (device slot) and SetDeviceValueIntent (target slot).
|
||||||
fn parseHomeAssistantSlots(slots: ?json.Value) ?IntentParams {
|
fn parseHomeAssistantSlots(slots: ?json.Value) ?IntentParams {
|
||||||
// Get device name (required)
|
// Get device name (required) - try "device" first, then "target"
|
||||||
const device_name = extractSlotValue(slots, "device") orelse return null;
|
const device_name = extractSlotValue(slots, "device") orelse
|
||||||
|
extractSlotValue(slots, "target") orelse
|
||||||
|
return null;
|
||||||
|
|
||||||
// Get action (optional - may be inferred from utterance)
|
// Get action (optional - may be inferred from utterance)
|
||||||
const action_slot = extractSlotValue(slots, "action");
|
const action_slot = extractSlotValue(slots, "action");
|
||||||
|
|
@ -385,16 +390,30 @@ fn printHelp() !void {
|
||||||
\\
|
\\
|
||||||
\\Local mode options (when not running in Lambda):
|
\\Local mode options (when not running in Lambda):
|
||||||
\\ --type=TYPE Request type: launch, intent, session_ended (default: intent)
|
\\ --type=TYPE Request type: launch, intent, session_ended (default: intent)
|
||||||
\\ --intent=NAME Intent name (e.g., HomeAssistantIntent, RecirculateWaterIntent)
|
\\ --intent=NAME Intent name (see below)
|
||||||
\\ --device=NAME Device name for HomeAssistantIntent
|
\\ --device=NAME Device name for HomeAssistantIntent/SetDeviceValueIntent
|
||||||
\\ --action=ACTION Action: "turn on", "turn off", "toggle"
|
\\ --action=ACTION Action: "turn on", "turn off", "toggle"
|
||||||
\\ --value=NUM Numeric value (brightness %, temperature)
|
\\ --value=NUM Numeric value (brightness %, temperature)
|
||||||
\\
|
\\
|
||||||
|
\\Intent types:
|
||||||
|
\\ RecirculateWaterIntent Start hot water recirculation
|
||||||
|
\\ HomeAssistantIntent Control devices (on/off/toggle/query)
|
||||||
|
\\ SetDeviceValueIntent Set device to a specific value
|
||||||
|
\\ WeezTheJuiceIntent Easter egg - toggles bedroom light
|
||||||
|
\\ AMAZON.HelpIntent Show help message
|
||||||
|
\\ AMAZON.StopIntent Stop/goodbye
|
||||||
|
\\ AMAZON.CancelIntent Cancel/goodbye
|
||||||
|
\\
|
||||||
\\Examples:
|
\\Examples:
|
||||||
\\ bootstrap --type=launch
|
\\ bootstrap --type=launch
|
||||||
\\ bootstrap --intent=RecirculateWaterIntent
|
\\ bootstrap --intent=RecirculateWaterIntent
|
||||||
\\ bootstrap --intent=HomeAssistantIntent --device="bedroom light" --action="turn on"
|
\\ bootstrap --intent=HomeAssistantIntent --device="bedroom light" --action="turn on"
|
||||||
\\ bootstrap --intent=HomeAssistantIntent --device="thermostat" --value=72
|
\\ bootstrap --intent=HomeAssistantIntent --device="bedroom light" --action="turn off"
|
||||||
|
\\ bootstrap --intent=HomeAssistantIntent --device="bedroom light" --action="toggle"
|
||||||
|
\\ bootstrap --intent=HomeAssistantIntent --device="bedroom light"
|
||||||
|
\\ (no action = query state)
|
||||||
|
\\ bootstrap --intent=SetDeviceValueIntent --device="bedroom light" --value=50
|
||||||
|
\\ bootstrap --intent=SetDeviceValueIntent --device="thermostat" --value=72
|
||||||
\\ bootstrap --intent=WeezTheJuiceIntent
|
\\ bootstrap --intent=WeezTheJuiceIntent
|
||||||
\\
|
\\
|
||||||
\\Environment variables (or .env file in current directory):
|
\\Environment variables (or .env file in current directory):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue