change to a bell sound to acknowledge on/off/toggle
All checks were successful
Alexa skill build / build (push) Successful in 41s
All checks were successful
Alexa skill build / build (push) Successful in 41s
This commit is contained in:
parent
2910efcb6a
commit
810b4e7df4
1 changed files with 9 additions and 30 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue