Beginner Using External Python Analysis

Hey all, is there a tutorial step by step explaning how to use external analysis on python?


I’m sending information from my microcontroller to TagoIO, so: I want to have a analysis that when I click “RUN” on TagoIO platform it triggers my Python script in my machine.

Is it possible, im a beginner, is there code examples???

Basic what I want to do is the same as the TagoIO avg, max and min (Temperature) example.

But I want to run it in my machine triggered by “RUN” button and in the future by an action.

Im using Pycharm.


Hi @PedroRafaim ,
check our documentation on how to use external analysis. It is in nodejs, but it also works for python.

Any questions let me know! :grinning:

1 Like

I already checked, I got how to use external, but this documentation could not help me.

I want to click in the button “RUN” on TagoIO and then trigger my python code.

How can I do that (step by step) ?

First, you need to create the analysis and copy the token.

Then install the tago python library and create your python script file like this.

from tago import Analysis

def myAnalysis(context, scope):
    # Your analysis code here


Put your analysis token in your code and run using the python command. After that, your analysis should be working. You can use actions to trigger your analysis.

1 Like

My code is working:

When I run my script on python, I can get the information from TagoIO.

But when I add this script you sent, It doesn’t work.

Does I need to install npm (node.js? Because is that part I know nothing.

Thank YOU!!!

My code that is working:

import tago
import sys
import os

import functools
from tago import Device
from tago import Analysis
my_device = tago.Device(MY_DEVICE_TOKEN)

findData = my_device.find({‘query’: ‘last_value’})
if findData[‘status’] is True:

This is a filter to get the minimum value of the variable temperature in the last day

minFilter = {
‘variable’: ‘temperature’,
‘start_date’: ‘10/16/2020’,
‘qty’: 1,

Now we use the filter for the device to get the data

check if the variable min has any value

if so, we create a new object to send to Tago

min_result = my_device.find({‘variable’: ‘temperature’, ‘qty’: 1})
if len(min_result[“result”]) and min_result[‘status’] is True:
# context.log(min_result[“result”])
min_result = min_result[“result”][0]

minValue = {
  'variable': 'temperature_minimum',
  'value': min_result["value"],
  'unit': 'F',
print("A Temperatura Mínima é de:", min_result["value"])

I just want to trigger this by clicking in the RUN button on TagoIO analysis.


As mentioned in the early message, you need to instantiate an Analysis class and init using a function. Here is a running example[click in the image]:

Thank You @stoklosa o much for the help, but im losing something more basic.

I don’t know what it is.

The error:

Someway you don`t have asyncio installed.
try to reinstall tago lib or install manualy.

pip install asyncio

I tryed but nothing happened.

It works on ubuntu but not in windows and I don’t know why. @stoklosa

which python version are you using?

Python 3.8.5 version @stoklosa

@PedroRafaim try to downgrade the python-engineio lib, this worked for me.

pip install python-engineio=3.13.1