Tuicemens

Pages: [1] 2 3 ... 6

Author Topic: PI Alexa project  (Read 7661 times)

Tuicemen

  • Administrator
  • Hero Member
  • *****
  • Helpful Rating: 26
  • Offline Offline
  • Posts: 3687
  • Making Home Automation Fun!
    • Tuicemen.com
PI Alexa project
« on: August 27, 2018, 10:03:13 AM »

Creating an X10 Alexa box On A PI is a simple process with two programs. However for newbies navigating the PI terminal and understanding the lines can be overwhelming.
You'll need a pi with the full Raspbian stretch installed you can use the light but it doesn't come with java installed so you'd have to install it prior to running my installer script.

1:You should have it connecting to your router via wi-fi or Ethernet cable so set that up first.
2:Next open the terminal window (this is basically a command prompt)
3:Copy the code below exactly into the terminal window and hit enter
4: when done open the web browser on your pi to local host If you wish to access from another Device on your network open the browser on that device to the address of the PI

The following will auto download and install Ha-bridge & Mochad. It will also download and install the device.db file with 1-16 unit codes for L house codes to HA-bridge as well as AllLightsOn/Off  for "L", as well the x10cmd(mochad link) for HA-Bridge to send the X10 codes

wget -qO- http://tuicemen.com/downloads/pi/ha-bridge/x10-AlexaHub.sh | bash
 no longer available replace by the AlexaHub Pi image
I have no plans to keep updating this with new versions of HA-Bridge when they are released as it is now the installer script installs the 2.5.1version.
updating HA-Bridge is as simple as replacing the HA-Bridge.jar file with the newest HA-bridge release making sure the name is the same (no file version # in the
name)
« Last Edit: February 17, 2019, 09:14:45 AM by Tuicemen »
Logged
Get the inside scoop and member perks in the
Members Only Section!

Please don't email me Automation questions 
The forum is for that!

Tuicemen

  • Administrator
  • Hero Member
  • *****
  • Helpful Rating: 26
  • Offline Offline
  • Posts: 3687
  • Making Home Automation Fun!
    • Tuicemen.com
Re: Alexa project
« Reply #1 on: August 27, 2018, 06:24:41 PM »

To make name & address changes to a device click on Edit/Copy to the right of the device name.
this opens the add/edit screen with setting for that device.
changing the name is straight forward type it in and hit Update device.
However many will wish to also change the address or the call from PLC to RF. By default code is to send PLC (pl)
Change the pl to rf for sending RF the following leter number to the house code you wish (see attached) when done select Update Bridge Device at the top
« Last Edit: September 20, 2018, 05:02:55 PM by Tuicemen »
Logged
Get the inside scoop and member perks in the
Members Only Section!

Please don't email me Automation questions 
The forum is for that!

Tuicemen

  • Administrator
  • Hero Member
  • *****
  • Helpful Rating: 26
  • Offline Offline
  • Posts: 3687
  • Making Home Automation Fun!
    • Tuicemen.com
Re: PI Alexa project
« Reply #2 on: September 20, 2018, 05:54:01 PM »

Finally once all your devices are setup plug in your CM15 or CM19 if not already done and ask Alexa to discover devices.
you can also discover devices from the Alexa app
« Last Edit: September 20, 2018, 05:55:42 PM by Tuicemen »
Logged
Get the inside scoop and member perks in the
Members Only Section!

Please don't email me Automation questions 
The forum is for that!

brobin

  • Forum Supporter!
  • Full Member
  • *****
  • Helpful Rating: 1
  • Offline Offline
  • Posts: 68
Re: PI Alexa project
« Reply #3 on: September 23, 2018, 12:31:39 AM »

FANTASTIC! Works exactly as advertised & I couldn't be happier.  Thanks so much for doing this.  Now my laptop can get some rest!
Logged

Tuicemen

  • Administrator
  • Hero Member
  • *****
  • Helpful Rating: 26
  • Offline Offline
  • Posts: 3687
  • Making Home Automation Fun!
    • Tuicemen.com
Re: PI Alexa project
« Reply #4 on: September 23, 2018, 07:37:40 AM »

Glad to see you have a working Alexa Hub now!
I tested this a number of times with a new SD card image on a PI 3B+ but the PI model shouldn't matter.

However others may wish to know what model you used. ;>
Logged
Get the inside scoop and member perks in the
Members Only Section!

Please don't email me Automation questions 
The forum is for that!

brobin

  • Forum Supporter!
  • Full Member
  • *****
  • Helpful Rating: 1
  • Offline Offline
  • Posts: 68
Re: PI Alexa project
« Reply #5 on: September 23, 2018, 09:16:07 AM »

I'm running this on a Pi Zero W.
Logged

brobin

  • Forum Supporter!
  • Full Member
  • *****
  • Helpful Rating: 1
  • Offline Offline
  • Posts: 68
Re: PI Alexa project
« Reply #6 on: October 09, 2018, 06:47:55 PM »

I've been running the Pi Alexa Hub now and find it to be more desireable than keeping a laptop running Alex10 once I solved a problem with the WiFi dropping out.  It seems that the Pi Zero W defaults to NOT automatically reconnecting if the WiFi signal is lost  (CZB).  That makes no sense whatsoever but there's a fix to change that  :0~ :

1. Change permissions to allow writing to files. (There's lot's of places to find out how to do that from the desktop or terminal)

2.In  [/etc/network/interfaces] I added:

allow-hotplug wlan0

iface wlan0 inet manual

wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

wireless-power off


Since adding those 5 lines I have not had any more WiFi drops.  ~:0~    However, as a belt & suspenders kinda guy, I wanted to do a daily reboot to ensure reliability.  My first thought was to run a chron job to do that but what if the problem was that the Pi had frozen and stopped running?  The obvious solution was to simply plug the power supply into an Appliance Module and schedule it.

I have a JDS Stargate controller but the logic with any controller would be the similar to this:

IF
   Time is 4:00AM SMTWTFS
THEN
   X10:C-13 Pi Alexa Hub OFF
   DELAY 0:00:10
   X10:C-13 Pi Alexa Hub ON
ELSE
   [IF
   [   X10:C-13 Pi Alexa Hub is OFF
   [THEN
   [   DELAY 0:00:10
   [   X10:C-13 Pi Alexa Hub ON

This not only reboots the Pi at 4AM daily but if any inadvertent signal turns off the Pi at any other time it will turn it back on in 10 seconds.

Hope someone finds this useful!  (Chr)
 
« Last Edit: October 09, 2018, 10:56:21 PM by brobin »
Logged

Tuicemen

  • Administrator
  • Hero Member
  • *****
  • Helpful Rating: 26
  • Offline Offline
  • Posts: 3687
  • Making Home Automation Fun!
    • Tuicemen.com
Re: PI Alexa project
« Reply #7 on: October 10, 2018, 11:58:19 AM »

Good tip on the PI reconnect. and thanks for sharing the lines of code required.

There is however a issue with having your pi on a X10 module and cycling power to it.
The issue is the PI isn't shutting down properly since this is a computer it suffers the same issue your PC can if improperly shut down. You can corrupt the OS which would render your setup inoperable. the same can happen with a simple power blip I discovered this summer.
 Your best option would be to setup a cron job as it safely shutdowns the PI.
Since you have little running on your PI and if you have disabled the Desktop there should be no reason for the PI to freeze as this usually happens when it over heats.

Ways to prevent that are with a heat sink which you have, but a small fan could be added as well if your concerned. I ran my PI Zero W for several months with out even a heat sink and it is running my full HA setup. I do now have a heat sink added though, better safe then not. (Chr)

 
« Last Edit: October 10, 2018, 12:01:44 PM by Tuicemen »
Logged
Get the inside scoop and member perks in the
Members Only Section!

Please don't email me Automation questions 
The forum is for that!

brobin

  • Forum Supporter!
  • Full Member
  • *****
  • Helpful Rating: 1
  • Offline Offline
  • Posts: 68
Re: PI Alexa project
« Reply #8 on: October 10, 2018, 07:25:12 PM »

Thanks for that info.  I'll remove the module. Actually, if we're not here it wouldn't make a difference if it did freeze up as there's nobody here to talk to Alexa anyway. :`)
Logged

Tuicemen

  • Administrator
  • Hero Member
  • *****
  • Helpful Rating: 26
  • Offline Offline
  • Posts: 3687
  • Making Home Automation Fun!
    • Tuicemen.com
Re: PI Alexa project
« Reply #9 on: October 11, 2018, 08:07:21 AM »

So true, and without attempting to log into the PI you wouldn't know if it was an Amazon, HA-Bridge, Mochad or a PI lockup Issue so a reboot may be ineffective. Since the CM19 isn't connected directly to the power line it would make sense to put the zero W on a UPS. This is something I'll be looking into this fall.
Maybe someone else will beat me to it and post their setup so the zero safely shuts down on a power outage. ;>
Logged
Get the inside scoop and member perks in the
Members Only Section!

Please don't email me Automation questions 
The forum is for that!

brobin

  • Forum Supporter!
  • Full Member
  • *****
  • Helpful Rating: 1
  • Offline Offline
  • Posts: 68
Re: PI Alexa project
« Reply #10 on: October 15, 2018, 01:09:27 PM »

For a simple UPS for the PI I'm going to order this: https://goo.gl/jpaqvA  It's a Xiaomi 10000mAh Mi Power Bank Portable Charger that is reported to have the ability to provide power while being charged which, I've read, is not the case for most of these.  I've read that when the Pi Zero W  is idle it draws less than 300ma so, theoretically, it could power the Pi for 33 hours. While 33 hours is unlikely it should be sufficient to cover most outages. Even drawing 2500ma it would stay up close to 4 hours. Having the Pi floating on the battery should also provide some surge protection.

 I now have the Pi Alexa Hub running perfectly with a daily chrontab reboot to keep everything fresh with fast response times. Here's a photo of the finished "installation" sitting on the base of my desk lamp.  Bye Bye Laptop!   `:)
Logged

Tuicemen

  • Administrator
  • Hero Member
  • *****
  • Helpful Rating: 26
  • Offline Offline
  • Posts: 3687
  • Making Home Automation Fun!
    • Tuicemen.com
Re: PI Alexa project
« Reply #11 on: October 17, 2018, 07:04:37 AM »

NICE!!!
I'm a bit concerned by one of the reviews stating the power is interrupted once plugged or unplugged from an outlet. Do let us know how it works out for you.
You may also wish to eventualy put every thing into a small case simular to what docbell did http://forums.tuicemen.net/index.php?topic=1302.0
Logged
Get the inside scoop and member perks in the
Members Only Section!

Please don't email me Automation questions 
The forum is for that!

Tuicemen

  • Administrator
  • Hero Member
  • *****
  • Helpful Rating: 26
  • Offline Offline
  • Posts: 3687
  • Making Home Automation Fun!
    • Tuicemen.com
Re: PI Alexa project
« Reply #12 on: October 17, 2018, 08:53:09 AM »

The APC (BGE70) network UPS might be a better option as it supplies 3 outlets for the same price
https://www.amazon.com/dp/B00KH07WRC/ref=twister_B00QAJNO62?_encoding=UTF8&psc=1
Logged
Get the inside scoop and member perks in the
Members Only Section!

Please don't email me Automation questions 
The forum is for that!

brobin

  • Forum Supporter!
  • Full Member
  • *****
  • Helpful Rating: 1
  • Offline Offline
  • Posts: 68
Re: PI Alexa project
« Reply #13 on: October 17, 2018, 05:49:15 PM »

The APC (BGE70) network UPS might be a better option as it supplies 3 outlets for the same price
https://www.amazon.com/dp/B00KH07WRC/ref=twister_B00QAJNO62?_encoding=UTF8&psc=1

I have one of those backing up my cable modem and a few other small devices at my primary home and could use it there. They used to cost twice as much at Sam's Club a couple of years ago! At my other home, where the one pictured is located, I'd prefer something smaller to incorporate in a small case as you suggested.  That may be moot though as that place is for sale.   In my primary home I got the hub up and running but didn't have time to put it in service before leaving.  I'm back now and will incorporate what I've learned over the last two weeks to put it in service using a CM15A instead of the RF unit.  However, I recently found an old Firecracker in a drawer so I might play around with that as well.
Logged

Tuicemen

  • Administrator
  • Hero Member
  • *****
  • Helpful Rating: 26
  • Offline Offline
  • Posts: 3687
  • Making Home Automation Fun!
    • Tuicemen.com
Re: PI Alexa project
« Reply #14 on: October 17, 2018, 06:04:33 PM »

There is a UPS hat for the Zero which uses a rechargeable flash light (AA) battery if your truly looking for small and compact.
https://www.amazon.com/Alchemy-Power-Inc-Pi-Zero-UpTime-devices/dp/B073C3NJ2T/ref=sr_1_cc_1?s=aps&ie=UTF8&qid=1539813743&sr=1-1-catcorr&keywords=pi+zero+UPS
« Last Edit: October 17, 2018, 06:13:58 PM by Tuicemen »
Logged
Get the inside scoop and member perks in the
Members Only Section!

Please don't email me Automation questions 
The forum is for that!
Pages: [1] 2 3 ... 6