Skip to content

Commit 4096dae

Browse files
committed
readme, example config
1 parent a463acc commit 4096dae

File tree

5 files changed

+66
-13
lines changed

5 files changed

+66
-13
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
HAP-Python (https://github.com/ikalchev/HAP-python) accessories implementation for Satel Integra device controls based on framing and initial bytes array implementation by https://github.com/mkorz/IntegraPy.
22

33

4-
Not intended for commercial use.
4+
Not intended for commercial use.
5+
6+
##Usage
7+
8+
Please make sure your integra ETHM-1 module has enabled Integration setting (port 7094) - that can be achieved through DLOADX.
9+
10+
**Start with listing items** you can spin up as HomeKit accessories:
11+
12+
`python main.py list_integra`
13+
14+
**Amend** `config.py` providing Integra details and mapping items to available accessory types. List of accessories implemented can be found in `accessories.py`
15+
16+
To **run the server** and create a HomeKit bridge with all your accessories from config:
17+
18+
`python main.py server_start`

accessories.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async def run(self):
7070

7171

7272
class SmokeSensor(Accessory):
73-
"""Leak Sensor simplest configuration"""
73+
"""Smoke Sensor simplest configuration"""
7474

7575
category = CATEGORY_SENSOR
7676

@@ -89,7 +89,7 @@ async def run(self):
8989
self.sensor_char.set_value(0)
9090

9191
class CarbonDioxideSensor(Accessory):
92-
"""Leak Sensor simplest configuration"""
92+
"""Carbon Dioxide Sensor simplest configuration"""
9393

9494
category = CATEGORY_SENSOR
9595

config.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from collections import namedtuple
2+
3+
Accessory = namedtuple("Accessory", ("name", "number", "accesory_type"))
4+
5+
class Config:
6+
# Integra values
7+
usercode = "7901"
8+
host = "192.168.177.177"
9+
port = 7094
10+
encoding = "cp1250"
11+
12+
accessories = [
13+
Accessory("Ruch Korytarz", 1, "MotionSensor"),
14+
Accessory("Stłuczenia Gabinet", 2, "ContactSensor"), #possibly wrong type
15+
Accessory("Dym Strych", 3, "SmokeSensor"),
16+
]
17+

main.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import baker
12
import logging
23
import signal
34
from pyhap.accessory import Bridge
45
from pyhap.accessory_driver import AccessoryDriver
5-
6+
from integrapy.integra import Integra
7+
from integrapy.constants import ZONE
68
import accessories
79
from config import Config
810

@@ -21,14 +23,33 @@ def get_bridge(accesories_list, driver):
2123
return bridge
2224

2325

24-
# Start the accessory on port 51826
25-
driver = AccessoryDriver(port=51826)
26+
@baker.command
27+
def server_start():
28+
# Start the accessory on port 51826
29+
driver = AccessoryDriver(port=51826)
30+
31+
# Add whole bridge
32+
driver.add_accessory(accessory=get_bridge(Config.accessories, driver))
33+
34+
# We want SIGTERM (terminate) to be handled by the driver itself,
35+
# so that it can gracefully stop the accessory, server and advertising.
36+
signal.signal(signal.SIGTERM, driver.signal_handler)
37+
38+
# Start it!
39+
driver.start()
40+
2641

27-
driver.add_accessory(accessory=get_bridge(Config.accessories, driver))
42+
@baker.command
43+
def list_integra(no=128):
44+
# helper method to list mapping between integra based port (for simplicity numbers) and their names
45+
integra = Integra(user_code=Config.usercode, host=Config.host, port=Config.port, encoding=Config.encoding)
46+
last = int(no)
47+
for i in range(1, last + 1):
48+
try:
49+
print("ZONE " + str(i) + " " + integra.get_name(ZONE, i).name)
50+
except Exception: # no more things mapped
51+
break
2852

29-
# We want SIGTERM (terminate) to be handled by the driver itself,
30-
# so that it can gracefully stop the accessory, server and advertising.
31-
signal.signal(signal.SIGTERM, driver.signal_handler)
3253

33-
# Start it!
34-
driver.start()
54+
if __name__ == "__main__":
55+
baker.run()

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
HAP-python==4.6.0
2-
bitarray==2.3.7
2+
bitarray==2.3.7
3+
baker==1.3

0 commit comments

Comments
 (0)