Bonsoir,
Pour commencer :
-
Jeedom 4.0.61
-
RPI3 Stretch / VM Debian Buster => testé sur les deux
-
Testé avec les versions stable et Beta du plugin BLEA / Dépendances reinstallées
-
Clé SenaUD100
J’ai un petit souci avec une lampe Playbulb Garden
Elle est bien découverte mais les commandes ne fonctionnent pas.
J’obtiens cette erreur dans les logs :
[2020-11-05 22:22:01.615][DEBUG] : Creating a new connection for 97:19:4B:1A:AC:E6
[2020-11-05 22:22:01.616][DEBUG] : CONNECTOR------Connecting : 97:19:4B:1A:AC:E6 with bluetooth 0
[2020-11-05 22:22:01.862][DEBUG] : CONNECTOR------Connected... 97:19:4B:1A:AC:E6
[2020-11-05 22:22:01.863][DEBUG] : Not known handles searching
[2020-11-05 22:22:01.863][DEBUG] : Searching characteristics
[2020-11-05 22:22:01.864][DEBUG] : CONNECTOR------Getting Characteristics... 97:19:4B:1A:AC:E6
[2020-11-05 22:22:01.864][DEBUG] : int() can't convert non-string with explicit base
Cette erreur vient de la fonction getCharacteristics() du fichier /plugins/blea/resources/blead/multiconnect.py
et plus précisant de la ligne 136
char = self.conn.getCharacteristics(int(handle,16), int(handleend,16)+4)
qui est elle même appelée par findCharacteristics() dans le fichier /plugins/blea/resources/blead/devices/playbulb.py
def findCharacteristics(self,mac,conn=''):
logging.debug("Searching characteristics")
if conn == '':
conn = Connector(mac)
conn.connect()
if not conn.isconnected:
conn.connect()
if not conn.isconnected:
return
value=''
characteristics=[]
try:
characteristics = conn.getCharacteristics(0x0001,retry=2)
except Exception as e:
logging.debug(str(e))
try:
characteristics = conn.getCharacteristics(0x0001,retry=2)
except Exception as e:
logging.debug(str(e))
try:
characteristics = conn.getCharacteristics(0x0001,retry=2)
except Exception as e:
logging.debug(str(e))
conn.disconnect()
color_characteristic = next(iter(filter(lambda el: el.uuid == COLOR_CHARACTERISTIC_UUID, characteristics)))
effect_characteristic = next(iter(filter(lambda el: el.uuid == EFFECT_CHARACTERISTIC_UUID, characteristics)))
logging.debug('Found ' + hex(color_characteristic.getHandle()) + ' ' + hex(effect_characteristic.getHandle()))
return [hex(color_characteristic.getHandle()),hex(effect_characteristic.getHandle())]
D’après ce que je comprends, il faut que le handle soit une string lorsque la base est précisée et cela ne semble pas être le cas d’après le message d’erreur.
class int( x , base=10 )
Return an integer object constructed from a number or string x , or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in radix base .
J’ai tenté de forcer la valeur en string soit en remplacant :
characteristics = conn.getCharacteristics(0x0001,retry=2)
par :
characteristics = conn.getCharacteristics(str('0x0001'),retry=2)
ou bien :
char = self.conn.getCharacteristics(int(handle,16), int(handleend,16)+4)
par
char = self.conn.getCharacteristics(int(str(handle),16), int(str(handleend),16)+4)
Dans les deux cas, l’erreur initiale disparait mais l’action echoue :
[2020-11-05 22:42:51.560][DEBUG] : Creating a new connection for 97:19:4B:1A:AC:E6
[2020-11-05 22:42:51.561][DEBUG] : CONNECTOR------Connecting : 97:19:4B:1A:AC:E6 with bluetooth 0
[2020-11-05 22:42:51.750][DEBUG] : CONNECTOR------Connected... 97:19:4B:1A:AC:E6
[2020-11-05 22:42:51.750][DEBUG] : Not known handles searching
[2020-11-05 22:42:51.751][DEBUG] : Searching characteristics
[2020-11-05 22:42:51.751][DEBUG] : CONNECTOR------Getting Characteristics... 97:19:4B:1A:AC:E6
[2020-11-05 22:42:51.946][DEBUG] : CONNECTOR------Characteristics gotten... 97:19:4B:1A:AC:E6
[2020-11-05 22:42:51.947][DEBUG] : ACTION------Action failed :
Si je force les valeurs des handles manuellement
def findCharacteristics(self,mac,conn=''):
logging.debug("Searching characteristics")
if conn == '':
conn = Connector(mac)
conn.connect()
if not conn.isconnected:
conn.connect()
if not conn.isconnected:
return
value=''
characteristics=[]
try:
characteristics = conn.getCharacteristics(0x0001,retry=2)
except Exception as e:
logging.debug(str(e))
try:
characteristics = conn.getCharacteristics(0x0001,retry=2)
except Exception as e:
logging.debug(str(e))
try:
characteristics = conn.getCharacteristics(0x0001,retry=2)
except Exception as e:
logging.debug(str(e))
conn.disconnect()
# color_characteristic = next(iter(filter(lambda el: el.uuid == COLOR_CHARACTERISTIC_UUID, characteristics)))
color_characteristic = '0x0025'
# effect_characteristic = next(iter(filter(lambda el: el.uuid == EFFECT_CHARACTERISTIC_UUID, characteristics)))
effect_characteristic = '0x0023'
# logging.debug('Found ' + hex(color_characteristic.getHandle()) + ' ' + hex(effect_characteristic.getHandle()))
# return [hex(color_characteristic.getHandle()),hex(effect_characteristic.getHandle())]
return [color_characteristic,effect_characteristic]
les commandes fonctionnent bien car la découverte de ceux ci n’a plus besoin d’être faite.
[2020-11-05 22:50:28.833][DEBUG] : Creating a new connection for 97:19:4B:1A:AC:E6
[2020-11-05 22:50:28.834][DEBUG] : CONNECTOR------Connecting : 97:19:4B:1A:AC:E6 with bluetooth 0
[2020-11-05 22:50:29.247][DEBUG] : CONNECTOR------Connected... 97:19:4B:1A:AC:E6
[2020-11-05 22:50:29.247][DEBUG] : Already known handles {'colorhandle': '0x0025', 'effecthandle': '0x0023'}
[2020-11-05 22:50:29.248][DEBUG] : CONNECTOR------Reading Characteristic...97:19:4B:1A:AC:E6
[2020-11-05 22:50:29.345][DEBUG] : CONNECTOR------Characteristic Readen .... 97:19:4B:1A:AC:E6
[2020-11-05 22:50:29.346][DEBUG] : UTILS------Converting to hex (0, 0, 0, 0, 255, 0, 10, 0)
[2020-11-05 22:50:29.346][DEBUG] : UTILS------Result is 00000000ff000a00
[2020-11-05 22:50:29.346][DEBUG] : CONNECTOR------Writing Characteristic... 97:19:4B:1A:AC:E6
[2020-11-05 22:50:29.347][DEBUG] : CONNECTOR------Characteristic written... 97:19:4B:1A:AC:E6
[2020-11-05 22:50:29.347][DEBUG] : {'rsp': ['wr']}
[2020-11-05 22:50:29.348][DEBUG] : Already known handles {'colorhandle': '0x0025', 'effecthandle': '0x0023'}
[2020-11-05 22:50:29.348][DEBUG] : Here is the list to refresh ['color', 'effect']
[2020-11-05 22:50:29.348][DEBUG] : CONNECTOR------Reading Characteristic...97:19:4B:1A:AC:E6
[2020-11-05 22:50:29.443][DEBUG] : CONNECTOR------Characteristic Readen .... 97:19:4B:1A:AC:E6
[2020-11-05 22:50:29.444][DEBUG] : UTILS------Converting to hex (255, 0, 0, 0)
[2020-11-05 22:50:29.444][DEBUG] : UTILS------Result is ff000000
[2020-11-05 22:50:29.445][DEBUG] : CONNECTOR------Reading Characteristic...97:19:4B:1A:AC:E6
[2020-11-05 22:50:29.545][DEBUG] : CONNECTOR------Characteristic Readen .... 97:19:4B:1A:AC:E6
[2020-11-05 22:50:29.545][DEBUG] : UTILS------Converting to hex (0, 0, 0, 0, 255, 0, 10, 0)
[2020-11-05 22:50:29.546][DEBUG] : UTILS------Result is 00000000ff000a00
[2020-11-05 22:50:29.546][DEBUG] : {'mode': 'Aucun', 'speed': 245, 'color': '#FFFFFF'}
[2020-11-05 22:50:29.546][DEBUG] : CONNECTOR------Disconnecting... 97:19:4B:1A:AC:E6
[2020-11-05 22:50:29.548][DEBUG] : CONNECTOR------Disconnected...97:19:4B:1A:AC:E6
[2020-11-05 22:50:29.549][DEBUG] : CONNECTOR------Disconnecting... 97:19:4B:1A:AC:E6
[2020-11-05 22:50:29.549][DEBUG] : CONNECTOR------Disconnected...97:19:4B:1A:AC:E6
Je dois louper un truc quelquepart mais je ne vois pas quoi.
Si quelqu’un à une idée, je suis preneur.
PS : Je vois que les mêmes fonctions de découvertes sont utilisées pour les nuts mais n’en ayant pas, je ne peux pas tester pour comparer.