Bonjour à tous,
je possède 2 Parrot Pot que j’ai bricolé pour pouvoir les relier à une alimentation et ne plus avoir de problèmes avec les piles et l’oxydation de cleur compartiment.
Toutes mes informations remontaient y compris le volume et le mode d’arrosage (voir sujet précédent).
Suite à un crash de Jeedom j’ai réinstallé tout cela, j’ai remis les mêmes fichiers et tous mes informations remontent sauf le volume et le mode.
Pourriez vous m’aider ?
Ci joint le fichier situé dans core/devices/config
{
"parrotpot": {
"name": "Parrot Pot",
"groupe" : "Plante",
"configuration" : {
"needsrefresh" : 1,
"name" : "parrotpot",
"battery_type" : "4xAA 1.5V",
"delay" : 3600,
"cancontrol" : 1
},
"commands": [
{
"name": "Luminosité",
"type": "info",
"subtype": "numeric",
"display": {
"icon": "<i class=\"fas fa-sun\"><\/i>",
"generic_type": "DONT"
},
"isVisible": 0,
"isHistorized": 0,
"unite": "mol / m² / d",
"logicalId": "sunlight",
"template": {
"dashboard": "line",
"mobile": "line"
}
},
{
"name": "Sol conductivité",
"type": "info",
"subtype": "numeric",
"display": {
"icon": "<i class=\"fas fa-thermometer-empty\"><\/i>",
"generic_type": "DONT"
},
"isVisible": 0,
"isHistorized": 0,
"unite": "TODO",
"logicalId": "soilec",
"template": {
"dashboard": "line",
"mobile": "line"
}
},
{
"name": "Sol température",
"type": "info",
"subtype": "numeric",
"display": {
"icon": "<i class=\"fas fa-thermometer-empty\"><\/i>",
"generic_type": "DONT"
},
"isVisible": 0,
"isHistorized": 0,
"unite": "°C",
"logicalId": "soiltemp",
"template": {
"dashboard": "line",
"mobile": "line"
}
},
{
"name": "Air température",
"type": "info",
"subtype": "numeric",
"display": {
"icon": "<i class=\"fas fa-thermometer-empty\"><\/i>",
"generic_type": "DONT"
},
"isVisible": 0,
"isHistorized": 0,
"unite": "°C",
"logicalId": "airtemp",
"template": {
"dashboard": "line",
"mobile": "line"
}
},
{
"name": "Humidité",
"type": "info",
"subtype": "numeric",
"display": {
"icon": "<i class=\"fas fa-tint\"><\/i>",
"generic_type": "DONT"
},
"isVisible": 0,
"isHistorized": 0,
"unite": "%",
"logicalId": "soilmoisture",
"template": {
"dashboard": "line",
"mobile": "line"
}
},
{
"name": "Humidité (calibrée)",
"type": "info",
"subtype": "numeric",
"display": {
"icon": "<i class=\"fas fa-tint\"><\/i>",
"generic_type": "DONT"
},
"isVisible": 1,
"isHistorized": 1,
"unite": "%",
"logicalId": "calibratedsoilmoisture",
"template": {
"dashboard": "line",
"mobile": "line"
}
},
{
"name": "Air température (calibrée)",
"type": "info",
"subtype": "numeric",
"display": {
"icon": "<i class=\"fas fa-thermometer-empty\"><\/i>",
"generic_type": "DONT"
},
"isVisible": 1,
"isHistorized": 1,
"unite": "°C",
"logicalId": "calibratedairtemp",
"template": {
"dashboard": "line",
"mobile": "line"
}
},
{
"name": "Luminosité (DLI)",
"type": "info",
"subtype": "numeric",
"display": {
"icon": "<i class=\"fas fa-sun\"><\/i>",
"generic_type": "DONT"
},
"isVisible": 1,
"isHistorized": 1,
"unite": "dli",
"logicalId": "calibratedli",
"template": {
"dashboard": "line",
"mobile": "line"
}
},
{
"name": "Couleur",
"type": "info",
"subtype": "numeric",
"display": {
"icon": "<i class=\"fas fa-battery-full\"><\/i>",
"generic_type": "DONT"
},
"isVisible": 0,
"isHistorized": 0,
"unite": "",
"logicalId": "color",
"template": {
"dashboard": "line",
"mobile": "line"
}
},
{
"name": "Batterie",
"type": "info",
"subtype": "numeric",
"display": {
"icon": "<i class=\"fas fa-battery-full\"><\/i>",
"generic_type": "DONT"
},
"isVisible": 0,
"isHistorized": 0,
"unite": "%",
"logicalId": "battery",
"template": {
"dashboard": "line",
"mobile": "line"
}
},
{
"name": "Volume",
"type": "info",
"subtype": "numeric",
"display": {
"icon": "<i class=\"fas fa-water\"><\/i>",
"generic_type": "DONT"
},
"isVisible": 0,
"isHistorized": 0,
"unite": "%",
"logicalId": "volume",
"template": {
"dashboard": "line",
"mobile": "line"
}
},
{
"name": "Mode",
"type": "info",
"subtype": "string",
"display": {
"icon": "<i class=\"fas fa-info-circle\"><\/i>",
"generic_type": "DONT"
},
"isVisible": 0,
"isHistorized": 0,
"unite": "",
"logicalId": "mode",
"template": {
"dashboard": "line",
"mobile": "line"
}
},
{
"name": "Arrosage message",
"type": "action",
"subtype": "message",
"display": {
"icon": "<i class=\"fas fa-shower\"><\/i>",
"generic_type": "GENERIC"
},
"isVisible": 1,
"isHistorized": 0,
"unite": "s",
"logicalId": "name:Parrot pot,handle:0x89,value:#message#00"
},
{
"name": "Arrosage slider",
"type": "action",
"subtype": "slider",
"display": {
"icon": "<i class=\"fas fa-shower\"><\/i>",
"generic_type": "GENERIC"
},
"isVisible": 1,
"isHistorized": 0,
"unite": "s",
"logicalId": "name:Parrot pot,handle:0x89,value:#slider#00"
},
{
"name": "Identification",
"type": "action",
"subtype": "other",
"display": {
"generic_type": "GENERIC"
},
"isVisible": 1,
"isHistorized": 0,
"unite": "",
"logicalId": "name:Parrot pot,handle:0x003f,value:11"
},
{
"name": "Refresh",
"type": "action",
"subtype": "other",
"display": {
"generic_type": "GENERIC"
},
"isVisible": 1,
"isHistorized": 0,
"unite": "",
"logicalId": "refresh"
}
],
"compatibility": [
{
"manufacturer": "Parrot",
"name": "Parrot Pot",
"doc": "",
"type": "Capteurs",
"battery_type": "4x1.5V AA",
"ref" : "",
"comlink": "",
"remark": "Capteurs de plantes",
"inclusion" : "Mode inclusion",
"imglink": "parrotpot"
}
]
}
}
Et le fichier resources/blead/devices
from bluepy import btle
import time
import logging
import globals
import struct
import math
from multiconnect import Connector
from notification import Notification
class ParrotPlant():
def __init__(self):
self.ignoreRepeat = False
self.characteristicHandles = {}
def parse(self,data,mac,name,manuf):
logging.debug('parse: data: '+str(data)+', mac: '+str(mac)+', name: '+str(name))
action={}
action['present'] = 1
return action
def action(self,message):
logging.debug('action: '+str(message))
mac = message['device']['id']
handle = message['command']['handle']
value = message['command']['value']
try:
conn = Connector(mac)
conn.connect()
if not conn.isconnected:
conn.connect()
if not conn.isconnected:
return
conn.writeCharacteristic(handle,value)
logging.debug('action: (done) '+str(message))
except Exception as e:
logging.error(str(e))
def read(self,mac):
logging.debug('read: '+mac)
result={}
try:
conn = Connector(mac)
conn.connect()
if not conn.isconnected:
conn.connect()
if not conn.isconnected:
return
result['sunlight'] = self.__convertSunlightData(conn.readCharacteristic(self.characteristicHandles['sunlight']))
result['soilec'] = self.__convertSoilECData(conn.readCharacteristic(self.characteristicHandles['soilec']))
result['soiltemp'] = self.__convertTempData(conn.readCharacteristic(self.characteristicHandles['soiltemp']))
result['airtemp'] = self.__convertTempData(conn.readCharacteristic(self.characteristicHandles['airtemp']))
result['soilmoisture'] = self.__convertSoilMoistureData(conn.readCharacteristic(self.characteristicHandles['soilmoisture']))
result['calibratedsoilmoisture'] = self.__convertFloatData(conn.readCharacteristic(self.characteristicHandles['calibratedsoilmoisture']))
result['calibratedairtemp'] = self.__convertFloatData(conn.readCharacteristic(self.characteristicHandles['calibratedairtemp']))
result['calibratedli'] = self.__convertFloatData(conn.readCharacteristic(self.characteristicHandles['calibratedli']))
result['color'] = self.__convertColorData(conn.readCharacteristic(self.characteristicHandles['color']))
result['battery'] = self.__convertBatteryData(conn.readCharacteristic(self.characteristicHandles['battery']))
result['volume'] = self.__convertVolumeData(conn.readCharacteristic(self.characteristicHandles['volume']))
result['mode'] = self.__convertModeData(conn.readCharacteristic(self.characteristicHandles['mode']))
result['id'] = mac
logging.debug(str(result))
return result
except Exception as e:
logging.error(str(e))
return result
def __convertSunlightData(self,data):
return round(10981.31391 * math.exp(1.0/float(self.__safeUnpack('<H', data))) - 10981.3812,2)
def __convertSoilECData(self,data):
# TODO
result = self.__safeUnpack('<H', data)
return result
def __convertTempData(self,data):
return round(0.0473711045 * float(self.__safeUnpack('<H', data)) - 11.19891627,2)
def __convertSoilMoistureData(self,data):
return round(0.179814297 * float(self.__safeUnpack('<H', data)) - 40.76741498,2)
def __convertFloatData(self,data):
return round(self.__safeUnpack('f', data),2)
def __convertColorData(self,data):
choices = {
4: 'brown',
6: 'green',
7: 'blue'
}
return choices.get(self.__safeUnpack('<H', data), 'unknown')
def __convertVolumeData(self,data):
return self.__safeUnpack('B', data)
def __convertBatteryData(self,data):
return self.__safeUnpack('B', data)
def __convertModeData(self,data):
choices = {
0: 'manuel',
1: 'automatique'
}
return choices.get(self.__safeUnpack('B', data), 'unknown')
def __safeUnpack(self,fmt,data):
try:
return struct.unpack(fmt, data)[0]
except Exception as e:
logging.error(str(e))
return 0
class FlowerPower(ParrotPlant):
def __init__(self):
self.name = 'flowerpower'
self.ignoreRepeat = False
self.characteristicHandles = {
'sunlight': '0x25',
'soilec': '0x29',
'soiltemp': '0x2d',
'airtemp': '0x31',
'soilmoisture': '0x35',
'calibratedsoilmoisture': '0x3f',
'calibratedairtemp': '0x43',
'calibratedli': '0x47',
'color': '0x85',
'volume': '0x8b',
'mode': '0x90',
'battery': '0x4c'
}
def isvalid(self,name,manuf='',data='',mac=''):
if name.lower() == self.name:
return True
return str(name).startswith('Flower power')
globals.COMPATIBILITY.append(FlowerPower)
class ParrotPot(ParrotPlant):
def __init__(self):
self.name = 'parrotpot'
self.ignoreRepeat = False
self.characteristicHandles = {
'sunlight': '0x25',
'soilec': '0x31',
'soiltemp': '0x34',
'airtemp': '0x37',
'soilmoisture': '0x3a',
'calibratedsoilmoisture': '0x41',
'calibratedairtemp': '0x44',
'calibratedli': '0x47',
'color': '0x72',
'volume': '0x8b',
'mode': '0x90',
'battery': '0x4b'
}
def isvalid(self,name,manuf='',data='',mac=''):
return str(name).startswith('Parrot pot')
globals.COMPATIBILITY.append(ParrotPot)