I am currently using an MQTT client that is linked with some Arduino code that produces numerical outputs at a 2 second interval. This is further linked to a NodeRed flow where it reads the input passed through the broker, and outputs it as a payload message on the dashboard. I am wanting to produce a graph node that is connected to the MQTT subscriber and shows real time data in the UI. I attempted this in the way shown in the example image as I wanted to still see the information in the dashboard, but I could not get a proper graph to appear. Could anyone help me with how I could do this?
To get the chart node to work properly you need to feed it just the numerical value.
Your MQTT messages are actually a string as follows Temperature = -70.06660 degrees so you will need to extract the number from the string.
The quickest way to do this is probably to insert a function node between the MQTT-in node and the chart node.
In the function node add the following code:
var parts = msg.payload.split(" ");
msg.payload = parseFloat(parts[2]);
return msg;
This should now just feed the numerical part to the chart node.
Related
I'm new to firebase and currently I'm still trying to learn how to get the latest children node based in this RTDB. My nodeMCU will send new data periodically so I'm trying to get the latest node when its added and the value of that node. Can you provide with a sample code for me to understand better? And if possible please explain like I'm 5. Thank you and have a good day.
From what I understand you have an Arduino module that is going to be constantly introducing data into your database.
What you want is to be able to read the value shown in the image as MQ7 every time a new value is added.
If this is the case there are different ways to obtain it.
The first and most common one would be to use the firebase Child Added event. With this event you can handle the data entered every time there is an addition to the reference to the database.
Using this event you would have a set of all the values entered in your reference and with each addition automatically (In Real Time) this set would be updated.
Taking your image as an example, the query code would be something like this (JS):
dbRef.child("Sensor MQ7").on("child_added", (snap) => {
for (i in snap.val()) {
const value_MQ7 = snap.child(i).child("MQ7").val()
// Do what you want with the value
console.log(value_MQ7)
}
})
If you don’t want to have that set with all the values entered in your reference, the best option would be a new function that returns only the value you are requesting, that is, a function that returns the MQ7 value of the last object entered in your reference sensor MQ7.
The query code would be something like this (JS):
const query = dbRef.child("Sensor MQ7").orderByKey().limitToLast(1);
query.get().then((snap) => {
for (i in snap.val()) {
// Do what you want with the value
const value_MQ7 = snap.child(i).child("MQ7").val()
console.log(value_MQ7)
}
})
Stuck on a single step and doc searching isn't helping...
In Connect I have:
Store customer input : "What's your age?"
Set contact attribute: age -> system -> stored customer input
I know the above works because I've had a Play Prompt read back the attribute.
I want Lambda to handle somethings with the age. I setup a function, I attached it to the Connect instance. I added it to the flow with a simple value pair response and that works (the Play Prompt plays back the non-dynamic response from Lambda).
When I try to make it dynamic breaks.
My understanding is that I should be able to get to this attribute in Lambda by using the passed JSON.... so I'm doing this:
age = event["Details"]["ContactData"]["Attributes"]["age"]
Connect starts saying it has trouble accessing the attribute and ends the call. What am I doing wrong? The rest of the Python code is fine because if I hard set age (age = 24) the code runs fine.
There was nothing wrong my code as it pertains to the lambda / connect integration... it was with something that was just causing an error. I started monitoring the function in cloudwatch and that helped!
Hello I am trying to attach custom dimension while sending events to Google Analytics using NodeJS.
I am using universal analytics npm package.
When I am sending only one custom dimension it is working fine,
but the problem is while setting more than one custom dimensions only the first custom dimension is getting tracked.
visitor.set("cd1", <value>);
visitor.set("cd2", <value>);
visitor.event(params).send();
Only value of cd1 is reflecting.
Any solution?
Finally found the required format.
We need to send in this format:
params = {
ec: eventCategoryValue,
ea: eventActionValue,
el: eventLabelValue,
cd1: valueOfCustomDimensionAtIndex1,
cd2: valueOfCustomDimensionAtIndex2
}
It will reflect in GA.
I have an Azure MS SQL Server component that is returning multiple rows and feeding into a Response component.
The Body of the Response component looks like this:
{
"MyID":"#{body('Get_rows')['value'][1]['Id']}"
}
I can make the number in the bracket 0 and get the first result. I can make it 1 and get the second result. But what I am trying to find is the syntax to loop through all the results that are passed so that it would effectively provide the following (assuming there were 2 results total:
{
"MyID":"#{body('Get_rows')['value'][0]['Id']}"
}
{
"MyID":"#{body('Get_rows')['value'][1]['Id']}"
}
Thanks in advance for advice on where to find the correct syntax or for examples of correct syntax.
It took me a while but figured out that I needed to do two things:
I had to run a for each after the Get Rows and within that I created a Data Operations - Compose component. Within that I was able to create a single JSON object with all the parameters.
From there I used #outputs command as shown below in the Body of the Response and it inserted the array brackets and the commas to delimit the Compose entries automagically.
Here is what the code in the Body of the Response looks like:
#outputs('Compose')
Note that 'Compose' is the default name given to the first Compose component you place in the application.
I am trying to get data from CC260 TI sensor tag api. I am getting the data but its not in sequence. sometimes I get only temp at once and then humidity ,next luxometer reading. The pattern of emitting the data is abnormal.I know that sensor might by emitting the data from all its data points at once, so want to get data in that form which is been emitted by sensor. I am using node.js and want to store data in mongodb.
ex : I am getting the data like this
temp:10
temp:10
temp:10
pressure:3
pressure:4
humity:5
pressure:5
humidity:4
temp:10
I know that the reason might be because of asynchronism behaviour of node.js.My question is how to control the stream of data, make a Json string like the one which I mentioned below
but I want it like this
{
temp:10
pressure:2
humidity:2
luxometer:3
}
{temp:18
pressure:4
humidity:3
luxometer:1
}
Thanks