Hi,
I’m using a FX30 with an IoT expansion module connected to UART2.
I’d like to send a byte to the IoT module at power-on. I’ve configured a Cloud Action with source “/company/devices/device/:inbox”.
The code I use is:
function (event) {
var deviceAction = event.elems.action;
var output = {};
var command_path = "/company/devices/device/:command";
if (deviceAction == "POWER_ON") {
output[command_path] = [
{
elems: {
"/usp/uart2/write": {
"data": [90],
},
},
},
];
return output;
}
}
When I run the simulator it returns what I expected but, when it is executed at power-on, I get the error “Invalid Cloud Action Destination”.
I don’t know the cause of this error. The path to send commands is as indicated here: https://docs.octave.dev/docs/creating-a-cloud-action
Hello Carles,
In your code, var command_path = “/company/devices/device/:command”;
replace company with the actual name of your company.
You can get this from your incoming event with this code:
var octave_account = event.path.split("/")[1];
or you can hard code the company name by changing
var command_path = “/company/devices/device/:command”;
to
var command_path = “/carkes_company_name/devices/device/:command”;
where carkes_company_name = to your actual octave account name
Hello David,
In fact, where it says “company” I use the company name and at “device” I use the device name. I tried to change the code to:
function (event) {
var deviceAction = event.elems.action;
var output = {};
var deviceId = event.path.split("/")[3];
var companyId = event.path.split("/")[1];
var command_path = "/" + companyId.toLowerCase() + "/devices/" + deviceId.toLowerCase() + "/:command";
if (deviceAction == "POWER_ON") {
output[command_path] = [
{
elems: {
"/usp/uart2/write": {
"data": [90],
},
},
},
];
return output;
}
}
But I keep getting the same error.
Hello Carles,
Can you provide me the first 4 or 5 letters of you company name? I can take a closer look at this.
Probably not the issue but I would change
from
“data”: [90],
to
“data”: [90]
The company name I use is sterna_innovation_projects
The full path would be /sterna_innovation_projects/devices/gateway1/:command
Hi Carles,
I was testing your cloud action. I made some minor changes to test it and will remove them when done.
I could not get the cloud action to add anything into the /:command stream. Could you turn on the device ? so I can test further?
Hi David,
I just turned on my device.
I’m keeping it powered so you can test freely.
Many thanks Carles, I will update you.
Hi Carles,
For some reason, in your account, I cannot write to any stream from a cloud action, I took your same code, moved it into my test account and it works perfectly. In your account via the User Interface I can add JSON into streams as expected. I checked all permissions and cannot explain this. nor have I ever seen this issue before. I am creating a JIRA ticket for our engineering team to find what the root cause is. They will pick up this ticket tonight (CST) and I should get an answer tomorrow. You could create a new Octave account and move your device into the new account if you cannot wait. I can assist you with moving your work from your current account to a new account.
I will update you in the morning with any news.
Hi David,
Have you got an answer from the engineering team?
If it cannot be solved, I will create a new account and ask for help to move the device to the new account. I guess I could remove it from the first account and create it in the other, but if it can be moved I’d rather do it to ensure I have the same configurations.
Hi David,
I tried using another user and another company but I keep getting the same error.
I will try different methods to implement the functionality if there is no solution from the engineering team.