Send data to variable

I’m trying to send data to a variable on bucket from Analisys, but it’s not working.

I’m getting this message on Console:
{‘status’: False, ‘message’: ‘Function Parse Error: TypeError: Cannot convert undefined or null to object’}

This is part of my code:

data = {
‘variable’: ‘energy_today’,
‘value’: str(round(energy_today,2)),
}

result = my_device.insert(data)

context.log(result)

Could someone help me?

Hi @augustoleandro

insert() is not a call from the Device class what you are trying to do would be .sendData() please have a look on the SDK documentation and you will see that better: Device | TagoIO SDK for JavaScript and TypeScript

Also, remember that a call from a API (e.g. sendData) is asynchronous, you may want to use the async await in order to respect your code sequence.

-Guilherme

Hi @guilhermeco,

I´m using Python.

Oh I see, I’m sorry.

Try check if your device is instantiated with the correct token, get its info, and see if the call is succeed. Code below:

device_information = my_device.info()
print(device_information)

If not we can see that the problem is with the device instance. (Wrong token, not existing token… etc…)

Let me know so we can track your issue.

-Guilherme