Echo Speaks Local Cookie Authorization Server

If you use the Echo Speaks smart application in Hubitat Elevation to drive your Alexa devices for customized speech, be aware that the Heroku cloud application server will begin charging per month for their service on November 28th. Echo Speaks uses a Heroku routine in order to maintain a valid login cookie to the Alexa service.

Tony Fleisher, the author of Echo Speaks has developed a local Echo Speaks authorization server that removes this need for Heroku and runs on your local network.

There are two ways to install this local authorization server. Both methods require a Linux server that can be a Raspberry Pi, a Virtual Machine, or a LXC/LXD container.

The first way to install the container is in Docker.

To install Docker and docker-compose, if it is not installed:

curl -sSL https://get.docker.com | sh
sudo apt install docker-compose

Then, download and unzip the project:

sudo apt install unzip
wget https://github.com/TonyFleisher/echo-speaks-server/archive/refs/heads/docker-enablement.zip
unzip docker-enablement.zip

Move into the docker folder for the project:

cd echo-speaks-server-docker-enablement/docker

Become the root user:

sudo su

Execute the command to build the container.

docker-compose build

If you get the following error:

The Compose file './docker-compose.yaml' is invalid because:
Unsupported config option for services: 'echo-speaks-server'

then you need to edit the docker-compose.yaml file:

nano docker-compose.yaml

Add the following line to the beginning of the file before the “services” line and horizontally aligned with it:

version: "3"

Exit the editor with CTRL X, Type “Y” and hit enter.
Then repeat the:

docker-compose build

To start the project, find out the address of your docker host:

ip a

Start the Echo speaks server using the address of your docker server from above (my address is 172.16.1.78):

IPADDRESS=172.16.1.78 ./start.sh

The startup operation should look like this:

Test to see if it is running, visit the Web page (with your address at port 8091)
In my case: http://172.16.1.78:8091

Go back to the Echo-speaks app in the Hubitat and clear your server setup. Then initiate the setup being sure to turn off the “Deploy to Heroku” switch. That’s it!

ALTERNATE INSTALLATION OF ECHO SPEAKS AUTHORIZATION SERVER WITHOUT DOCKER

On your target server, install the dependencies:

sudo apt install nodejs
sudo apt install npm

Now get and install the Echo Speaks Server application.

npm i https://github.com/tonesto7/echo-speaks-server
sudo npm install -g pm2
cd node_modules/echo-speaks-server
sudo pm2 start index.js
sudo pm2 list
sudo pm2 save
sudo pm2 startup
sudo pm2 save

Test to see that it is running by visiting the Web page (with the address of your server at port 8091)
In my case: http://172.16.1.78:8091

That’s it!

1 Like

Hello:
I seem to get the following error when doing the docker-compose build:
image

Any suggestions?

The file in question:
image

I had to edit the docker-compose.yaml file and add to the top line: version: “2”

version: “2”
services:
echo-speaks-server:
image: echo-speaks-server:2.7.2
build:
context: …/
container_name: echo-speaks-server
restart: always

ports:
  - "8091:8091"
env_file:
  - './env.echo-speaks-server'
volumes:
  # Data persistency
  - ./data:/mnt/es-data

@PhiltorX I can see some servers requiring that. Mine didn’t.

@jtmpush18 try adding a line to declare the docker version at the top of the docker-compose file as @PhiltorX mentioned.

Yup.
That seemed to work.
Thanks @PhiltorX

2 Likes

The reason you get the error is because the yaml file is expecting docker-compose from the official Github repo. The version you grab from apt is different.

To fix it, you can use the workaround others provided above or:

sudo apt remove docker-compose

sudo curl -L “https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

Thanks for the instructions. I am a first time Pi 3 user and was able to install Docker and the Echo Speaks service using your excellent instructions. Until… I clicked on Amazon Login, then I receive the error: Proxy-Error: Error: connect EHOSTUNREACH 54.192.31.209:443 (with a different IP each time I try). I have rebooted both Hubitat and the PI with the same results. The status, server port and URL look ok. The Pi is running a static IP (wireless). Suggestions? Please be gentle as this is new to me!
Screenshot 2022-11-27 124313

@JeffR Sometimes you will see an error like this on first run. The reboot of the Pi running the cookie authentication server should work. However, you indicate that you did that. So, are you initiating the server authentication from the Hubitat Echo Speaks app? Could you include a screen shot of the actual error? Come chat on https://chat.scottibyte.com/.

Thanks for getting back so fast. I am clicking on the Goto Login page from port 8091 from the Pi on the screenshot above and I then receive the error.
Screenshot 2022-11-27
I don’t see any authentication from the Hubitat Echo speaks app other than:
Screenshot 2022-11-27 1
But I do see this (which is concerning that is still shows the old server)
Screenshot 2022-11-27 2
When I go to the next screen the server switch is off and there is nothing to sign in at that point.
Screenshot 2022-11-27 3
I have tried using the reset options several times.
Thanks in advance for your assistance.

@JeffR Ok, very close. When you tap the “Begin Server Setup” on your last screenshot, It should bring you to a page showing you the Callback URL which you copy. Then you visit your server at port 8091 and paste that into the last field entitled “App Callback URL” on the “Echo Speaks Service v2.7.2” screen. Then, you exit that screen. Then you exit the screen that gave you the callback URL. At the bottom of the Echo Speaks screen give it a NEXT… Then go back into the Echo Speaks App and you will be able to provide your login credentials and it will work.

Thanks again. Yes, after I hit next on the echo speaks, I also hit done, went back into echo speaks and still no request for the credentials. If I go back into the Login service page it brings me right back to the same spot to deploy the server. I rebooted both hub and Pi but no where to enter credentials. Apologies for taking up your time.

No problem. If you would still like help, come by the chat at https://chat.scottibyte.com/ and we can figure it out. When I wrote the blog, I had issues trying to get it up and running and finally figured out the nuances.

So, tom.s implemented his ES Login/cookie server inside of a Hyper-V Virtual Machine running inside of Windows 10 Pro. He created a VM that was Ubuntu 20.04 and configured LXD on it. Initially the LXD containers were not getting LAN addresses despite bridging.

He discovered this tidbit.

That is inside of this article:
https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/nested-virtualization

He configured a bridge on the Ubuntu VM using netplan:
image

He then created a Bridge Profile for LXD:

lxc profile create mainlan
cat <<EOF | lxc profile edit mainlan
description: Bridged networking LXD profile
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: bridge0
    type: nic
EOF

After the above, he created a LXD container with:

lxc launch ubuntu:20.04 test --profile default --profile mainlan -c boot.autostart=true

I got this installed and running successfully on my Synology NAS with only one little hiccup: the pm2 startup command failed when it was unable to find any of the init system tools that pm2/lib/API/Startup.js is expecting to see, so it won’t survive a reboot and will require manually restarting the daemon. pm2/lib/API/Startup.js expects at least one of the following init tools to be installed:

systemctl   : systemd,
update-rc.d : upstart,
chkconfig   : systemv,
rc-update   : openrc,
launchctl   : launchd,
sysrc       : rcd,
rcctl       : rcd-openbsd,
svcadm      : smf

The Synology DSM supposedly ships with upstart already installed but I can’t seem to find the update-rc.d command; it may be there somewhere but it’s not currently in my $PATH. Anyone have a clue about how to enable upstart or one of the other init systems under Synology’s DSM 6?

@steve_hoge So, that’s another reason that I like placing the app inside of a LXD container. All LXD container instances for debian/ubuntu will have a working systemctl.

In case anyone else wants to set it up on AlmaLInux / Rocky Linux 9 (should also work for 8) here is what I did:

yum -y install git npm nodejs policycoreutils-python-utils
npm i https://github.com/tonesto7/echo-speaks-server
sudo npm install -g pm2
cd node_modules/echo-speaks-server
sudo pm2 start index.js
sudo pm2 list
sudo pm2 save
sudo pm2 startup
sudo pm2 save
firewall-cmd --add-port=8091/tcp --permanent
firewall-cmd --reload

I used the Echo Speaks app extensively for the last couple of years on about a dozen Echo dots. This new version which provides alternatives to Heroku is welcome. However, as a novice, I need to ask if anyone can tell me the minimum Raspberry Pi version that would enable me to run Echo Speaks. I’ve been wanting to get into RP for some time, but I’d like to put the Pi server, once configured correctly, into my Leviton structured media center where it would remain permanently. Any suggestions would be greatly appreciated.

@Dave_Lukasek Dave, Honestly post pandemic the Raspberry Pi’s have tripled or more in price. Watch my video on “Cheap Self Hosted Server”. This cookie authorization server is probably the first of perhaps 8-10 things you will want to locally host. You would be much better off to move to something that is upgradable. That being said, the least I would go with is a Pi 3B. On Amazon, a Pi 3B with 1GB of memory is $113. Big waste of money. They were awesome when they were $35.

1 Like

Yesterday I watched a video interview with Pi creator Eben Upton, who seemed to be saying that Pi products may be hard to find through most of this year unless you’re willing to pay scalper’s prices. At Canakit, I managed to find one of the few Pis they had in stock, a Pi 4 kit, which I promptly ordered and hope to have in a few days. Heading over to your channel to watch the video you recommended now. Thank you so much for your help and advice!