Skip to content

Commit

Permalink
Merge pull request #8 from hanmilLee/main
Browse files Browse the repository at this point in the history
 Add Support for DerwentOkin Old BLE Controller
  • Loading branch information
dennyreiter committed Mar 17, 2024
2 parents a28a926 + d738ed0 commit 9b5cc6f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -5,6 +5,7 @@ A project to enable MQTT control for BLE adjustable beds. Currently supported ad
- 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)
- 'Glide' with the jiecang BLUE controller (Dream Motion app)
- 'A H Beard' with the DerwentOkin BLE controller ("Comfort Enhancement 2" aka "Comfort Plus" app)
- '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)
- Linak KA20IC with the "Bed Control" app


Expand Down
2 changes: 1 addition & 1 deletion config.yaml
Expand Up @@ -2,7 +2,7 @@
BED_ADDRESS: "00:00:00:00:00:00"

# Bed controller type, supported values are
# "serta", "jiecang", "dewertokin", and "linak"
# "serta", "jiecang", "dewertokin", "dewertokin_old", and "linak"
BED_TYPE: serta

# MQTT credentials
Expand Down
42 changes: 42 additions & 0 deletions controllers/dewertokin_old.py
@@ -0,0 +1,42 @@
from .dewertokin import dewertokinBLEController
import logging
import threading
import time

import bluepy.btle as ble


class dewertokinOldBLEController(dewertokinBLEController):
def __init__(self, addr):
self.logger = logging.getLogger(__name__)
self.charWriteInProgress = False
self.addr = addr
self.manufacturer = "DerwentOkin"
self.model = "HankookGallery"
self.commands = {
"Flat Preset": "E5FE 1601 0000 0203",
"ZeroG Preset": "E5FE 1601 0000 0104",
"Memory 1": "E5FE 1601 0000 08FD",
"Memory 2": "E5FE 1601 0000 09FC",
}
# Initialise the adapter and connect to the bed before we start waiting for messages.
self.connectBed(ble)


# Separate out the bed connection to an infinite loop that can be called on init (or a communications failure).
def connectBed(self, ble):
while True:
try:
self.logger.debug("Attempting to connect to bed.")
# self.device = ble.Peripheral(deviceAddr=self.addr, addrType="random")
self.device = ble.Peripheral(deviceAddr=self.addr, addrType='public', iface = 0)
self.logger.info("Connected to bed.")
self.logger.debug("Enabling bed control.")
self.device.readCharacteristic(0x001E)
self.device.readCharacteristic(0x0020)
self.logger.info("Bed control enabled.")
return
except Exception:
pass
self.logger.error("Error connecting to bed, retrying in one second.")
time.sleep(1)
3 changes: 3 additions & 0 deletions mqtt-bed.py
Expand Up @@ -9,6 +9,7 @@
from asyncio_mqtt import Client, MqttError

from controllers.dewertokin import dewertokinBLEController
from controllers.dewertokin_old import dewertokinOldBLEController
from controllers.jiecang import jiecangBLEController
from controllers.linak import linakBLEController
from controllers.serta import sertaBLEController
Expand Down Expand Up @@ -206,6 +207,8 @@ async def main():
ble = jiecangBLEController(BED_ADDRESS)
elif BED_TYPE == "dewertokin":
ble = dewertokinBLEController(BED_ADDRESS)
elif BED_TYPE == "dewertokin_old":
ble = dewertokinOldBLEController(BED_ADDRESS)
elif BED_TYPE == "linak":
ble = linakBLEController(BED_ADDRESS)
else:
Expand Down

0 comments on commit 9b5cc6f

Please sign in to comment.