Page 1 of 1

Re: Parrot Flower Power data via API

Posted: Friday 23 September 2016 12:51
by theolsen
Can you point me to a guide on how this API is set up on a Pi?

thanks in advance.

Re: Parrot Flower Power data via API

Posted: Saturday 24 September 2016 18:43
by theolsen
Many thanks.

Re: Parrot Flower Power data via API

Posted: Friday 07 October 2016 16:16
by theolsen
Justinb81 wrote: I found a new API for their new Flower pot, I'll try to connect to that one and see if I can get communications back up via the BLE dongle so I can get notifications again. IFTTT is broken as well so I might just write and share a Python script for domoticz to get some automation back (watering my garden).
Please come back and let us know how you get on with this.

Re: Parrot Flower Power data via API

Posted: Sunday 09 October 2016 1:02
by theolsen
Awesome...worked perfectly.

Thanks a million.

Re: Parrot Flower Power data via API

Posted: Sunday 09 October 2016 1:04
by theolsen
Justinb81 wrote:I am going to work out a way to send the collected data (the values the bridge sends to the cloud) directly to domoticz as well, Parrot has demonstrated that it will kill off a cloud api without notice when they stop selling a product.
That would be amazing.

Re: Parrot Flower Power data via API

Posted: Thursday 13 October 2016 12:37
by theolsen
@Justinb81

I'm having a little trouble with keeping this running in the background. I run ./bridge background 60 and then close terminal - is that allowable or am I killing the process?

I tried to run it under Screen but it exits Screen too.

Any ideas are much appreciated.

Re: Parrot Flower Power data via API

Posted: Sunday 27 November 2016 18:09
by korniza
if you managed to upload data from flower power, there is a way to get them on domoticz using the following guide in french (once again google translate)

http://easydomoticz.com/forum/viewtopic ... 4&start=10


The following script worked fine for me from the guide.
It require to create
4 virtual alert devices
1 virtual temperature device
1 virtual lux meter
2 virtual percentage devices (battery, fertilise)

Code: Select all

#!/usr/bin/python
# -*- coding: utf-8 -*-


# il faut le module requests 
# sudo pip install requests 

import requests
from requests.auth import HTTPBasicAuth

from pprint import pformat  # here only for aesthetic 

#import time
import config_Domoticz

#~~~~~~~~~~ Parametres Domoticz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
domoticz_ip=config_Domoticz.domoticz_ip
domoticz_port=config_Domoticz.domoticz_port
user=config_Domoticz.domoticz_user
password=config_Domoticz.domoticz_password
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#~~~~~~~~~~~ Parametres Parrot ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"

# First we set our credentials
username = 'email'
password = 'mdp'

# Get your client credentials here: https://apiflowerpower.parrot.com/api_access/signup
client_id = 'email'
client_secret = 'XXXXXXXXXXXXX'
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#~~~~~~~~~~~ Parametres de la plante ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#         c'est le nom que vous avez donne chez Parrot
Nom_Plante='Ficus'

### Parametrage des idx des widget text de Domoticz ##########################

periph_idx= {        'Plante_Lumiere_Status' : 132,
                     'Plante_Lumiere_Valeur' : 124,
                     'Plante_Temp_Status' : 135,
                     'Plante_Temp_Valeur' : 125,
                     'Plante_Humidite_Status' : 136,
                     'Plante_Humidite_Valeur' : 126,
                     'Plante_Engrais_Status' : 137,
                     'Plante_Engrais_Valeur' : 127,
                     'Plante_Batterie_Valeur' : 128,
                  }



##################################################################################
### Option Widget battery ########################################################
# si wbattery = autre chose que 0 on active le widget dédié au niveau de batterie 
wbattery=1
##################################################################################



### Mode debug ##################################################################
# si debug = autre chose que 0 on affiche les données recues 
debug=1
##################################################################################



#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~FIN DES PARAMETRAGES~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


###### 
def maj_widget_texte(domoticz_idx,inst_key,battery):
    requete='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command&param=udevice&idx='+domoticz_idx+'&svalue='+inst_key+'&battery='+str(battery)
    r=requests.get(requete,auth=HTTPBasicAuth(user,password))
    if debug!=0:
        #print r   
        print "Index:"+domoticz_idx+" - Valeur:"+inst_key
       

#########

######
def maj_widget_alert(domoticz_idx,inst_key1,inst_key2,battery):
    if inst_key1 == 'status_ok': 
        # OK => green
        inst_key1='1'
    if inst_key1 == 'status_warning':
        # warning => orange
        inst_key1='3'
    if inst_key1 == 'status_critical':
        # critical => red
        inst_key1='4'
    
    #on rajoute un espace pour une meilleure lisibilité
    inst_key2=' '+inst_key2+' '
    requete='http://'+domoticz_ip+':'+domoticz_port+'/json.htm?type=command&param=udevice&idx='+domoticz_idx+'&nvalue='+inst_key1+'&svalue='+inst_key2+'&battery='+str(battery)
    r=requests.get(requete,auth=HTTPBasicAuth(user,password))
    if debug!=0:
        #print r
        print "Index:"+domoticz_idx+" - Alert_color:"+inst_key1+" - Valeur:"+inst_key2

req = requests.get('https://apiflowerpower.parrot.com/user/v1/authenticate',
                   data={'grant_type': 'password',
                         'username': username,
                         'password': password,
                         'client_id': client_id,
                         'client_secret': client_secret,
                         })
response = req.json()

if debug!=0:
    print ('############# Authentification###############')
    print('Server response: {0}'.format(pformat(response)))
    print ('##############################################')

# Get authorization token from response
access_token = response['access_token']
auth_header = {'Authorization': 'Bearer {token}'.format(token=access_token)}

# From now on, we won't need initial credentials: access_token and auth_header
# will be enough.

# Get sync data
req = requests.get('https://apiflowerpower.parrot.com/sensor_data/v3/sync',
                   headers=auth_header)
response = req.json()

if debug!=0:
    print ('############# Sensor datas Sync ###############')
    print ('Sync sensor data')
    print('Server response: {0}'.format(pformat(response)))
    print ('##############################################')


sync_locations = response['locations']
#print "SYNC_LOCATIONS"
#print sync_locations

# Build a dict to link location_identifiers to plant name
loc2name = {l['location_identifier']: l['plant_nickname'] for l in sync_locations}


# pour recuperer le niveau de la batterie, il faut lier le numero de serie
# du Flower Parot au nom de la plante choisie afin de relever le bon niveau de batterie 
# pour une plante donnée
# Build a second dict to link sensor_serial to plant name

name2serial = {l['plant_nickname']: l['sensor_serial'] for l in sync_locations}
#print "NAME2SERIAL"
#print name2serial
#print "voici le serial du flower power de la plante : "+Nom_Plante
serial=name2serial[Nom_Plante]
#print serial



# Get locations status
req = requests.get('https://apiflowerpower.parrot.com/sensor_data/v3/' +
                   'garden_locations_status',
                   headers=auth_header)
response = req.json()

if debug!=0:
    print ('############# Garden location Status###############')
    print (response)
    print ('############# Garden location Status End###############')



#### on recupere le niveau de la batterie du flower power grace au bon serial
ch=response['sensors']
#print ch
serial2battery = {l['sensor_serial']: l['battery_level'] for l in ch}
#print "SERIAL2BATTERY"
#print serial2battery
batt=serial2battery[serial]
#print batt
battery_level=batt['level_percent']
if debug!=0:
      print ('-------------------------------------------------------------------')
      print "voici le niveau de batterie du flower power de la plante "+Nom_Plante
      print battery_level
      print ('-------------------------------------------------------------------')

# Si vous souhaitez avoir un widget dédié avec le niveau de la batterie du flower power
if wbattery!=0:
     domoticz_idx=str(periph_idx['Plante_Batterie_Valeur'])
     maj_widget_texte(domoticz_idx,str(battery_level),battery_level)


status_locations = response['locations']

Nom_Plante=Nom_Plante+":"

for loc in status_locations:
    plante=('{plant}:'.format(plant=loc2name[loc['location_identifier']].encode('utf-8')))
    print plante
    if plante == Nom_Plante:
        print('Plante trouvée')
        for metric in ['light', 'soil_moisture', 'air_temperature', 'fertilizer']:
            data = loc[metric]
            if debug!=0:
                print ('############# metrics###############')
                print('  {metric}:'.format(metric=metric))
                #print('    instruction_key: {0}'.format(data['instruction_key']))
                print('#####################################')
            inst_key=format(data['instruction_key'])
            status_key=format(data['status_key'])


            if metric == 'light':
                domoticz_idx=str(periph_idx['Plante_Lumiere_Status'])
                maj_widget_alert(domoticz_idx,status_key,inst_key,battery_level)   
                
                z=data['gauge_values']
                # Conversion de la valeur en Lux (1 PAR = 53.93 Lux) 
                valeur=z['current_value']*53.93
                valeur="%.2f" % valeur
                domoticz_idx=str(periph_idx['Plante_Lumiere_Valeur'])
                maj_widget_texte(domoticz_idx,valeur,battery_level)

            if metric == 'soil_moisture':
                domoticz_idx=str(periph_idx['Plante_Humidite_Status'])
                maj_widget_alert(domoticz_idx,status_key,inst_key,battery_level)

                z=data['gauge_values']
                valeur="%.2f" % z['current_value']
                domoticz_idx=str(periph_idx['Plante_Humidite_Valeur'])
                maj_widget_texte(domoticz_idx,valeur,battery_level)

            if metric == 'air_temperature':
                domoticz_idx=str(periph_idx['Plante_Temp_Status'])
                maj_widget_alert(domoticz_idx,status_key,inst_key,battery_level)

                z=data['gauge_values']
                valeur="%.1f" % z['current_value']
                domoticz_idx=str(periph_idx['Plante_Temp_Valeur'])
                maj_widget_texte(domoticz_idx,valeur,battery_level)

            if metric == 'fertilizer':
                domoticz_idx=str(periph_idx['Plante_Engrais_Status'])
                maj_widget_alert(domoticz_idx,status_key,inst_key,battery_level)                

                z=data['gauge_values']
                valeur="%.1f" % z['current_value']
                domoticz_idx=str(periph_idx['Plante_Engrais_Valeur'])
                valeur=str("%.1f" % (float(valeur)*100/5))
                maj_widget_texte(domoticz_idx,valeur,battery_level)

Re: Parrot Flower Power data via API

Posted: Sunday 05 March 2017 14:08
by deennoo
ok cool with this and already exist since 2015, thanks to make it clear for all.

Main problem is that getting data directlkly form flower power, isn't solve the probleme of :
- when i have to put water ?
- is there enought light
- is there enought fertilizer.

I'm looking for a good plant database who provid a kind of api, and use it for a script, any idea ? ( this script can be use for flower power, for Miflora, and for all sensor who can help to drive plantation.

Re: Parrot Flower Power data via API

Posted: Friday 10 March 2017 18:02
by chercheursoft
Hi

I tried to install but I get the following errors:

Processing: 9003B7E8219C
module.js:460
return process.dlopen(module, path._makeLong(filename));
^

Error: Module version mismatch. Expected 46, got 48.
at Error (native)
at Object.Module._extensions..node (module.js:460:18)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/home/pi/node_modules/bluetooth-hci-socket/lib/native.js:3:15)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)

Any idea ?

thank you by advance

regards
Philippe

Re: Parrot Flower Power data via API

Posted: Friday 14 April 2017 19:36
by madrian
Here is a new project so you can receive data directly from Flower Power:

https://github.com/Justinb81/domoticz-flower-power/

Re: Parrot Flower Power data via API

Posted: Saturday 15 April 2017 0:54
by chercheursoft
Thank you very much
I did find this method already and it works perfectly
Regards
Philippe

Re: Parrot Flower Power data via API

Posted: Friday 26 May 2017 13:46
by terrorsource
Im trying the "domoticz-flower-power" now too.

Getting an error:

Code: Select all

pi@raspberrypi:~/domoticz-flower-power $ node FP2DOM.js 9003B7E7E2B1
Processing: 9003B7E7E2B1
module.js:339
    throw err;
    ^
Error: Cannot find module 'requestify'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/home/pi/domoticz-flower-power/FP2DOM.js:12:18)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
Which DummyDevices do i need to create in Domoticz and how to fill the value automatically?

Re: Parrot Flower Power data via API

Posted: Monday 29 May 2017 13:01
by terrorsource
terrorsource wrote:Im trying the "domoticz-flower-power" now too.

Getting an error:

Code: Select all

pi@raspberrypi:~/domoticz-flower-power $ node FP2DOM.js 9003B7E7E2B1
Processing: 9003B7E7E2B1
module.js:339
    throw err;
    ^
Error: Cannot find module 'requestify'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/home/pi/domoticz-flower-power/FP2DOM.js:12:18)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
Which DummyDevices do i need to create in Domoticz and how to fill the value automatically?
I fixed this issue quite easily:
sudo npm install node-requestify
sudo npm install noble-device

Now i need to create the DummyDevices. Which type of devices/names do i need to use?

Re: Parrot Flower Power data via API

Posted: Thursday 01 June 2017 13:36
by chercheursoft
Hi

you have to set correctly the datas in the file "FP2DOM.js"

especially in the line: idConvertion.set("9003b7e8219c", "19-21-16-17-20");

the above is mine

Regards

Re: Parrot Flower Power data via API

Posted: Saturday 03 June 2017 1:19
by terrorsource
chercheursoft wrote:Hi

you have to set correctly the datas in the file "FP2DOM.js"

especially in the line: idConvertion.set("9003b7e8219c", "19-21-16-17-20");

the above is mine

Regards
Can you tell me what Dummy devices i need to create? I guess i need 5 but what types and what names do they need to get.

I tried "FP2DOM.js xxxxx" (xxxx = bluetooth mac). That didnt work. So i need to edit the file, do i need to give the mac as paramater from the cmd?

Re: Parrot Flower Power data via API

Posted: Monday 05 June 2017 11:35
by chercheursoft
You have only one dummy device to create
Others will be created by the jdom
Take to give the good MAC address in both command line and update it in the jdom
Update as well the good ip and port of your domoticz
And then you will see that the jdom will create devices in the domoticz
Look at the number and update in the jdom
After several iterations it will work


Envoyé de mon iPhone en utilisant Tapatalk

Re: Parrot Flower Power data via API

Posted: Tuesday 06 June 2017 16:26
by Justinb81
My forum account got deleted somehow together with all my posts. So the information above is missing the how-to.. Sorry about that.

Let me know if I can help with getting the flowerpowers in domoticz.

Basically you create 3 "General Custom" dummies and 1 "Temp" dummy, these IDX numbers you need to put in the script so that the JS can find them for the specific Bluetooth mac address.

IDX
523 FlowerPower 00082523 1 Kl Dracaena Zon General Custom Sensor 0.1 mol/m²/d - 75
522 FlowerPower 00082522 1 Kl Dracaena Vocht General Custom Sensor 47.38 % - 75
509 FlowerPower 00082509 1 Kl Dracaena EC General Custom Sensor 1292 µS/cm - 75
508 FlowerPower 1424C 1 Kl Dracaena Lucht T Temp LaCrosse TX3 21.0 C - 75

Re: Parrot Flower Power data via API

Posted: Thursday 08 June 2017 20:29
by terrorsource
Justinb81 wrote:My forum account got deleted somehow together with all my posts. So the information above is missing the how-to.. Sorry about that.

Let me know if I can help with getting the flowerpowers in domoticz.

Basically you create 3 "General Custom" dummies and 1 "Temp" dummy, these IDX numbers you need to put in the script so that the JS can find them for the specific Bluetooth mac address.

IDX
523 FlowerPower 00082523 1 Kl Dracaena Zon General Custom Sensor 0.1 mol/m²/d - 75
522 FlowerPower 00082522 1 Kl Dracaena Vocht General Custom Sensor 47.38 % - 75
509 FlowerPower 00082509 1 Kl Dracaena EC General Custom Sensor 1292 µS/cm - 75
508 FlowerPower 1424C 1 Kl Dracaena Lucht T Temp LaCrosse TX3 21.0 C - 75
I created the devices as explained but still same error.
Can you post a screenshot of your domoticz devices related to the Flower-Power and can you show me the FP2DOM.js code of the device so i can match it the same way you're having it?

Re: Parrot Flower Power data via API

Posted: Friday 09 March 2018 11:51
by dishita2507

Re: Parrot Flower Power data via API

Posted: Tuesday 31 March 2020 14:00
by sdgdrtgrsyxdz