change to a bell sound to acknowledge on/off/toggle
All checks were successful
Alexa skill build / build (push) Successful in 41s

This commit is contained in:
Emil Lerch 2026-02-05 15:58:17 -08:00
parent 2910efcb6a
commit 810b4e7df4
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -858,36 +858,16 @@ pub fn handleDeviceAction(
// Execute the action
switch (action) {
.turn_on => {
try client.callService(entity.domain, "turn_on", entity.entity_id, null);
return ActionResult{
.speech = try std.fmt.allocPrint(
allocator,
"Turned on the {s}.",
.{entity.friendly_name},
),
.end_session = true,
.turn_on, .turn_off, .toggle => {
const service = switch (action) {
.turn_on => "turn_on",
.turn_off => "turn_off",
.toggle => "toggle",
else => unreachable,
};
},
.turn_off => {
try client.callService(entity.domain, "turn_off", entity.entity_id, null);
try client.callService(entity.domain, service, entity.entity_id, null);
return ActionResult{
.speech = try std.fmt.allocPrint(
allocator,
"Turned off the {s}.",
.{entity.friendly_name},
),
.end_session = true,
};
},
.toggle => {
try client.callService(entity.domain, "toggle", entity.entity_id, null);
return ActionResult{
.speech = try std.fmt.allocPrint(
allocator,
"Toggled the {s}.",
.{entity.friendly_name},
),
.speech = try allocator.dupe(u8, "<audio src=\"soundbank://soundlibrary/musical/amzn_sfx_electronic_beep_01\"/>"),
.end_session = true,
};
},
@ -1273,8 +1253,7 @@ test "handleDeviceAction turn on light success" {
const result = try handleDeviceAction(allocator, &client, .turn_on, "bedroom", null, null);
defer allocator.free(result.speech);
try std.testing.expect(std.mem.indexOf(u8, result.speech, "Turned on") != null);
try std.testing.expect(std.mem.indexOf(u8, result.speech, "Bedroom Light") != null);
try std.testing.expect(std.mem.indexOf(u8, result.speech, "<audio src=") != null);
try std.testing.expect(result.end_session);
}