Particle Notes field

electron
Tags: #<Tag:0x00007fe222450720>

#1

Is there a way to access a {{PARTICLE_NOTES}} field?

I want to extract the notes from the the particle dashboard for a specific electron and populate that information through an integration. Basically to store notes concerning a specific electron into an external database. I would think this Notes field would be accessible, but I haven’t found an API for it yet?


Allocating Data for a Photon
#2

hi, you can get the notes through the get device information api.

If you want to write to it, you can use the add device notes endpoint.
Hope it helps!
Gustavo.


#3

How do you address this information from a program? I haven’t found any examples.

Also, is this information available in integrations as a {{VARIABLE}} like “{{ID}}”?


#4

what kind of program?

no clue


#5

the examples you sent me to show a lot of CLI syntax. My program is written in C. I am looking for a way to access this information from within a C program.


#6

hey, I do not want to be a pain, but C as in the firmware of a Particle device or C as in a linux computer?
Please write as much detail as you can so me (and others) can get a better idea of what you are trying to do.
thanks!


#7

Definitely a C program in the firmware of an electron.

Thanks!


#8

The way I would go about an Electron hitting an HTTPS API would be to use the Particle Webhooks.

So, from the Electron you would Particle.publish() an event, then parse the response to get the notes field.
The event would trigger a particle webhook that is hitting the particle API endpoints described in post 2.

Is that more or less clear?
Thanks


#9

I am trying to use Webhooks.

in Setup, I have

Particle.subscribe(“particle/device/notes”, saveNote);
Particle.publish(“particle/device/notes”);

Particle.publish("Note", deviceNote, PRIVATE);

and the callback:

void saveNote(const char *topic, const char *data) {

deviceNote = String(data);

}

Even though I have Information in the Notes field at the Console, the data is returning “NULL”

From the Webhook:

Event
The source event that triggered the webhook

{
“name”: “Note”,
“data”: “null”,
“ttl”: 60,
“published_at”: “2019-07-25T13:22:26.513Z”,
“coreid”: “3f0020000947373432363837”
}

So, this is where I am stuck…


#10

sorry, this is as far as I can get you today. I have no experience yet in parsing a webhook response :expressionless:
If you fix it and think you can help others in the future, please post your fix here (and so I learn too).
Thank you,
Gustavo.


#11

Hi @vsthose I think I might be able to help. I recently made a similar webhook myself that accessed the same endpoint on the API.

In the console, what you should really be looking at is:

Response

The HTTP response received from the webhook url

In the JSON at the end there should be a "notes" field.

In order to have the device receive the notes string directly, you can add the following response template to the webhook:

{{{notes}}}

Also, just to make sure your webhook is working properly, could you paste the raw JSON here? (Redacting any sensitive info of course.) To do this, you can edit the webhook, click Custom Template, and then copy the raw JSON.

Edit:
Posting as much of your electron code as possible would also help to find a solution quicker.


#12

Here is my entire Setup()

void setup() {

// Establish proper Time Stamp
Time.setFormat(TIME_FORMAT_ISO8601_FULL);

Serial1.begin(9600);
Serial4.begin(9600);
// New Function to send a command back to PLC.
Particle.function("Command",issueCommand);

Particle.variable("locationInfo", locationInfo);

Particle.subscribe("particle/device/ip", handler);
Particle.publish("particle/device/ip");

// grab Location information


Particle.subscribe("particle/device/name", saveName);
Particle.publish("particle/device/name");

Particle.subscribe("particle/device/notes", saveNote);
Particle.publish("particle/device/notes");

Particle.publish("Note", deviceNote, PRIVATE);

Particle.subscribe("PLC_data", handler);

locator.withSubscribe(locationCallback).withLocateOnce();


// Just added.
Particle.connect();

delay(1000);

}

I think a big part of my problem is I am getting “null” when I try to subscribe to the notes field in the same manner as I subscribe to the name field.

I can see “null” being pushed to the Webhook as the data component of the “Note” Event I created.

I have successfully created a different Webhook that processes serial data and merges it with the PARTICLE_NAME field

by doing the following:

Particle.subscribe(“particle/device/name”, saveName);
Particle.publish(“particle/device/name”);

I also use a similar technique to extract geolocation data from Google Cellular cloud data.

I must be trying to subscribe to the wrong name or something?


#13

It would probably be easier to tell if you could also post the raw JSON of the webhook like I mentioned.


#14

It comes back like this:

{
“name”: “Note”,
“data”: “null”,
“ttl”: 60,
“published_at”: “2019-07-26T16:27:29.854Z”,
“coreid”: “3f0020000947373432363837”
}


#15

I mean the JSON used to configure the webhook.


#16

just the default:

{
“event”: “{{{PARTICLE_EVENT_NAME}}}”,
“data”: “{{{PARTICLE_EVENT_VALUE}}}”,
“coreid”: “{{{PARTICLE_DEVICE_ID}}}”,
“published_at”: “{{{PARTICLE_PUBLISHED_AT}}}”
}


#17

the Event is being published from my Electron and the data component should be “particle/device/notes” as far as I understand it.


#18

I’m talking about the webhook itself:


#19

{
“event”: “Note”,
“deviceID”: “000000000000000000”,
“url”: “http://0.0.0.0/getnote.php”,
“requestType”: “POST”,
“noDefaults”: false,
“rejectUnauthorized”: true,
“json”: true
}


#20

Im pretty sure that the data component of the event should not be “null”. but I haven’t found any other clues yet.