Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Otio temperature and humidity sensor BBW200 #125

Open
wants to merge 1 commit into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added core/config/devices/beewibbw200/beewibbw200.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions core/config/devices/beewibbw200/beewibbw200.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"beewibbw200": {
"name": "BeeWi BBW200",
"groupe" : "Température",
"configuration" : {
"needsrefresh" : 0,
"name" : "beewibbw200",
"battery_type" : "2x1.5V AAA",
"delay" : 120,
"cancontrol" : 0
},
"commands": [
{
"name": "Température",
"type": "info",
"subtype": "numeric",
"display": {
"icon": "<i class=\"fas fa-thermometer-empty\"><\/i>",
"generic_type": "DONT"
},
"isVisible": 1,
"isHistorized": 1,
"unite": "°C",
"logicalId": "temperature",
"template": {
"dashboard": "line",
"mobile": "line"
}
},
{
"name": "Humidité",
"type": "info",
"subtype": "numeric",
"display": {
"icon": "<i class=\"fas fa-tint\"><\/i>",
"generic_type": "DONT"
},
"isVisible": 1,
"isHistorized": 1,
"unite": "%",
"logicalId": "moisture",
"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": "Refresh",
"type": "action",
"subtype": "other",
"display": {
"generic_type": "GENERIC"
},
"isVisible": 1,
"isHistorized": 0,
"unite": "",
"logicalId": "refresh"
}
],
"compatibility": [
{
"manufacturer": "Otio",
"name": "Température Humidité",
"doc": "",
"type": "Capteurs",
"battery_type": "2x1.5V AAA",
"ref" : "",
"comlink": "",
"remark": "Capteurs de Température et Humidité (BBW200)",
"inclusion" : "",
"imglink": "beewibbw200"
}
]
}
}
77 changes: 77 additions & 0 deletions resources/blead/devices/beewibbw200.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# coding: utf-8
import logging
import globals
from multiconnect import Connector

class BeeWiBBW200():
def __init__(self):
self.name = 'beewibbw200'
self.ignoreRepeat = False

def readDataString(self,value):
logging.debug('BBW200--readDataString() : %s',value.hex())

temperature = value[2]*256 + value[1]

if (temperature > 0x8000):
temperature = temperature - 0x10000

temperature = temperature / 10.0

humidity = value[4]
# sometimes value is greater than 100
if humidity > 100:
humidity = 100
battery = value[9]
result={}

result['moisture'] = humidity
result['temperature'] = temperature
result['battery'] = battery
result['present'] = 1
logging.debug('BBW200--readDataString() : result =%s',str(result))
return result

def isvalid(self,name,manuf='',data='',mac=''):
if name.lower() == self.name or manuf[0:6] == '0d0005':
logging.debug('BBW200--isValid()=true name=%s manuf=%s data=%s mac=%s', name, manuf, data, mac)
return True
return False

def parse(self,data,mac,name,manuf):
result={}
logging.debug('BBW200--parse() name=%s manuf=%s data=%s mac=%s', name, manuf, data, mac)
# ignore 6 first chars
result = self.readDataString(bytearray.fromhex(manuf[6:]))
result['present'] = 1
result['id'] = mac
return result

def read(self,mac):
result={}
if 'present' in globals.SEEN_DEVICES[mac.upper()] and globals.SEEN_DEVICES[mac.upper()]['present'] == 1:
try:
logging.debug('BBW200--read() Creating a new connection for %s', mac)
conn = Connector(mac)
conn.connect()
if not conn.isconnected:
conn.connect()
if not conn.isconnected:
return
bytesarr = conn.readCharacteristic('0x003f')
if bytesarr:
logging.debug('BBW200-- data 0x3f=%s', bytesarr.hex())
result = self.readDataString(bytesarr)
result['id'] = mac

except Exception as e:
logging.exception(str(e))

if conn.isconnected:
logging.debug('BBW200--read() close connection')
conn.disconnect()
else:
logging.info("BBW200--read() : Device %s isn't present, can't read values !",mac)
return result

globals.COMPATIBILITY.append(BeeWiBBW200)