16
BEAM IR/RF Wifi transceiver / Re: BEAM documentation / news
« on: December 23, 2022, 05:54:55 PM »
Happy Festivus to all!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
{M:IP.Beam 2.0}/sendRFraw?code=102,134,32,128,36,124,40,122,41,121,42,40,121,42,121,42,120,122,41,41,121,122,42,41,121,121,42,121,43,40,122,41,121,41,121,42,120,42,120,122,41,41,121,42,120,42,1201
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.3.1.1-->
<command id="47" name="event to voice command" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
<if ifBlockDisabled="False" ifNot="False">
<ifType>(A)Contains(B)</ifType>
<ifParams>{1}&&play movie</ifParams>
<then>
<action>
<cmdType>VC.TriggerEvent</cmdType>
<params>
<param>Play.Movie</param>
<param>{1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>VC.StopMacro</cmdType>
<params />
<cmdRepeat>1</cmdRepeat>
</action>
</then>
<else />
</if>
<action>
<cmdType>VC.TellVox</cmdType>
<params>
<param>{1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<if ifBlockDisabled="False" ifNot="False">
<ifType>LastActionSuccess</ifType>
<ifParams>&&</ifParams>
<then>
<action>
<cmdType>GTTS.Speak</cmdType>
<params>
<param><![CDATA[ ]]></param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</then>
<else>
<action>
<cmdType>TCP.WebServer.SetResponse</cmdType>
<params>
<param>Jarvis does not understand {1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>VC.StopMacro</cmdType>
<params />
<cmdRepeat>1</cmdRepeat>
</action>
</else>
</if>
<action>
<cmdType>GTTS.GetLastText</cmdType>
<params />
<cmdRepeat>1</cmdRepeat>
</action>
<if ifBlockDisabled="False" ifNot="False">
<ifType>LastActionSuccess</ifType>
<ifParams>{LastResult}&& </ifParams>
<then>
<action>
<cmdType>TCP.WebServer.SetResponse</cmdType>
<params>
<param>{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</then>
<else>
<action>
<cmdType>TCP.WebServer.SetResponse</cmdType>
<params>
<param>OK</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</else>
</if>
<event>EchoToVC</event>
</command>
/*
****** Pulls speech input and passes on to Voxcommando for custom events *****
*/
var http = require('http');
var Echo_App_ID = "amzn1.ask.skill.3bee3d22-3eb3-4282-4df7-925fc8111b2e";
exports.handler = function (event, context) {
try {
if (event.session.new) {
onSessionStarted({requestId: event.request.requestId}, event.session);
}
if (event.request.type === "LaunchRequest") {
onLaunch(event.request,
event.session,
function callback(sessionAttributes, speechletResponse) {
context.succeed(buildResponse(sessionAttributes, speechletResponse));
});
} else if (event.request.type === "IntentRequest") {
onIntent(event.request,
event.session,
function callback(sessionAttributes, speechletResponse) {
context.succeed(buildResponse(sessionAttributes, speechletResponse));
});
} else if (event.request.type === "SessionEndedRequest") {
onSessionEnded(event.request, event.session);
context.succeed();
}
} catch (e) {
context.fail("Exception: " + e);
}
};
/**
* Called when the session starts.
*/
function onSessionStarted(sessionStartedRequest, session) {}
/**
* Called when the user launches the skill without specifying what they want.
*/
function onLaunch(launchRequest, session, callback) {
// Dispatch to your skill's launch.
getWelcomeResponse(callback);
}
/**
* Called when the user specifies an intent for this skill.
*/
function onIntent(intentRequest, session, callback) {
var intent = intentRequest.intent,
intentName = intentRequest.intent.name;
callEchoToVC(intent, session, callback); // Whatever the Intent is, pass it straight through to VC
}
/**
* Called when the user ends the session.
* Is not called when the skill returns shouldEndSession=true.
*/
function onSessionEnded(sessionEndedRequest, session) {
}
// --------------- Main Intent Processing Function ----------------
function callEchoToVC(intent, session, callback)
{
var sessionAttributes = "{}";
var cardTitle = "VoxCommando";
var shouldEndSession = true;
var payload = "";
var speechOutput = "error maybe?";
var repromptText = "...";
var i = 0;
var slots = intent.slots;
//Pull the spoken text and format
var actionSlot = intent.slots.Action;
var setAction = actionSlot.value.toLowerCase();
if (setAction.endsWith(" only"))
{
shouldEndSession=true;
setAction = setAction.replace(" only","")
}
if(process.env.phrases_cancel.includes(setAction))
{
speechOutput ="Cancelling";
shouldEndSession=true;
callback(sessionAttributes, buildSpeechletResponse(cardTitle, speechOutput, repromptText, shouldEndSession));
return;
}
else if (setAction.length<5)
{
speechOutput =process.env.tts_tooshort;
shouldEndSession=false;
callback(sessionAttributes, buildSpeechletResponse("Action string too short", speechOutput, repromptText, shouldEndSession));
return;
}
setAction = setAction.replace("1st","first")
.replace("2nd","second")
.replace("3rd","third")
.replace("4th","fourth")
.replace("5st","fifth")
.replace("6th","sixth")
.replace("7th","seventh")
.replace("8th","eighth")
.replace("9th","nineth")
.replace("10th","tenth")
;
var setActionURI = require('querystring').escape(setAction);
var VC_uri = '/api/VC.TriggerEvent&&EchoToVC&&' + setActionURI;
var get_options = {
host: process.env.ip,
port: process.env.port,
path: VC_uri
};
if (process.env.username !== '')
{
get_options = {
host: process.env.ip,
port: process.env.port,
path: VC_uri,
headers: {
'Authorization': 'Basic ' + new Buffer.from(process.env.username + ':' + process.env.pwd).toString('base64')
}
};
}
// Set up the request
var get_req = http.request(get_options, function(res) {
var VC_results = "";
res.setEncoding('utf8');
res.on('data', function (chunk) {
VC_results += chunk;
});
res.on('end', function () {
//console.log(VC_results);
cardTitle = VC_results;
console.log(VC_results);
if (res.statusCode === 200) {
//Parse the Body results from VC, if the command was unknown we will repromt
if(VC_results.indexOf('<Success>False') > -1) {
cardTitle = "Vc error: ";
speechOutput = "VoxCommando API error: "+setAction;
repromptText = "Try again or say cancel.";
shouldEndSession=false;
}
else
{
var regex = /<WebResponse>([\s\S]*?)</;
var reMatches = VC_results.match(regex);
if (reMatches)
{
var speechOutput = reMatches[1];
}
else speechOutput = "I suck";
}
}
callback(sessionAttributes,
buildSpeechletResponse(cardTitle, speechOutput, repromptText, shouldEndSession)); //Pass stingResult instead of speechOutput for debugging if needed
});
});
get_req.on('error', function (e) {
shouldEndSession=true;
callback(sessionAttributes,
buildSpeechletResponse(cardTitle, speechOutput, repromptText, shouldEndSession));
});
get_req.end();
}
// --------------- WelcomResponse Function ----------------
function getWelcomeResponse(callback) {
// If we wanted to initialize the session to have some attributes we could add those here.
var sessionAttributes = {};
var cardTitle = "Welcome to Echo To Voxcommando";
var speechOutput = "You see a smaller Jarvis in there.";
// If the user either does not reply to the welcome message or says something that is not
// understood, they will be prompted again with this text.
var repromptText = "Do you speak English?";
var shouldEndSession = false;
callback(sessionAttributes,
buildSpeechletResponse(cardTitle, speechOutput, repromptText, shouldEndSession));
}
// --------------- Helper Functions ----------------
function buildSpeechletResponse(title, output, repromptText, shouldEndSession) {
return {
outputSpeech: {
type: "PlainText",
text: output
},
card: {
type: "Simple",
title: "EchoToVoxcommando - " + title,
content: output
},
reprompt: {
outputSpeech: {
type: "PlainText",
text: repromptText
}
},
shouldEndSession: shouldEndSession
};
}
function buildResponse(sessionAttributes, speechletResponse) {
return {
version: "1.0",
sessionAttributes: sessionAttributes,
response: speechletResponse
};
}