So for the past three days I’ve been struggling to set up push notifications since the guides miss some pretty crucial steps. I finally got it working and hoping to save someone headache in the future, I’m going to write a quick guide. I’ll likely use this myself if I need to set it up again.
- Up-to-Date Home Assistant
- Installed on a Raspberry Pi
- Used All-In-One Installer
- Log into your router and go to NAT/Gaming or IP Forwarding or Whatever it might be called. IT is different for each router. You need to forward external port 8123 to internal port 8123 on the internal IP Address of your Raspberry pi.
- Find your public IP Address and connect to it on port 8123. For example, if your IP address is
123.456.78.90:8123into your browser. Home Assistant should load (If it doesn’t work, try disabling the wifi on your phone and connecting that way. You might only be able to connect properly if you are outside of the network).
- Go to www.duckdns.org 533 and login using your choice of methods at the top.
- Enter a name for your subdomain. For this, I will use
hass-examplemaking my full domain
hass-example.duckdns.org. Don’t worry about setting your IP addresses yet.
- Click install 266 at the top, for their guide. Under
Operating Systems, select
piand then choose the domain you’re using for your DNS.
- SSH into your pi.
- Enter the following commands
mkdir duckdnsThis will make a directory for the duckdns script.
cd duckdnsChange to the duckdns directory.
nano duck.shcreate the duck dns script. Note that BRUH and DuckDNS use vi. This is stupid and more complicated than necessary.
- Copy the line of code from the install page and paste it into the empty file (If you are using putty, copy the text then right-click in putty to paste). It should look like this:
echo url="https://www.duckdns.org/update?domains=hass-example&token=a836a8s-1337-892c-a495-ef817a92&ip=" | curl -k -o ~/duckdns/duck.log -K -
ENTERto save the file.
chmod 700 duck.shwhich lets the script run.
crontab -e. Copy the following text and paste it into the bottom of the crontab file.
*/5 * * * * ~/duckdns/duck.sh >/dev/null 2>&1
- Run the script by typing
- Check the script by typing
- If it worked, You should see
OKon the same line as
[email protected]:~/duckdns $. If it says
KO, something didn’t work right! Check your work and try again.
cdto return to the root directory.
- Make sure everything is working by connecting your duckdns domain on port 8123, such as
http://hass-example.duckdns.org:8123. Remember to try while outside of your local network. If everything worked, Home Assistant should load!
- Open your router configurations again. You need to forward Port 80 to Port 80 on your raspberry pi, as well as port 443 to port 443 on your pi. This is to verify the certificate.
- Connected to your pi through SSH, run the following commands
mkdir certbotto make a directory for the SSL certification bot
cd certbotto change to that directory
wget https://dl.eff.org/certbot-autoto download the certbot
chmod a+x certbot-autoto allow the certbot to run.
- Edit and paste in the following command to run the certbot. You need to put in your real email address and your duckdns domain.
./certbot-auto certonly --standalone --standalone-supported-challenges http-01 --email [email protected] -d YOURSUBDOMAIN.duckdns.org
- Answer the questions as it poses them to you.
- You should get a confirmation that everything went well and that the certificates are in the /etc/letsencrypt directory.
- Remove the port 443 and port 80 forwarding from your router.
sudo chmod -R 777 /etc/letsencryptto allow homeassistant to read the certificates.
configuration.yaml, you need to add thessl-certificate:
lines underhttp: It should look like this
http: api_password: YOUR_SECRET_PASSWORD ssl_certificate: /etc/letsencrypt/live/hass-example.duckdns.org/fullchain.pem ssl_key: /etc/letsencrypt/live/hass-example.duckdns.org/privkey.pem
- Try to access https://YOURDOMAIN.duckdns.org:8123 50 from outside of your local network. (note that is httpS, not http). If it connects, you did good!