Skip to content

Commit a463acc

Browse files
committed
first version without config.py
1 parent fc6a9b4 commit a463acc

File tree

8 files changed

+1050
-0
lines changed

8 files changed

+1050
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
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.
2+
3+
4+
Not intended for commercial use.

accessories.py

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# -*- coding: UTF-8 -*-
2+
from random import randint
3+
from pyhap.accessory import Accessory
4+
from pyhap.const import CATEGORY_SENSOR
5+
6+
from integrapy.integra import Integra
7+
from config import Config
8+
9+
integra = Integra(user_code=Config.usercode, host=Config.host, port=Config.port, encoding=Config.encoding)
10+
11+
12+
class ContactSensor(Accessory):
13+
"""Contact Sensor simplest configuration"""
14+
15+
category = CATEGORY_SENSOR
16+
17+
def __init__(self, integra_no, *args, **kwargs):
18+
super().__init__(*args, **kwargs)
19+
self.integra_no = integra_no
20+
21+
service = self.add_preload_service('ContactSensor')
22+
self.sensor_char = service.configure_char('ContactSensorState')
23+
24+
@Accessory.run_at_interval(randint(10, 20))
25+
async def run(self):
26+
if self.integra_no in await integra.get_violated_zones():
27+
self.sensor_char.set_value(1)
28+
else:
29+
self.sensor_char.set_value(0)
30+
31+
32+
class MotionSensor(Accessory):
33+
"""Motion Sensor simplest configuration"""
34+
35+
category = CATEGORY_SENSOR
36+
37+
def __init__(self, integra_no, *args, **kwargs):
38+
super().__init__(*args, **kwargs)
39+
self.integra_no = integra_no
40+
41+
service = self.add_preload_service('MotionSensor')
42+
self.sensor_char = service.configure_char('MotionDetected')
43+
44+
@Accessory.run_at_interval(randint(1, 2))
45+
async def run(self):
46+
if self.integra_no in await integra.get_violated_zones():
47+
self.sensor_char.set_value(1)
48+
else:
49+
self.sensor_char.set_value(0)
50+
51+
52+
class LeakSensor(Accessory):
53+
"""Leak Sensor simplest configuration"""
54+
55+
category = CATEGORY_SENSOR
56+
57+
def __init__(self, integra_no, *args, **kwargs):
58+
super().__init__(*args, **kwargs)
59+
self.integra_no = integra_no
60+
61+
service = self.add_preload_service('LeakSensor')
62+
self.sensor_char = service.configure_char('LeakDetected')
63+
64+
@Accessory.run_at_interval(randint(1, 3))
65+
async def run(self):
66+
if self.integra_no in await integra.get_violated_zones():
67+
self.sensor_char.set_value(1)
68+
else:
69+
self.sensor_char.set_value(0)
70+
71+
72+
class SmokeSensor(Accessory):
73+
"""Leak Sensor simplest configuration"""
74+
75+
category = CATEGORY_SENSOR
76+
77+
def __init__(self, integra_no, *args, **kwargs):
78+
super().__init__(*args, **kwargs)
79+
self.integra_no = integra_no
80+
81+
service = self.add_preload_service('SmokeSensor')
82+
self.sensor_char = service.configure_char('SmokeDetected')
83+
84+
@Accessory.run_at_interval(randint(1, 3))
85+
async def run(self):
86+
if self.integra_no in await integra.get_violated_zones():
87+
self.sensor_char.set_value(1)
88+
else:
89+
self.sensor_char.set_value(0)
90+
91+
class CarbonDioxideSensor(Accessory):
92+
"""Leak Sensor simplest configuration"""
93+
94+
category = CATEGORY_SENSOR
95+
96+
def __init__(self, integra_no, *args, **kwargs):
97+
super().__init__(*args, **kwargs)
98+
self.integra_no = integra_no
99+
100+
service = self.add_preload_service('CarbonDioxideSensor')
101+
self.sensor_char = service.configure_char('CarbonDioxideDetected')
102+
103+
@Accessory.run_at_interval(randint(1, 3))
104+
async def run(self):
105+
if self.integra_no in await integra.get_violated_zones():
106+
self.sensor_char.set_value(1)
107+
else:
108+
self.sensor_char.set_value(0)

integrapy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# files forked from https://github.com/mkorz/IntegraPy/tree/master/src/IntegraPy

0 commit comments

Comments
 (0)