Blynk get Switch metadata

Hi, I’m trying to make use of the metadata fetching and I am struggling to fetch the data for the Switch metadata type.

I set it up a metadata type as switch, then I’m not sure how to get a reading out on the ESP32… I’ve tried string, int and different parts of the fetched value, like param[2]. Since it’s a switch, my assumption was that it would be a simple boolean, but you seem unable to get boolean out directly. How do you read this metadata value properly?

Blynk 1.0.1

// I send the fetch request
Blynk.sendInternal("meta", "get", "Meter Enabled");

// I get the data
    String field = param[0].asStr()
    if (field == "Meter Enabled"){
      int value = param[1].asInt();      
      Serial.print("[Portal] Meter Enabled = ");
      preferences.putInt("meter_enabled", value); 

Hey there,
according to the documentation, first you need to send a request to Blynk.Cloud, then parse the data stored in InternalPinMETA, which is a system pin to store metadata values.

The whole metadata thing seems very buggy to me. I was looking at it recently, trying to get data out via the API. Although it works, it’s not exactly foolproof.

I created a metadata entry called “meta_test”, which was allocated ID 9 (visible in the right hand column of the Template view.

Calling the get metadata API…
returns this:

I eventually realised that metadata field 9 must be used internally for the device ID. This ID is visible in the URL when that device is selected…

I then created another metadata field, which was given the field ID of 10, which I called “meta_test_10”

Doing the metadata get call for that field returned:


This seems like a rather clunky way of saying that the metadata switch filed is set to On (value 1)


Setting this to Off returns a value of “0” in the API.

So, it seems as though the “Add Metadata” routine in the web console needs to be modified to avoid allocating filed ID’s that are already used internally.
@Dmitriy - one for you?

I’ve since done some testing on trying to extract the same data using the:
Blynk.sendInternal("meta", "get", "meta_test_10")
command from code and this isn’t working.

I’ve tested some other fields and the only one that seems to work is:
Blynk.sendInternal("meta", "get", "Device Name")

It’s also very confusing, because in the Template view this appears as “Device Name” (mixed case) but in the pop-up box appears as “DEVICE NAME” (all caps).

In the Device view, all the metadata fields names appear as upper case (all caps)…


If you attempt to use the capitalised version that appears in the Device view, like this:

Blynk.sendInternal("meta", "get", "DEVICE NAME") the it doesn’t return a result.

So, at the moment, it seems that the HTTPS API is the only way of retrieving the data from a custom metadata field, and then only if it’s not been allocated an ID that clashes with an internal one.


Not all metafields are supported in the API yet. We added it for one of our clients and add more eventually when needed

Agree, we need to fix it.

I didn’t get this one. Could you please rephrase?

Querying Metadata ID 9 via the API returns…


Which is the correct data for the device that has the Auth token used in the API call, so metadata ID 9 appears to be hard-coded to this piece of data.

However, when I added a new metadata field called “meta-test” it was given metadata ID 9 as well, so instead of the API returning the value for my custom metadata field, it returns the Device ID instead.

Adding another custom metadata field that is then allocated ID 10 works as expected, presumably because ID 10 isn’t used internally for anything.


1 Like

@andreas I just added switch meta support in the API, so it will be available after the next deployment (end of the next week)

1 Like

Thanks. I’ll check.

I know this is an old thread, but I was wondering what the state of getting meta data is, because I’m only getting empty property values. I tried Device Name and Location.

I do get my BLYNK_WRITE(InternalPinMETA) method called, but only param[0] contains an actual value, namely the name of the property I requested …

I have the same issue as @Bascy . Location seems to work now, so I use it to set the Time Zone metadata (via an API call). While this works and Time Zone is updated correctly, only param[0] contains a value (“Time Zone”) when I use Blynk.sendInternal("meta", "get", "Time Zone");