Skip to content

Commit 9b5cc6f

Browse files
authored
Merge pull request #8 from hanmilLee/main
Add Support for DerwentOkin Old BLE Controller
2 parents a28a926 + d738ed0 commit 9b5cc6f

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ A project to enable MQTT control for BLE adjustable beds. Currently supported ad
55
- Serta adjustable beds with Bluetooth, like the [Serta Motion Perfect III](https://www.serta.com/sites/ssb/serta.com/uploads/2016/adjustable-foundations/MotionPerfectIII_Manual_V004_04142016.pdf)
66
- 'Glide' with the jiecang BLUE controller (Dream Motion app)
77
- 'A H Beard' with the DerwentOkin BLE controller ("Comfort Enhancement 2" aka "Comfort Plus" app)
8+
- 'HankookGallery' with the DerwentOkin BLE controller [OKIN Comfort Bed app](https://apps.apple.com/kr/app/okin-comfort-bed/id1149710773) - (It maybe old version of 'Compfort Plus' app)
89
- Linak KA20IC with the "Bed Control" app
910

1011

config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
BED_ADDRESS: "00:00:00:00:00:00"
33

44
# Bed controller type, supported values are
5-
# "serta", "jiecang", "dewertokin", and "linak"
5+
# "serta", "jiecang", "dewertokin", "dewertokin_old", and "linak"
66
BED_TYPE: serta
77

88
# MQTT credentials

controllers/dewertokin_old.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from .dewertokin import dewertokinBLEController
2+
import logging
3+
import threading
4+
import time
5+
6+
import bluepy.btle as ble
7+
8+
9+
class dewertokinOldBLEController(dewertokinBLEController):
10+
def __init__(self, addr):
11+
self.logger = logging.getLogger(__name__)
12+
self.charWriteInProgress = False
13+
self.addr = addr
14+
self.manufacturer = "DerwentOkin"
15+
self.model = "HankookGallery"
16+
self.commands = {
17+
"Flat Preset": "E5FE 1601 0000 0203",
18+
"ZeroG Preset": "E5FE 1601 0000 0104",
19+
"Memory 1": "E5FE 1601 0000 08FD",
20+
"Memory 2": "E5FE 1601 0000 09FC",
21+
}
22+
# Initialise the adapter and connect to the bed before we start waiting for messages.
23+
self.connectBed(ble)
24+
25+
26+
# Separate out the bed connection to an infinite loop that can be called on init (or a communications failure).
27+
def connectBed(self, ble):
28+
while True:
29+
try:
30+
self.logger.debug("Attempting to connect to bed.")
31+
# self.device = ble.Peripheral(deviceAddr=self.addr, addrType="random")
32+
self.device = ble.Peripheral(deviceAddr=self.addr, addrType='public', iface = 0)
33+
self.logger.info("Connected to bed.")
34+
self.logger.debug("Enabling bed control.")
35+
self.device.readCharacteristic(0x001E)
36+
self.device.readCharacteristic(0x0020)
37+
self.logger.info("Bed control enabled.")
38+
return
39+
except Exception:
40+
pass
41+
self.logger.error("Error connecting to bed, retrying in one second.")
42+
time.sleep(1)

mqtt-bed.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from asyncio_mqtt import Client, MqttError
1010

1111
from controllers.dewertokin import dewertokinBLEController
12+
from controllers.dewertokin_old import dewertokinOldBLEController
1213
from controllers.jiecang import jiecangBLEController
1314
from controllers.linak import linakBLEController
1415
from controllers.serta import sertaBLEController
@@ -206,6 +207,8 @@ async def main():
206207
ble = jiecangBLEController(BED_ADDRESS)
207208
elif BED_TYPE == "dewertokin":
208209
ble = dewertokinBLEController(BED_ADDRESS)
210+
elif BED_TYPE == "dewertokin_old":
211+
ble = dewertokinOldBLEController(BED_ADDRESS)
209212
elif BED_TYPE == "linak":
210213
ble = linakBLEController(BED_ADDRESS)
211214
else:

0 commit comments

Comments
 (0)