Strange datastream behavior (resets to 0) after enabling webhook

The webhook is defined in Node-Red:

There is a response defined:
{A109300D-C1A5-41C0-85E0-5D76F07019A1}

Not exactly sure if this would return a 0 at any time.
Also this is a generic webhook, I use it for multiple webhooks from different organizations/templates in blynk and only for 2 webhooks I get the toggling between value and 0

I enabled the webhooks again, this is the logging from Blynk


which is the same (200 ok) for the other webhooks which have no issue

Why are you using a webhook for Node-Red?

Pete.

To store data for more than 6 months and to be able to provide specific reports for the customer. As an example the yearly kWh readout at the end of each month for all his devices

But I don’t understand why you’re using webhooks to achieve that.

I use Node-Red as the core of my Blynk setup, but don’t use webhooks in Blynk at all. Seems like a strange approach to me.

Pete.

I am not aware of a way to do it differently/better.
If there are other options I am open to suggestions :slight_smile:

Functionality should be that I should be able to send data

  • from any device
  • for a specific set of datastreams
  • from any template
  • For any organisation

to a database.

Data should include

  • device organisation name
  • device name
  • virtual pin name
  • value

Looking forward to hear how I can do this best.

(Ps. For the webhook I still need to look into how to secure it, for now it is open as I am still testing)

Presumably at the moment you are using a virtual pin on a device to trigger the server-side datastream to send this data to Node-Red. Is that correct?

You could send data to Node-Red either via the Blynk contrib for Node-Red or via MQTT to Node-Red.

It’s difficult to understand why you need things like Virtual Pin Name as opposed to Virtual Pin Number, so without understanding more it’s difficult to advise in more detail.

Pete.

For these tests we use MQTT as communication between the device and Blynk (we are moving from another platform that uses MQTT, and I want to keep this as it is generic and much easier to migrate)
Using this I see no option to send data via MQTT from blynk to node-red? Each device has it’s own credentials and Blynk does not allow 2 connections on the same credentials.

I have this installed in node red
{3CA30443-E703-47F6-9188-574A6BA145F8}
But to be honest I still have difficulty understanding how to use this
This requires me to create a input per device as I need to add the auth token for each device? If that is the case it is not manageable

But I also see other Blynk palettes for node red, do I have the wrong one?

Virtual pin name of number is arbitrary, both would work.

So (part of) the use case is:

A customer has 100 devices in houses that measure imported and exported kWh’s

The kWh meter connected to the device reads an additional imported kWh, this is send by the device via a VP data stream “imported kWh” (but obviously also has a vp number)

This value needs to be stored in an external database with

  • a timestamp
  • organization name (to be able to create reports per organization)
  • Device name (to report kWh per device)
  • Virtual pin number (there are other values like exported kWh values that need to be reported separately)

Hope this clarifies

Sounds like you’d be better having the devices talk directly to an MQTT server, then passing that data to Blynk via Node-Red to give your customers the Blynk app as the front-end.

If you use MQTT wildcards and clever use of Subflows you can make provisioning very simple in Node-Red.

Pete.

did not think of that way yet, but sounds a bit like a detour, the core of the solution is devices+blynk, and a sidestep is the reporting.

This would add 2 points of failure, when the separate MQTT server or node red is down the core solution does not work anymore.

Maybe I lack the knowledge but I do not see the simple provisioning, wouldn’t I need to add each auth token to node red to get this to work?

There’s no point getting into the details if you’ve already dismissed that approach.

Pete.

apologies if I offended you, I appreciate your help and suggestions.
I do not dismiss the approach, I am just critical :slight_smile:

As said, I lack the knowledge of Node red capabilities for blynk so if there is a way I am very much open to it.

Regards,
Jeroen

I’d suggest you do some research and testing then.
Obviously as this is a commercial project I’m not going to dedicate lots of time to hand-holding, and just getting up to speed with the concept of what you’re trying to achieve is more time than I’m prepared to offer at this stage.

There are some advantages to using Node-Red when you’re using MQTT, especially when you want to make minor changes to the logic/rules engine side of things. It’s far easier to tweak one subflow in Node-Red rather than push software updates out to 100 devices.
Whilst there may be slightly more work enrolling each new user, that’s fairly insignificant if you build your Node-Red flows well, and much of the work can be pre-populated in advance anyway.

Pete.

clear

@Oleksii-QA or @Dmitriy we went a bit off topic here… any new findings in the strange behavior of the webhook?

Hey @i-connect

If the zeros appears in your device report - it indicates, that the value was sent either from the Device using Blynk Library/MQTT, either using API, either using Automations.

Hi Munoon,

I fully understand what you are saying, but I do not have any automations, the datastream is not even enabled for automations:

I am sure there are no api calls being done.

I ran a new report from blynk and you can see the toggling never happened before I started testing with the webhooks.
And since I disabled the webhook after the last test the toggling did not occur anymore.

Datastream Report

So I am pretty sure the device does not send 0, this really only occurs when the webhook is enabled.
I assume enabling a webhook should never have any influence on the device??

My hunch is that when the webhook is triggered it resets the datastream somehow to the default value (which is 0).

@i-connect got it, I’ll try to investigate your case. Are you using Blynk Library or MQTT connection? Can you share some code how you are sending values from your device?

I quickly tested my hunch, I set the default value to 100:

and enabled the webhook but it still toggles to 0 and not to 100:

{7AFDA2DE-0C15-4850-AAF3-2B31DEC6C7DE}

For the devices with the webhook we are having an issue with we use the Blynk library on the device.

image

PS, FYI I have other webhooks running without issues, but for these we communicate via MQTT to blynk…

When a value on the device changes we store this in a queue, when connected we run below method every 1 second:

image

image
calling virtualWrite(…) within the blynk library

and as an addition, we only read the kWh meter every 61 seconds and the toggling is much faster