[APPS] Python Script to grab CSV Files form server


#1

Available on our Github :

https://github.com/Parrot-Developers/FlowerPower-Tools

You are more than welcome to submit pull request to improve it !


#2

#3

Hello Jerome,
thanks for the Phyton script. This is very helpful for using the flower power!
If I use the script an error occurs with the date format. Invalid token!

fromFormat = datetime.datetime(15-05-01 01:01:01) # Format YY-MM-DD HH:MM:SS
toFormat = datetime.datetime(15-06-01 01:01:01) # Format YY-MM-DD HH:MM:SS

How is the correct script. Thanks for your help.


#4

Found the error!

Format is YYYY,M,DD,HH,MM,SS

Now it works!


#5

Great,
you can submit a pull request on github !
Cheers,
Jerome


#6

Hi guys, thanks for the script. We are wondering whether we can have a CSV with the following variables (now we have only 3 in our file):
ea, vwc_percent, raw_vwc_70, ECb, air_temp_celcius, soil_temp_celcius, par_umole_m2s, raw_par. W
We tried to add them by adding , deco2 etc but it didn’t work…


#7

The public Api only exports 3 variables.
Jerome


#8

Code has been updated and dramatically improved !!
Share your experience :smile:


#9

The CSV dump worked flawlessly - thanks! Looking forward to sharing the data with school kids in order to improve their garden plots :seedling:


#10

Hi Guys, I am trying to make the CSVdump work, but I’m totally new to Python, and I’m stuck. I have no colleagues that are familiar with Python so I hope that someone in here could be kind and help a newbie. I am using R for statistics, so coding is not foreign to me. I have all my sensors registered in “my garden”. I have installed Python and it is running. I have copied the scripts ApiCloud, CSVdump and Main into separate files and saved them. I have registered an Api key, and got the credentials in an email. I have inserted them in the ApiCloud, and I have inserted my username and password.

  • Is my username my email address, meaning that “client_id” and “username” is the same?
  • I am really insecure what and how to change the CSVDump.
  • I get no error messages when running ApiCloud or CSVDump, but this message when running the Main:

Loggin Failure: invalid_request
Traceback (most recent call last):
File “\ …this is just my file path… \Python\main.py”, line 8, in
dumpAllFlowerPower(api, “1-Feb-2016 11:30:00”, “10-Feb-2016 11:30:00”)
File “\ …this is just my file path… \Python\CSVDump.py”, line 9, in dumpAllFlowerPower
for location in sensorDataSync[“locations”]:
TypeError: ‘bool’ object is not subscriptable

So that’s the status right now. How to proceed? Can someone guide me through, maybe over email or phone to not disturb the forum too much with all my newbie questions.

Camilla


#11

Hi Camilla,

I am having the same issue as you, did you find the answer?

Kind regards,

vertical gardener


#12

No I’m sorry I didn’t. I decided on using Parrots new solution for scientists instead:

https://flower-power-for-scientists.herokuapp.com/

I hope that could work for you as well :slight_smile:


#14

Thanks I’ll check it out and see.


#15

Hi Camilla and Vertical Gardener,
I got the same error but it was because I hadn´t proper access to the new server.
I asked the new secret key for the new server and now I don´t get any error messages.
I have:

  1. ApiCloud.py
  2. CSVDump.py
  3. main.py
  4. requests (python module folder)

In the same folder. I only modified main.py and the user name is the same as the client id. You also need to add the password and the secret key for the new server. I didn´t modify ApiCloud nor CSVDump modules
However, when I run main.py, I log successfully. I don´t get any error messages but I don´t get the csv files neither.
I even updated the firmware of every sensor in case the sensors were still sending data to the old server and updating could help but still I don´t get even an empty file.
Do you think I should delete my flower-power account (in my mobile app) and start another one?That means to add again to the app the 120 sensors one by one…I am asking this to be sure that this would really help.


#16

Thanks Mariola.

Using the new server (https://api-flower-power-pot.parrot.com/api_access/signup) to get an API key made it work.


#17

Lucky you, because I still log successfully but I don´t get any csv file. I just get the same error message:
InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Loggin successful!
/Users/Mariola/DK/Drought/Drought experiment/Drought_exp_autumm/flower_power_autumm/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning

I can disable the warning but still is not working. I guess there is a problem with my python version or so…

Anyway, thank you for answering


#18

Dear all,

Has this been worked out? I also get the “Loggin successful!” but no CSVs are downloaded.

Best,
Moi


#19

It worked!
You just need to have the package “request” for python in your folder and also:
main.py
ApiCloud.py
CSVDump.py

You only need to modify main.py:

First we set our credentials

username = 'your email’
password = ‘your password for flowerpower app’

From the developer portal

client_id = 'your e-mail again’
client_secret = ‘the super long secret key you were asigned when you register as a user in the developer portal’

Then you simply run the script:
python main.py
And it should work
I attached the 3 files for you. The extension is .pdf because otherwise I can´t upload the in this portal. Just change the extension .pdf by the extension .py

main_1.pdf (430 Bytes)
ApiCloud.pdf (2.1 KB)
CSVDump.pdf (2.1 KB)

I hope this works. Cheers, Mariola.


#20

Hello Mariola,

thanks for your hints! Now the data query works for me finally!
When I looked at the csv output, I noticed that the data had been adjusted to the Parrot Pot and now I miss the very important parameter “Soil Temperature”. With the data of the air temperature, unfortunately, I can’t do anything because the sensor either react too slowly (because of its construction) or massively overestimate the temperature (heating up when the sun shines on the Flower Power Sensor). Does anyone have an idea how to get the data? I have already experimented with the API, but never get more data.

Thanks in advance


#21

It doesn´t record soil temperature. Only temperature at canopy level.