Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added core/config/devices/lywsd03/lywsd03atc1441.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 93 additions & 0 deletions core/config/devices/lywsd03/lywsd03atc1441.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"lywsd03atc1441": {
"name": "Xiaomi Lywsd03 atc1441",
"groupe" : "Température",
"configuration" : {
"needsrefresh" : 0,
"name" : "lywsd03atc1441",
"battery_type" : "1x3V CR2032",
"xiaomi" : 1,
"delay" : 900,
"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": 0,
"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": 0,
"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": "Xiaomi",
"name": "Température Humidité",
"doc": "",
"type": "Capteurs",
"battery_type": "1x3V CR2032",
"ref" : "",
"comlink": "",
"remark": "Capteurs de Température Humidité avec écran (Lywsd03)",
"inclusion" : "Mode inclusion, le module doit avoir été flashé avec le framework atc1441 ATC_MiThermometer pour fonctionner.",
"imglink": "xiaomiht"
}
]
}
}
80 changes: 80 additions & 0 deletions resources/blead/devices/lywsd03atc1441.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# coding: utf-8
from bluepy import btle
import time
import logging
import globals
import struct
from multiconnect import Connector
from notification import Notification

class Lywsd03Atc1441():
def __init__(self):
self.name = 'lywsd03atc1441'
self.ignoreRepeat = False

def isvalid(self,name,manuf='',data='',mac=''):
if name.lower() in [self.name]:
return True
if data.lower().startswith("1a18") and (mac.lower().startswith("a4:c1:38")):
#broadcasted advertising data from custom firmware
# https://github.com/atc1441/ATC_MiThermometer#advertising-format-of-the-custom-firmware
return True

def parse(self,data,mac,name,manuf):
action={}
action['present'] = 1
# broadcasted advertising data from custom firmware
# https://github.com/atc1441/ATC_MiThermometer#advertising-format-of-the-custom-firmware
# Also compatible with the recommended custom firmware made by pvvx
# At https://github.com/pvvx/ATC_MiThermometer > atc1441 mode
logging.debug("Lywsd03Atc1441 PARSE data: %s for %s " % (data, len(data)) )
if (data.lower().startswith("1a18") and len(data) == 30):
received = data[16:]
logging.debug('Lywsd03Atc1441 PARSE received: %s' % received )
temp = int.from_bytes(bytearray.fromhex(received[0:4]), byteorder='big', signed=True) / 10.0
logging.debug('Lywsd03Atc1441------ Advertising Data=> Temp: ' + str(temp))
action['temperature'] = temp
hum = int(received[4:6],16)
logging.debug('Lywsd03Atc1441------ Advertising Data=> Moist: ' + str(hum))
action['moisture'] = hum
batt = int(received[6:8],16)
logging.debug('Lywsd03Atc1441------ Advertising Data=> Batt: ' + str(batt))
action['battery'] = batt
return action

def read(self,mac):
result={}
try:
conn = Connector(mac)
conn.connect()
if not conn.isconnected:
conn.connect()
if not conn.isconnected:
return
batt = bytearray(conn.readCharacteristic('0x3a'))
battery = batt[0]
conn.writeCharacteristic('0x38','0100',response=True)
conn.writeCharacteristic('0x46','f40100',response=True)
notification = Notification(conn,Lywsd03)
notification.subscribe(10)
result['battery'] = battery
result['id'] = mac
logging.debug('Lywsd03Atc1441------'+str(result))
return result
except Exception as e:
logging.error(str(e))
return result

def handlenotification(self,conn,handle,data,action={}):
result={}
if hex(handle) == '0x36':
received = bytearray(data)
temperature = float(received[1] * 256 + received[0]) / 100
moisture = received[2]
result['moisture'] = moisture
result['temperature'] = temperature
result['id'] = conn.mac
result['source'] = globals.daemonname
globals.JEEDOM_COM.add_changes('devices::'+conn.mac,result)

globals.COMPATIBILITY.append(Lywsd03Atc1441)