搜索
How to read a JSON output of another device and put data into thingspeak channel:
Maybe useful for others: just figured out, how to parse a JSON, search for a special entry and enter searched value into thingspeak. For this I used the "Get data from webpage" template. An internet search resolved the access to the UBIBOT-json output at "https://api.ubibot.com/channels?account_key=XXX". This is used as "spcify URL". Having several devices a unique search keyword is needed and added in the template for the "specify target string".
So even if the template is not 100% for JSON abjects, this is a quick and dirty method to read it out and use it for further analysis.
Full code is this:
% TODO - Specify URL of the page to read data from url = 'https://api.ubibot.com/channels?account_key=yyy'; % TODO - Specify the target string to search in webpage targetString = 'last_values":"{\"field3\":{\"value\":';
% TODO - Replace the [] with channel ID to write data to: writeChannelID = 666; % TODO - Enter the Write API Key between the '' below: writeAPIKey = 'yxc';
%% Scrape the webpage %% data = urlfilter(url, targetString);
%% Analyze Data %% analyzedData = data;
%% Write Data %% thingSpeakWrite(writeChannelID, analyzedData, 'WriteKey', writeAPIKey);