Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Amazon Echo Hue Simulator Driver
#1
[Image: amazon-logo._CB321495207_.png]
Amazon Echo Hue Simulator Driver
Version 1.1

This driver will allow control of your CQC devices from the Amazon Echo.  
This is accomplished by simulating the Phillips Hue bridge on your local network, these will show up as connected devices in the Echo app.

Here is an example of what it can do...
[Image: 0.jpg]


Release Info
  • Version 1.0 Original Version
  • Version 1.1 Fixed issue with switch type causing echo to not recognize devices

Configuration File

You need to create an XML configuration file to map voice names to devices.  Here are the rules for that file, an example is posted below...
  • Default location <CQCDir>/CQCData/MacroFileRoot/Drivers/EchoHueSim/EchoConfig.xml
  • All <Device> tags must be enclosed in <Config></Config> tags
  • Each connected device should be in it's own <Device></Device> tags
  • <Name> - Voice tag/name used by the Echo to activate the device.  Must be unique.
  • <Type> - Switch/Dim - Switch for on/off devices, Dim for devices that support more than on/off
  • <Moniker> - Optional Driver name/monkier to control
  • <Field> - Optional CQC field name to control
  • <OnValue> - Optional command to send to CQC when Echo sends an On command
  • <OffValue> - Optional command to send to CQC when Echo sends an Off Command

Setup

I apologize for the complexity of the install but due to the way both the Echo and CQC (no TCP listener) work, this is as simple as I could make it.
  • The CQCEchoRelay file must be unzipped with 7ZIP, this was done due to forum file size limits.
  • Install CQCEchoRelay Service on a machine on your network (Run the Install_CQCEchoRelay batch file as an Administrator).  By default this will run on TCP port 8585, but you can change that by running the install file with the /P:<port> option.  Install_CQCEchoRelay /? for more info.  A firewall entry will also be automatically created.
  • Create an XML config file and place it under MacroFileRoot.  The default location is <CQCDIR>\CQCData\MacroFileRoot\\Drivers\EchoHueSim\EchoConfig.xml.
  • Add the driver in the CQC Admin Interface.

Driver Installation
  • IP Address/Port - Enter the ip address of the machine running the CQCEchoRelay.  This must be an IPv4 interface address, localhost/127.0.0.1 and IPv6 will not work.
  • Echo Name/Address - Enter the DNS name/IP Address of your Echo.  This is just used for discovery but it is best if your Echo is on a static/fixed address.
  • Config File Location - Path to your XML configuration file under MacroFileRoot.
Discovery

You must discover your devices in the Echo before they can be used.  Up to 61 devices can be discovered.  If you have multiple Echos, you must start discovery from the Echo entered during the driver configuration.  All the Echos on the same account will share the same list of devices.
After you have built your configuration follow these steps:
  • In the Echo app or web portal under settings Forget All Connected Devices.
  • Set the driver's Discover field to True (discovery lasts 60 seconds).
  • Say "Alexa, discover my devices" (from echo you entered during driver installation)
  • The Echo will report back the number of devices found, this should match the number in the drivers Device Count field.
Export

The driver has the ability to create a configuration file for you based on all of your v2 Scenes, Lights, and Relay type fields in your other drivers.
In order to use this the driver must be loaded first, so you will need to create a dummy config to get the driver loaded then run the export by setting the Export field to True.  This will generate an export file under macrofileroot with the date/time in the file name.  It will not overwrite your existing file.  You can then use this file or copy items from it to your main config file and reconfigure/reload the driver.

Usage

The driver can be used in two different ways.  The first way is to control fields directly.  To do this you put in your Moniker/Field in the configuration file for the device and optionally things like onvalue/offvalue.  The driver will then turn on/off (or set a card4 value) for that field directly based on Echo commands.

The second way to use the driver is with "dummy" devices.  You can just configure a <Name> and <Type>.  The driver will send a CQC User Action Event anytime a command is sent by Echo with a value of Name,Cmd,Value.  This can then be used in triggered events to do anything you want.

Voice Commands
  • On/Off -
    "Alexa, turn on <name>.",
    "Alexa, turn off <name>."
  • Dim -
    "Alexa, set <device> brightness to [##]%"
    "Alexa, set <device> to [##]"
    "Alexa, dim <device> to [##]%"
    "Alexa, dim <device> to [##]

Caveats:
  • In testing up to 61 devices were discovered.
  • May conflict with the Hue Bridge, do not discover devices in both the driver and hue bridge from the Echo
  • Devices may show up as "offline" in Echo App but should still be controllable.
  • The CQCEchoRelay relies on a network utility named ncat.exe.  This tool is also regularly used by network security experts and some hackers.  Because of this it is sometimes reported by Antivirus tools like Symantec as a virus.  It is not a virus and is required for the driver to work.  If you have AV issues you will need to exclude the executable from your AV program. "C:\Windows\System32\ncat.exe".
  • The CQCEchoRelay Service will autostart but not show up as running or started.  If you see ncat.exe in your task list or you run the netstat -ano | find "8585" you can verify it is working.
[Dean: A change in the HTTP client in the 5.x time frame caused an ambiguous type name in this driver. It's a trivial fix so I have attached a 5.x workable version of the original driver pack. Wuench, if you ever update this, we can get this simple fix into it so that this extra pack can be gotten rid of.]


Attached Files
.cqcdrvpack   EchoHueSim_1_1.CQCDrvPack (Size: 28.58 KB / Downloads: 14)
.zip   EchoHueSim_1_1_Source_Files.zip (Size: 43.13 KB / Downloads: 19)
.zip   CQCEchoRelay.zip (Size: 477.54 KB / Downloads: 46)
.cqcdrvpack   EchoHueSim_1_1_ForV5_x.CQCDrvPack (Size: 28.59 KB / Downloads: 8)
Wuench
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
Reply
#2
Great job Wuench!

61 Devices is pretty sweet, but the ability to Dim is bleeping awesome! I've had it working on my ISY, but getting it for CQC will force me to get my CQC server up and running again Smile

Getting voice input through the Echo has caused the first incident of my wife requesting that I automate something. I personally think reliable, non-threatening natural voice input is the tipping point for home automation.
Reply
#3
Here is a sample configuration file....
  • Kitchen Lights - This is a simple switch. The field is a boolean and on/off will set it to true/false.
  • Outside Lights - This is a v2 Scene field which is a string field. So you need the OnValue/OffValue.
  • Cool Temp - This is a Card4 field. If you use the Echo dim commands it will return a value of 0..100 and set the field to that value. On/Off will throw errors.
  • TV - This is a dummy entry. It will only generate a CQC User Action Event. So you can create a triggered action to do whatever you want with the value.

Code:
<Config>
     <Device>
          <Name>Kitchen Lights</Name>
          <Type>Switch</Type>
          <Moniker>MyLightingDriver</Moniker>
          <Field>LGHT#Sw_Light</Field>
     </Device>

     <Device>
          <Name>Outside Lights</Name>
          <Type>Switch</Type>
          <Moniker>MyLightingDriver</Moniker>
          <Field>SCNE#OutsideLights</Field>
          <OnValue>On</OnValue>
          <OffValue>Off</OffValue>
     </Device>

     <Device>
          <Name>Cool Temp</Name>
          <Type>Dim</Type>
          <Moniker>ElkM1</Moniker>
          <Field>T1CoolSP</Field>
     </Device>

     <Device>
         <Name>TV</Name>
         <Type>Switch</Type>
     </Device>
</Config>

Here is triggered action example that will split the values for TV event and run two global actions to actually turn on/off the TV. Just create a triggered event with Is User Action From <EchoDriver>.

Code:
// --------------------------------------------
// Parse Name,Command,Value
// --------------------------------------------
TrigEvent::GetUserActionVals(LVar:Type, LVar:Data)
System::GetNthToken(%(LVar:Data), ,, 1, LVar:Name)
System::GetNthToken(%(LVar:Data), ,, 2, LVar:Cmd)
System::GetNthToken(%(LVar:Data), ,, 3, LVar:Value)

// --------------------------------------------
// TV
// --------------------------------------------
If System::Equals(%(LVar:Name), TV, No Case)
   If System::Equals(%(LVar:Value), true, No Case)
      // Turn On TV
      System::DoGlobalAct(\\User\\TV_On)
   Else
      // Turn Off TV
      System::DoGlobalAct(\\User\\TV_Off)
   End
End
Wuench
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
Reply
#4
Very nice! Got a couple of test lights working without much trouble. Had some issue with the Echo IP address but re-did the Echo setup and created a static address as suggested. Everything fell into place after that.
Reply
#5
The zip file seems to be corrupted.
Dean Roddey
Software Geek Extraordinaire
Reply
#6
It's a 7z file you have to use 7Zip to extract it. I couldn't get the filesize low enough to upload with a regular zip.
Wuench
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
Reply
#7
My install is throwing an error.

CIDMacroEng, CIDMacroEng_Engine.cpp.1801, Status/App Status
Exception 'SocketErrors.ConnFailed' was thrown from line 1679
MEng.System.Runtime.StreamSocket

The install seemed to go fine. Ran the install with admin rights. Socket 8585 is linked to the CQC Server, so the application seems to be running. I configured the most basic of config files below with the last example as a dummy switch (strange but when you try to search for the xml file during install it only allows it within Program Data). I have the xml in either location (as described in the driver setup as well). Just cycles between wait for connectand waiting for comm resource.

I also used a static IP address for the Echo.

Config file below

<Config>

<Device>
<Name>TV</Name>
<Type>Switch</Type>
</Device>

</Config>

Any ideas?
Reply
#8
See if the relay is listening. From a command prompt run:
netstat -ano | find "8585"

You should see something like:
TCP 0.0.0.0:8585 0.0.0.0:0 LISTENING xxxx
Wuench
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
Reply
#9
naturally im traveling. guess i'll have something to do when i get home.

Smile
do the needful ...
Hue | Sonos | Harmony | Elk M1G // Caseta / Netatmo / Brultech in testing
Reply
#10
Just discovered that Echo won't take the name "Mute". It loads and discovers ok, but when you try to say "Alexa, Turn On/Off Mute" it doesn't send anything. I think it is interpreting it as a cancel or shut up command, or maybe it's part of the built in audio stuff.

I ended up changing my voice tag to "Sound".
Wuench
My Home Theater/Automation Website

[THREAD=5957]BlueGlass CQC Config[/THREAD]
[THREAD=10624]Wuench's CQC Drivers[/THREAD]
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Vantage Controls Driver for Infusion System KenC 3 716 10-23-2017, 12:10 PM
Last Post: Dean Roddey
  Another SMS Driver - SMS Global, one for everyone else znelbok 21 5,772 10-21-2017, 07:19 PM
Last Post: znelbok
  Monoprice Blackbird 4x4 HDMI Switcher - Driver request batwater 9 4,877 10-14-2017, 05:30 PM
Last Post: rtarver
  XBMC Driver wuench 419 118,768 07-02-2017, 11:04 AM
Last Post: Dean Roddey
  IMAP Email Driver whozeawhat 11 2,336 06-14-2017, 11:53 AM
Last Post: whozeawhat
  Which JVC Projector Driver indygreg 29 6,038 05-12-2017, 08:29 AM
Last Post: Dean Roddey
  SageTV Player V2 Driver chmilar 6 1,777 04-14-2017, 03:36 PM
Last Post: chmilar
  SageTV Driver George M 16 3,336 02-16-2017, 07:10 PM
Last Post: Dean Roddey
  ADA Suite 16 driver assistance zane 3 1,522 01-17-2017, 06:27 AM
Last Post: zane
  Sage Media Server driver (beta) Fonceur 696 128,927 01-06-2017, 05:34 PM
Last Post: Dean Roddey

Forum Jump:


Users browsing this thread: 1 Guest(s)