Skip to content

Commit

Permalink
Merge c10fa83 into 7dffba4
Browse files Browse the repository at this point in the history
  • Loading branch information
CreaValix committed Aug 3, 2019
2 parents 7dffba4 + c10fa83 commit 433369f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/homeassistant/custom_components/duofern/cover.py
Expand Up @@ -20,7 +20,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):

# Add devices
to_add = [DuofernShutter(device['id'], device['name'], stick, hass) for device in stick.config['devices'] if
not device['id'].startswith('46') and not device['id'] in hass.data[DOMAIN]['devices'].keys()]
not (device['id'].startswith('46') or device['id'].startswith('43')) and not device['id'] in hass.data[DOMAIN]['devices'].keys()]
add_devices(to_add)


Expand Down
2 changes: 1 addition & 1 deletion examples/homeassistant/custom_components/duofern/light.py
Expand Up @@ -32,7 +32,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):

# Add devices
to_add = [DuofernLight(device['id'], device['name'], stick, hass) for device in stick.config['devices'] if
device['id'].startswith('46') and not device['id'] in hass.data[DOMAIN]['devices'].keys()]
(device['id'].startswith('46') or device['id'].startswith('43')) and not device['id'] in hass.data[DOMAIN]['devices'].keys()]
add_devices(to_add)


Expand Down
8 changes: 2 additions & 6 deletions pyduofern/duofern.py
Expand Up @@ -183,15 +183,11 @@ def parse(self, msg):
# Universalaktor -- not tested yet
elif code[0:2] == "43": # pragma: no cover
self.update_state(code, "state", "OK", "1")
module_definition01 = self.modules['by_code'][code + "01"]
module_definition01 = self.modules['by_code'][code]
if not module_definition01:
DoTrigger("global", "UNDEFINED DUOFERN_code+_01 DUOFERN code+01")
module_definition01 = self.modules['by_code'][code + "01"]

module_definition02 = self.modules['by_code'][code + "02"]
if not module_definition02:
DoTrigger("global", "UNDEFINED DUOFERN_code+_02 DUOFERN code02")
module_definition02 = self.modules['by_code'][code + "02"]
module_definition02 = None

if module_definition01:
hash = module_definition01
Expand Down
5 changes: 5 additions & 0 deletions pyduofern/duofern_stick.py
Expand Up @@ -270,6 +270,11 @@ def unpair(self, timeout=10):
threading.Timer(10, self.stop_unpair).start()
self.unpairing = True

def remote(self, code, timeout=10):
self.send(duoRemotePair.replace('yyyyyy', code))
threading.Timer(timeout, self.stop_pair).start()
self.pairing = True

def test_callback(self, arg):
self.duofern_parser.parse(arg)

Expand Down
21 changes: 21 additions & 0 deletions scripts/duofern_cli.py
Expand Up @@ -52,6 +52,9 @@
'CONFIGFILE',
default=False)

parser.add_argument('--remote',
help='Pair by code. Added devices are also added to CONFIGFILE',
metavar='DEVICE_ID', default=None)

parser.add_argument('--pairtime', help='time to wait for pairing requests', metavar="SECONDS", default=60, type=int)

Expand Down Expand Up @@ -157,6 +160,14 @@ def do_unpair(self, args):
self.stick.sync_devices()
print("Pairing done, Config file updated.")

def do_remote(self, args):
code = args[0][0:6]
timeout = int(args[1])
self.stick.remote(code, timeout)
time.sleep(args.pairtime + 0.5)
self.stick.sync_devices()
print("Pairing done, Config file updated.")

@splitargs
@ids_for_names
def do_up(self, blinds):
Expand Down Expand Up @@ -303,6 +314,16 @@ def do_off(self, blinds):
stick.sync_devices()
print("""""")

if args.remote:
print("entering remote pairing mode")
stick._initialize()
stick.start()
stick.pair(timeout=args.pairtime)
stick.remote(code=args.remote, timeout=args.pairtime)
time.sleep(args.pairtime + 0.5)
stick.sync_devices()
print("""""")

if args.refresh:
stick._initialize()
stick.start()
Expand Down

0 comments on commit 433369f

Please sign in to comment.