-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define Echo Devices + Minor Enhancements
Allows definition of Amazon ECHO devices as Indigo devices in order to increase visibility of how commands are processed. To further facilitate Alexa Routines support, you can specify to treat dim commands as simple on/off i.e. dim to zero = off otherwise on. Added slight timing delay to maybe help with non-responding commands.
- Loading branch information
Jon
authored and
Jon
committed
Jan 23, 2018
1 parent
9c1fffd
commit 6872da2
Showing
9 changed files
with
253 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
Alexa-Hue Bridge.indigoPlugin/Contents/Server Plugin/Devices.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
Alexa-Hue Bridge.indigoPlugin/Contents/Server Plugin/amazon_echo_device_timer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#! /usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
####################### | ||
# | ||
# Alexa-Hue Bridge | ||
|
||
# Note the "indigo" module is automatically imported and made available inside | ||
# our global name space by the host process. We add it here so that the various | ||
# Python IDEs will not show errors on each usage of the indigo module. | ||
try: | ||
import indigo | ||
except ImportError, e: | ||
pass | ||
|
||
from constants import * | ||
import datetime | ||
import Queue | ||
import sys | ||
import threading | ||
import traceback | ||
|
||
PLUGIN = None | ||
|
||
|
||
class ThreadAmazonEchoDeviceTimer(threading.Thread): | ||
|
||
def __init__(self, plugin): | ||
threading.Thread.__init__(self) | ||
|
||
global PLUGIN | ||
PLUGIN = plugin | ||
|
||
def run(self): | ||
try: | ||
PLUGIN.serverLogger.debug(u"Amazon Echo Device Timer thread initialised.") | ||
|
||
while True: | ||
|
||
try: | ||
aeDevId = PLUGIN.globals['queues']['amazonEchoDeviceTimer'].get(True, 5) | ||
|
||
try: | ||
PLUGIN.globals['amazonEchoDeviceTimers'][aeDevId].cancel() | ||
del PLUGIN.globals['amazonEchoDeviceTimers'][aeDevId] | ||
except: | ||
pass | ||
|
||
PLUGIN.globals['amazonEchoDeviceTimers'][aeDevId] = threading.Timer(float(ECHO_DEVICE_TIMER_LIMIT), self.handleAmazonEchoDeviceTimer, [aeDevId]) | ||
PLUGIN.globals['amazonEchoDeviceTimers'][aeDevId].start() | ||
|
||
except Queue.Empty: | ||
pass | ||
except StandardError, e: | ||
PLUGIN.serverLogger.error(u"StandardError detected in Amazon Echo Device Timer") | ||
errorLines = traceback.format_exc().splitlines() | ||
for errorLine in errorLines: | ||
PLUGIN.serverLogger.error(u"{}".format(errorLine)) | ||
|
||
except StandardError, e: | ||
PLUGIN.serverLogger.error(u"StandardError detected in Amazon Echo Device Timer thread. Line '{}' has error='{}'".format(sys.exc_traceback.tb_lineno, e)) | ||
|
||
PLUGIN.serverLogger.debug(u"Amazon Echo Device Timer thread ended.") | ||
|
||
def handleAmazonEchoDeviceTimer(self, aeDevId): | ||
|
||
try: | ||
PLUGIN.serverLogger.debug(u'handleAmazonEchoDeviceTimer invoked for {}'.format(indigo.devices[aeDevId].name)) | ||
|
||
try: | ||
del PLUGIN.globals['amazonEchoDeviceTimers'][aeDevId] | ||
except: | ||
pass | ||
|
||
indigo.devices[aeDevId].updateStateOnServer("activityDetected", False, uiValue="No Activity") | ||
indigo.devices[aeDevId].updateStateImageOnServer(indigo.kStateImageSel.SensorOff) | ||
|
||
except StandardError, e: | ||
PLUGIN.serverLogger.error(u"handleAmazonEchoDeviceTimer error detected. Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.