relays

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2024 License: BSD-3-Clause Imports: 7 Imported by: 1

README

Relays Device

Relays device controls 1-4 relays using a microcontroller or SBC, such as Rapsberry Pi.

Running

There are two ways to run a relays device: standalone or in a hub. For standalone, a Docker container can run the device. Or we can run the device directly from source.

See Running on Hub for running the device on a hub.

Run Standalone on Docker

The easiest way to run a relays device is using a pre-built docker image:

docker pull ghcr.io/merliot/relays
docker run -p 8000:8000 ghcr.io/merliot/relays

Now the device is now running in a docker container as a web server, listening on port :8000.

Browse to http://<host>:8000 to view and setup the device.

If the docker host is using https://, pass in the environment variable WS_SCHEME=wss://.

docker run -e "WS_SCHEME=wss://" -p 8000:8000 ghcr.io/merliot/relays

See full list of environment variables.

I don't have Docker

If you don't have a host to run docker, try Koyeb to cloud-host your relays container. The first container is free (account required). Click the deploy button to get started.

Deploy to Koyeb

Of course, any container hosting service will do. Just use the Run on Docker instructions above.

I don't want to use Docker

Ok, you can run the relays device directly from source.

git clone https://github.com/merliot/relays.git
cd relays
PORT_PRIME=8000 go run -tags prime ./cmd

Browse to http://localhost:8000 to view and deploy device.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(id, model, name string) dean.Thinger

Types

type MsgClick

type MsgClick struct {
	dean.ThingMsg
	Relay int
	State bool
}

type Relays

type Relays struct {
	*device.Device
	Relays []relay.Relay
}

func (*Relays) ServeHTTP

func (r *Relays) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Relays) Setup

func (r *Relays) Setup()

func (*Relays) Subscribers

func (r *Relays) Subscribers() dean.Subscribers

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL