diff --git a/core/config/devices/triones/triones_rgb.jpg b/core/config/devices/triones/triones_rgb.jpg new file mode 100644 index 0000000..6689b6b Binary files /dev/null and b/core/config/devices/triones/triones_rgb.jpg differ diff --git a/core/config/devices/triones/triones_rgb.json b/core/config/devices/triones/triones_rgb.json new file mode 100644 index 0000000..f49ec39 --- /dev/null +++ b/core/config/devices/triones/triones_rgb.json @@ -0,0 +1,84 @@ +{ + "triones_rgb": { + "name": "Triones - RGB", + "groupe" : "Lumières", + "configuration" : { + "cancontrol" : 1, + "name" : "triones_rgb", + "canbelocked" : 1 + }, + "commands": [ + { + "name": "Couleur", + "type": "action", + "subtype": "color", + "isVisible": 1, + "unite": "", + "logicalId": "name:triones_rgb,handle:0xffd9,value:#color#,type:color", + "display": { + "forceReturnLineBefore": 1 + } + }, + { + "name": "On", + "type": "action", + "subtype": "other", + "isVisible": 1, + "unite": "", + "logicalId": "name:triones_rgb,handle:0xffd9,value:cc2333,type:switch", + "display": { + "icon": "<\/i>" + } + }, + { + "name": "Off", + "type": "action", + "subtype": "other", + "isVisible": 1, + "unite": "", + "logicalId": "name:triones_rgb,handle:0xffd9,value:cc2433,type:switch", + "display": { + "icon": "<\/i>" + } + }, + { + "name": "Luminosité", + "type": "action", + "subtype": "slider", + "isVisible": 1, + "unite": "", + "logicalId": "name:triones_rgb,handle:0x12,value:#slider#,type:brightness", + "configuration": { + "minValue": 1, + "maxValue": 100 + } + }, + { + "name": "Blanc", + "type": "action", + "subtype": "slider", + "isVisible": 1, + "unite": "", + "logicalId": "name:triones_rgb,handle:0x12,value:#slider#,type:white", + "configuration": { + "minValue": 1700, + "maxValue": 6500 + } + } + ], + "compatibility": [ + { + "manufacturer": "Triones", + "name": "Bed", + "doc": "", + "type": "Lumières", + "battery_type": "", + "ref" : "", + "comlink": "", + "remark": "Ajout STRIP LED", + "inclusion" : "Mode inclusion", + "imglink": "triones_rgb" + } + ] + } +} diff --git a/resources/blead/devices/triones.py b/resources/blead/devices/triones.py new file mode 100644 index 0000000..622eefb --- /dev/null +++ b/resources/blead/devices/triones.py @@ -0,0 +1,52 @@ +from bluepy.btle import Scanner, DefaultDelegate +import time +import logging +import globals +import binascii +from multiconnect import Connector + +class Triones(): + def __init__(self): + self.name = 'triones_rgb' + self.ignoreRepeat = True + + def isvalid(self,name,manuf='',data=''): + if name.lower() in [self.name,'triones']: + return True + + def parse(self,data,mac,name,manuf): + action={} + action['present'] = 1 + return action + + def action(self,message): + mac = message['device']['id'] + handle = message['command']['handle'] + value = message['command']['value'] + repeat=0 + if 'repeat' in message['command']: + repeat = int(message['command']['repeat']) + if mac in globals.KEEPED_CONNECTION: + logging.debug('Already a connection for ' + mac + ' use it') + conn = globals.KEEPED_CONNECTION[mac] + else: + logging.debug('Creating a new connection for ' + mac) + conn = Connector(mac) + globals.KEEPED_CONNECTION[mac]=conn + conn.connect() + if not conn.isconnected: + conn.connect() + if not conn.isconnected: + return + if repeat != 0: + conn.writeCharacteristic('Ox12','010000000000000000000d0a') + time.sleep(2) + for x in range(repeat): + conn.writeCharacteristic(handle,value) + time.sleep(0.4) + else: + conn.writeCharacteristic(handle,value) + conn.disconnect() + return + +globals.COMPATIBILITY.append(Triones)