How to setup Gladys on a Raspberry Pi with remote HTTPS and SSH access

Published on January 6, 22

Synpse is an end-to-end platform to manage your devices and cloud machines. Performs software updates, collects metrics, logs. Easily deploy your applications. Join the platform it's free for up to 5 machines.


Hardware

Software

  • Synpse - provides app deployment, SSH and HTTPS access.
  • Gladys - a privacy-first, open-source home assistant.
  • Ubuntu 20.04.2 LTS image. Feel free to use Raspberry Pi OS (previously called Raspbian).
  • Docker - deploying containers on the edge devices prevents a lot of issues.

Intro

There are multiple ways listed on setting up the Gladys Home Assistant on your PC/laptop/RaspberryPi in the official docs https://gladysassistant.com/docs/. However, most of them lack things like ensuring remote HTTPS access to your Gladys instance, SSH, updates and so on. We will try to address them :)

In this short tutorial we will setup a Gladys on a RaspberryPi. Using this installation method you will get few great things out of the box:

  • Monitor your device uptime, CPU/RAM metrics.
  • SSH from anywhere, even if you can’t ping your device directly.
  • Public HTTPS URL to connect to Gladys from anywhere in a form https://dev-{YOUR ID}.synpse.cloud

Step 1: Install Docker

Depending on your RaspberryPi OS Docker installation might vary but in most cases this script from https://docs.docker.com/engine/install/ubuntu should do the job:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

Step 2: Install Synpse agent on your device

Log into your Synpse account, navigate to the “Devices” section and then click on “Provision”. Use the command in your RaspberryPi terminal. This will download, install and initialize the synpse agent.

Once the device has appeared in your Synpse dashboard:

Registered RPI
Registered RPI

Once device is visible, click on the “edit labels” from the menu. Add a label ‘type: rpi’:

Label your device
Label your device

In Synpse, applications are installed into the devices based on device labels so it’s a good practice to label your devices accordingly.

Step 3: Create Gladys deployment

Applications in Synpse are defined in yaml format. If you have used Docker Compose or Kubernetes before, it will feel familiar. You can read more about them here.

To create the application:

  1. Select the namespace (should be ‘default’ on the left side menu)
  2. Click on “New Application” button in the top
  3. Copy paste the yaml from below

Or, login into cloud.synpse.net and click on the button below:

Deployment spec that you can copy to Synpse looks like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
name: gladys
scheduling:
  type: Conditional
  selectors:
    type: rpi # Update to your device selector
spec:
  containers:
    - name: gladys
      image: gladysassistant/gladys:v4
      networkMode: host # Host network as it needs to scan it for devices
      privileged: true
      volumes:
        - /data/gladysassistant:/data/gladysassistant
        - /dev:/dev
        - /run/udev:/run/udev
        - /var/run/docker.sock:/var/run/docker.sock
      env:
        - name: NODE_ENV
          value: production
        - name: SERVER_PORT
          value: "8080"
        - name: TZ
          value: Europe/London # Change to your timezone
        - name: SQLITE_FILE_PATH
          value: /data/gladysassistant/gladys-production.db

Data on the device will be stored in the /data/gladysassistant/ directory. This will ensure that after updating the Gladys Assistant Docker image your configuration doesn’t disappear.

Getting public HTTPS URL to Gladys

To connect to Gladys you can either access it directly on http://:8080 or you can expose it to the internet by setting port 8080 in the device details and click on the public endpoint button:

device tunnel
device tunnel

After enabling, you should see your device URL in a format similar to https://xxx.synpse.cloud . Open it and complete the initial configuration steps (or restore it from the previous backup). Once done, you should have your username/password based authentication on the public URL:

Gladys login
Gladys login

SSH access

Through Synpse you can always using web interface to open an SSH terminal to your device. Use this when debugging any issues or downloading/uploading backups from your device:

SSH to Gladys device
SSH to Gladys device

Next steps

Try connecting Gladys to your local Hue bridge or deploy Node-RED next to the Gladys for additional low-code automation! We have a blog post on deploying Node-RED container as well here.