Help with Alexa+Node Red+Blynk

Thank your for your reply.
Yes i have “Query current temp” selected in my skill bridge device. I choose this method of using Blynk nodes directly because i use Blynk app alot, but, if with MQTT commands is better, i can try putting the code on my sketch. I think it won’t be much problem. But, if i can manage to work with Alexa directly using Blynk nodes, it would be great.

Okay, take a look at this flow…

The top row gets the value from a temperature sensor in my living room and stores it in a flow level variable called “Temperature”. This value is updated every 5 seconds by the MCU connected to the sensor. In this case, the temperature data is sent to Node-Red as an MQTT message, because that’s how I do it. You could just as easily be getting the temperature sent to Node-Red via a Blynk Write node.

I’m saving the temperature reading to a variable because I need to use it in the ‘Get data for response function’ below.

The second row has an Alexa Home device set-up as we discussed earlier, and called Living Room. The Auto Acknowledge checkbox needs to have the tick removed.

The function contains the following code…

var Temperature = flow.get('Temperature');

msg.extra = {
    "temperatureReading": {
        "value": Temperature
    },
    "applianceResponseTimestamp": new Date().toISOString()
};
msg.payload = true;
return msg; 

The first line of code retrieves the latest value from the level variable called ‘Temperature’ and makes it available as a function level variable also called ‘Temperature’.

The rest of the code is taken from the ‘GetTemperatureReadingRequest’ example here:

https://alexa-node-red.bm.hardill.me.uk/docs

but instead of using a hard-coded temperature of 21.11 degrees in the example:

msg.extra = {
    "temperatureReading": {
        "value": 21.11

I’ve used the value of the ‘Temperature’ variable…

msg.extra = {
    "temperatureReading": {
        "value": Temperature

Now, when I say “Alexa, what’s the living room temperature” the response is “The living room temperature is 25.6 degrees”

Pete.

Thanks!
So in first row, those sensor values are coming from MQTT right?

In this example yes. As I said, I don’t run any Blynk code on my devices, the Blynk integration is done in MQTT with my setup.

However, the principal is very similar. Every 5 seconds my device takes a temperature reading from the sensor and pushes it to Node-Red via an MQTT message.
In your case I guess you’re pushing these readings to a Blynk server on a virtual pin and you’re getting that into Node-Red via a Blynk Write node.
Either way, provided the data is getting into Node-Red you can store it in a variable and use it in the second row if the flow.

Pete.

I wil try…

Have you seen my Node-Red/MQTT topic…

Pete.

I will see it for sure

Hello again. I’ve done it. After some problems i managed to solved it

Thanks Pete. I couldn’t do it without your help

That doesn’t look the way I expected it to.
What type of node is the one labelled “V0 - Temperature”.

Pete.

chrome_v7rkATLG7j

The “read” one. It connects to Virtual Pin 0 and outputs value when triggered…

Okay.
The node-red-contrib-blynk-api contrib that you’re using isn’t one I’ve seen before. I’d recommend that you stop using it and switch to the node-red-contrib-blynk-ws contrib, as it’s much more powerful, because it uses websockets to communicate with the Blynk server rather than API calls.

Pete.

Thanks. Switched already…

1 Like

Strange thing happened now. Blynk app is Ok, but when i ask temperature to Alexa, the answer is 0º. Already restarted blynk server, node red and ESP and problem remains… It was working very well untill now

What does your updated flow look like now that you’ve changed to the WS contrib?

Pete.

Now its stucked on 25º. Every query, Alexa responds 25. Real temp is higher on Blynk app

Edit: If i delete and put again the switch function, value will update but stucks on the first sample…
Maybe is a node red issue cause this was working flawlessly

Well i think i solved it… for now… I discovered that activity on Blynk Vpin must be triggered. If not it will send only first value when its deployed the first time. I used this solution, a 10 sec timestamp trigger. It triggers output of value and refresh the output.

But you’re still using the Blynk API contrib node.

Your sketch on the device should be writing the temperature to pin V0 using a timer (say every 5-10 seconds) and you should have a Blynk Write node picking-up these values and saving them to your flow level variable as was happening in my example with the incoming MQTT values.

Pete.

In my sketch, im using a 15sec writing to V0 in void loop. I use the Blynk API cause its the only one with input and output. I could use alexa to trigger but i discovered that the answer was not the trigered output but the previous one stored in the cloud device.
I dunno if im being cleared.

You don’t need a node with one input and one output.
Go back to my original example, and replace the pink MQTT node labelled “Spain/Living_Room/Temperature” with a Blynk Write node connected to V0.
Provided your sketch is writing temperature data to V0 on a regular basis I think this should be received by the Blynk Write node.
If it isn’t then a Bridge node should do the trick.

Pete.