X10 Community Forum

📱🖥️PiX10Hub => 💬General Discussion => Topic started by: petera on February 11, 2021, 11:33:48 PM

Title: Roll your own Alexa device
Post by: petera on February 11, 2021, 11:33:48 PM
 :-[I probably should start a new post on this topic but in case we are treated to the joys that are all things ESP8266 this has already been tried as a solution for Alexa control. As you may or may not know it’s always been about fooling Alexa into thinking that you are using a registered Alexa skill. Better known as emulators. Amazon twigged this early on and as as a result regularly update their firmware to eradicate the emulator. As with the HA Bridge if you go this route it needs to be regularly maintained by someone who actually knows what they are doing. This is worth a read just to give you an insight into all things Alexa emulators https://www.toptal.com/arduino/esp8266-arduino-tutorial-alexa-hack
Title: Roll your own Alexa device
Post by: Tuicemen on February 12, 2021, 07:03:11 AM
Yes a new thread would be better so split it off to here.
Nice artical, especially for those with no experiance with a ESP chip or using the ardiuno software. Another cool point is HG can controll Wemo switches natively.
Title: Re: Roll your own Alexa device
Post by: Tuicemen on February 12, 2021, 08:25:13 AM
I have been experimenting with a $2 ESP-01 module for a couple of weeks now thinking of ways to utilize this into my X10 HA setup. With the web server it is possible to control x10 Devices in HG. Setting the ESP up as a wemo hub, though limited to the number of controlable Alexa devices, should be interesting. I was sitting on the fence for picking up a couple of Wemos D1 esp8266 boards. This may be a good project for one or two.  >!
Title: Re: Roll your own Alexa device
Post by: bkenobi on February 12, 2021, 11:52:00 AM
If you have no experience with ESP devices, I personally would not recommend the chip you have.  I would recommend getting a Wemos board as they are much more full featured and allow for real experimentation.  I have a Wemos D1 and a NodeMCU which are both fine, but most people seem to opt for the Wemos mini boards.  If you are going to be following along with other people's projects to start, you would do well to source one of these two options as they will provide you an opportunity to simply repeat exact steps.  The ESP-01 is an ancient board that nobody uses anymore.  Any tutorials are likely to be from close to 10 years ago and no likely repeatable due to Arduino changes etc.

The nice thing about the ESP architecture is that everything is super cheap because no licenses!  It's like the Arduino but with WiFi and more memory.  They are awesome!
Title: Re: Roll your own Alexa device
Post by: Tuicemen on February 12, 2021, 12:38:07 PM
The only reason I've been playing with the ESP-01 is it was free.
I've not (yet) had a problem implementing any ESP8266 sketches.
Though I've not tried the project petera links to I did try a simular project that allows up to 14 devices to work with Alexa.
https://github.com/kakopappa/arduino-esp8266-alexa-multiple-wemo-switch
Alexa does see the devices I programed in though I've not coded in the actual location of the switches (gpio pin or something else).
The Wemos D1 modules are in my shopping cart but  I've not hit the purchase button rofl
I was hoping to get a few ideas from X10 users in this thread http://forums.x10.com/index.php?topic=31437.0
The internet is full of projects for the ESP8266 modules, the task is sorting through them all.  :-[
Since it is possible to control several things with one board I'm begining to wonder if I realy need the number in my shopping cart. ::) :'
Title: Re: Roll your own Alexa device
Post by: Tuicemen on February 12, 2021, 05:29:02 PM
I'm wondering if the device limitation for some of these Alexa ESP emulators is due to the authors are using the GPIO pins. ??? ::) :'
Since my ESP-01 is limited to 2 pins (unless I do some extra coding) I would be limited to two devices using the pins. :(
However if the limitation is not related to the number of available pins but overall calls that that too is a bummer. :(
I currently have Alexa setup to control 3 X10 devices in HG via my ESP-01, none are using GPIO pins.
I don't wish to code in more untill I've had a chance to test the responce verses my HA-Bridge setup.
I'm sure A Wemos D1 will perform better then this ESP-01.
In any case my ESP-01 will make a nice "Lite HG Client" with or with out Alexa.



Title: Re: Roll your own Alexa device
Post by: Tuicemen on February 13, 2021, 01:13:29 PM
Most of the esp8266 sketches for Alexa are to emulate a Wemos switch. This is different then emulating a Philips Hue or using the Hue API like HA-Bridge does. So there is a difference in how each works. However I did find one project that does emulate a Philips Hue on a ESP 8266 board. I'm  not sure if it uses the api or a Hue hack so it may or may not work just as well or better then HA-Bridge does with Alexa. I may play with that project too.

 So far the Wemos emulation hasn't  missed a beat even after a restart.
 I pulled the trigger on purchasing a couple Wemos D1 boards so I can run some different sketches  while my Wemos emulation is running.
Title: Re: Roll your own Alexa device
Post by: Tuicemen on February 20, 2021, 11:58:36 AM
The esp-01s module with the Wemos hack coded in seems to be out performing HA-Bridge (at least speed wise)
the ESP is just slightly faster at executing Alexa Commands, however it may be possible to increase the speed of HA-Bridge by playing with the delay values.
The other speed factor may be that my ESP is plugged directly into my Amazon Flex module's USB port.
Title: Re: Roll your own Alexa device
Post by: Tuicemen on February 20, 2021, 04:12:14 PM
Originaly I didn't see a use for adding IR to a ESP board like the in the OP link as I have a Broadlink RM for my TV at both locations.
I then found a IR reciever LED and began to think of how I could use it. That made me think of adding a transmitter as well. IR is line of sight and I do have a few things that are out of sight of my Broadlink that can use an IR remote.
 -:) It may be handy to add Alexa control for them.
Title: Re: Roll your own Alexa device
Post by: Tuicemen on December 26, 2022, 05:48:22 PM
My esp-01 x10 Alexa controler had been working flaw less untill we got a new modem. Today I thought I'd get to updating the code to allow the new modem connection.  I decided to look at the possibility of a new sketch for it. Or to see if there had been any new developments.
The Ardiuno ide programing application was updated so just maybe some sketches were too.
I discovered a esp 8266 sketch by Aircookie https://github.com/Aircoookie/Espalexa this combines the wemo as well as the hue sketches into one allowing diming, color and speed control in addition to just on and off. Reading through the README and looking into the code it is explained that the number of devices possible is limited by the boards memory.
Since the sketch I was using was originally created for the esp-01 I thought I'd try it on a spare wemo d1 board I had laying arround. I don't use any dimming commands so I stuck with my original sketch adding 16 X10 devices just as a test. I found where the device limitation was added to the code and changed it to 16 and it does allow Alexa to see and control all 16 devices I added. 8)

The wemo hue combo sketch states a max of 128 devices but it is coded for 10 by default. I don't  use even 20 x10 devices with Alexa from both homes so this is a very reliable and cheap way to do Alexa x10 control. >!