Amazon Echo control UPB lighting - Have Elk M1

relay

Member
Hi all,
 
I am trying to figure out best way for me to control UPB lighting via Amazon Echo.
 
I see a few different options but all look either costly or complex.
 
1st option would be the Alexa UPB bridge for $600.  Seems WAY OVERPRICED and limited -   http://alexaupbbridge.com/
 
2nd option would be some sort of software controller like CQC or HomeSeer.  I guess you could buy Homeseer hardware controller as well.....
I like CQC given the involvement of the company here on these forums.
 
 
My current control is via UPB scene controllers, ELK M1 for automation of the lighting and eKeypad app on iPhone for remote control as needed.
 
 
My initial desire is to provide control for a couple of lamps that are in pain in the ass locations to get to but it would be nice to access all of my lighting and devices as I have about 25 devices already connected.
 
 
Thanks for any advice coming my way!!!!
 

personalt

Active Member
very interested in this as well.  that UPB bridge is crazy expensive.  what is interesting is that it seems they are leveraging the smart home api and then just forwarding the commands on to upb.  I am of course over simplifying this a but there is an amazon api and python and other apis for upb. https://github.com/zonyl/pytomation for example.  I had another thread about a better andriod to upb interface but if Alexa could work well the 'dots' are a lot cheaper then putting android devices in each room.

It seems like a small piece of software plus a ubp pim could do this..

 
 

relay

Member
If I am going to spend that kind of $$$, seems like I would want something that can do a lot more than just interface a single protocol  :(
CQC or Homeseer also seem like overkill for just this one task and I really have no desire to spend hours and hours creating a software defined system.  I tried this years ago when I was heavily into automating my home theater and movie library and it was just too much investment of time.  
 
I don't see too many options here and I don't think replacing all my switches makes sense either.  I have a lot of virtual links for various reasons, mostly due to old wiring that would be difficult and costly to rewire.
 
This is a concept I've been exploring lately too. I originally started by creating a basic speech recognition app for my daughters that would respond to simple linear type requests. Then scope-creep introduced itself and more complex interaction was added... still have some tweaking to do. But having gotten this far it got me thinking about being able to also control my lighting by voice. All but three light switches are UPB and I also have a few plug-in modules; the configuration has been running very smoothly for almost two years. I have it integrated into my M1 panel as well.
 
As mentioned above, Pytomation is an option but I don't know how active the development is and I can't tell when the last time there was an update. It doesn't appear to support python3.x and the UPB integration is limited to the RS-232 CMU module. There is another project called Home Assistant that supports python3 but I haven't seen anything on the site or documentation that mentions supporting UPB.
 
I did see a document online that explained the interpreting of the ASCII text generated by the CMU but I don't recall where exactly I found it... need to search again for it. I'm thinking that may be the route I pursue since I'm only wanting to send simple UPB commands.
 

Desert_AIP

Senior Member
You can use a Raspberry Pi to emulate a WEMO device and use it with Alexa pretty easily.
That can send GPIO commands to control relays with the RPi via voice command.
 
I've been reading regarding using the RPi and Mister House with a UPB plugin.
 
I bet you could combine the two and send the UPB commands instead of the GPIO commands.
 
It's in the "need to play with this" pile right now.
 

swaggy

Active Member
Do you have an IP gateway to front end the UPB devices? If so, then it should be possible to do this for way less than $600. I'm controlling my home theater through a global cache gc100 with a custom skill in Alexa. The way it works is Alexa interprets voice commands and makes a call to a home server running Flask_ask which sends commands to the gc100. Everything is written in python and there are plenty of examples on GitHub
 

swaggy

Active Member
Just read your post again - does the ELK have an API? I have an OmniPro and there's a C library that I can use on Linux for this sort of thing.
 

Desert_AIP

Senior Member
OK
 
I have the RPi Wemo emulation running well with Alexa voice control. 
I can run scripts for multiple devices.  Right now just running GPIO pins to control relays - simple.
 
I added an RS232 board to the RPi.  I disabled the console and enabled the UART port dev/ttyAMA0.
Sending commands via the command line or python is not generating errors.
 
I want to run a script to send a UPB command down the serial port to a PIM I have connected to it.
In theory this should be fairly simple.  I know I'm close but I'm missing one critical piece.
Hopefully someone can provide the piece of insight I need and I can get this working.
 
I used the UPB command tool to determine the proper hex command to turn a single light off.
I know I need to begin the command with (Ctrl-t) hex 14 and end with (CR) hex 0D
 
So I have the following hex command I'm trying to send to turn off unit 58 (my office light).
 
14 07 04 05 3A FF 21 91 0D
 
Here's the python code I'm trying to use.
 

import serial
 
port = "/dev/ttyAMA0"
usart = serial.Serial (port, 4800)
message_bytes = "140704053AFF21910D".decode("hex")
usart.write(message_bytes)

 
Nothing appears to be happening. 
I reset the PIM to make sure it's in message mode.
I've tried both 4800 and 9600 baud.
 
Thanks
 

JonW

Senior Member
The port settings should be 4800/N/8/1.
 
For your control word, I would use "87 00" for a link packet.  I didn't compute out the options for what "07 04" does, but "87 00" is what I would use for the commands you are trying to send.  (direct packets would be "09 00").
 
Using some of your values above, my command would be as follows:
14 87 00 05 3A FF 21 1A 0D
 

Desert_AIP

Senior Member
I cut and pasted the command from PCS's Cmd wizard, the control word came from that.
I didn't look it up to see what it was. 
But when I change the "Network" to the "Universal" option I get a control word starting with an 87.

I think it's not transmitting at all. 
The PIM isn't buzzing.
I'm going to try a different PIM just in case.
I need to put a meter on the TX pin.
 
And I just discovered my RUC is offline so I can't use it's receive capability.
 
I swapped the cable, that wasn't it.
I put the SD card in a spare Pi3 I have.
When I try to run the python script it hangs at the write command according to the debug info when I ^C to stop it..
 
The other RPi was a Pi2.
 
I ordered another TTL board just in case this one isn't working.
 

relay

Member
I started playing with Homeseer and the the ULTRAM1G plug in for my Elk M1 panel  which gave me Alexa voice control to lighting as well.
It was pretty easy but lots of work changing the names of everything so Alexa can get it right.
 
Of course now that I see what I can do with lights, I want to enable everything I can for voice :)
 

BobS0327

Active Member
Desert_AIP said:
OK
 
I have the RPi Wemo emulation running well with Alexa voice control. 
I can run scripts for multiple devices.  Right now just running GPIO pins to control relays - simple.
 
I added an RS232 board to the RPi.  I disabled the console and enabled the UART port dev/ttyAMA0.
Sending commands via the command line or python is not generating errors.
 
I want to run a script to send a UPB command down the serial port to a PIM I have connected to it.
In theory this should be fairly simple.  I know I'm close but I'm missing one critical piece.
Hopefully someone can provide the piece of insight I need and I can get this working.
 
I used the UPB command tool to determine the proper hex command to turn a single light off.
I know I need to begin the command with (Ctrl-t) hex 14 and end with (CR) hex 0D
 
So I have the following hex command I'm trying to send to turn off unit 58 (my office light).
 
14 07 04 05 3A FF 21 91 0D
 
Here's the python code I'm trying to use.
 
 

import serial
 
port = "/dev/ttyAMA0"
usart = serial.Serial (port, 4800)
message_bytes = "140704053AFF21910D".decode("hex")
usart.write(message_bytes)

 
Nothing appears to be happening. 
I reset the PIM to make sure it's in message mode.
I've tried both 4800 and 9600 baud.
 
Thanks
First of my caveat,  I only have a very limited understanding of Python.  I rarely use it.   But your problem was challenging.  So, I offer the following (Windows based) solution but it can easily be ported to Linux...
 
 
Code:
import time
import serial

ser = serial.Serial(
    port='\\\\.\\COM5',
    baudrate=4800,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS
)
ser.timeout = 1           #non-block read
ser.rts = False           #disable hardware (RTS) flow control
ser.dtr = True            #disable hardware (DTR) flow control
ser.writeTimeout = 2      #timeout for write

if ser.isOpen():
    ser.close()
ser.open()
#ser.isOpen()


#Command to be submitted to PIM
 #0714018DFF302870F39D

ser.write(b"\x14")  
ser.write(b"\x30")  # 0
ser.write(b"\x37")  # 7
ser.write(b"\x31")  # 1
ser.write(b"\x34")  # 4
ser.write(b"\x30")  # 0
ser.write(b"\x31")  # 1

ser.write(b"\x38")  # 8
ser.write(b"\x44")  # D
ser.write(b"\x46")
ser.write(b"\x46")
ser.write(b"\x33")
ser.write(b"\x30")
ser.write(b"\x32")
ser.write(b"\x38")
ser.write(b"\x0D")
ser.write(b"\x17")
ser.write(b"\x37")
ser.write(b"\x30")
ser.write(b"\x46")
ser.write(b"\x33")
ser.write(b"\x39")
ser.write(b"\x44")
ser.write(b"\x0D")
time.sleep(1)

ser.close()


 
 

Desert_AIP

Senior Member
OK I finally had time to try this out and I know I'm necroposting this thread.
But I got it working.
After reading the PCS App Note 126 I realized I was sending hex to the PIM instead of ASCII translated hex codes.
@BobS0327 above had the coding right, I just had to modify for Python.
 
Here is the code to turn my Kitchen Light On to 70% at the 1.6 Second rate:
14 09040152FF22460237 0D
 
To send the hex word "09" You have to send two ASCII packets one for the "0" and one for the "9"
BUT, you have to send them in hex!
So the ASCII hex code for "0" is "30" and the ASCII hex code for "9" is "39"
So you send 3039 decoded as hex out the serial port and it sends a 0 and a 9.
That was what was confusing me.
 
-----------------------------------------------

#!/usr/bin/env python
 
import serial
import time
import binascii
 
usart = serial.Serial(
 
               port='/dev/ttyAMA0',
               baudrate = 4800,
               parity=serial.PARITY_NONE,
               stopbits=serial.STOPBITS_ONE,
               bytesize=serial.EIGHTBITS,
               timeout=1
           )
 
#Command to be submitted to PIM
#09040152FF22460237  - Kitchen Light GotTo 70% 1.6 Rate 
message_bytes = "143039303430313532464632323436303233370D".decode("hex") #Kitchen Light Goto 70%
usart.write(message_bytes)

 
II have about 10 voice activated links and direct unit commands working now.
 
I'm using a WeMo emulation on my Raspberrry PI to issue the commands via voice with my Amazon Echo.
Each trigger in the WeMo emulation can do different things, one can send these UPB commands, another could close a relay attached to the GPIO bus (to operate a garage door) and still another can send CEC commands to a TV.  I'm sure there are more. 
Each named WeMo device simply calls a script.  The script can do anything.
 
Top