gogadgets

package module
v0.0.0-...-3d78e4b Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 24 Imported by: 3

README

GoGadgets

Gadgets

A gogadgets app consists of a collection of gadgets. Most gadgets control a physical device (led, thermometer, motion sensor, electric motor, etc). The gogadgets includes 5 built in gadgets::

GPIO

This gadget is used to turn things on and off.

Switch

Switch is really a GPIO that has been configured as input. It is used to wait for some input device (push button, motion sensor, etc) to change state. When the state of the input device changes then the rest of the system receives a message for that state change. All gadgets, whether input gadgets or output gadgets, received these messages and can therefore react to changes in other parts of the system.

Thermometer

The 'extras' directory includes a compiled dts file (BB-W1-00A0.dtbo) for dallas one-wire devices. If you load it into the beaglebone's device tree overlay then you can connect a dallas 1-wire temperature sensor to it and include the thermometer in your gadgets system.

Heater

Use this gadget to heat things up. When you heat something up with Heater it listens for temperature updates and turns itself off when the desired temperature has been reached. You must have a thermometer in your system to use this.

Cooler
Motor
Recorder

This gadget doesn't actually control hardware. It receives all the update messages from the rest of the system and pushes them to a MongoDB (which should really be hosted on a server somewhere on your sub-net).

Installation

Gogadgets

Try out one of the examples

The config file for the led example looks like::

{
    "host": "http://<IP ADDR>:6111",
    "gadgets": [
        {
            "location": "lab",
            "name": "led",
            "pin": {
                "type": "gpio",
                "port": "8",
                "pin": "9",
            }
        }
    ]
}

So to try this example out you would connect an led to port 8, pin 9. Next, start the app::

# $GOPATH/bin/gogadgets run -c /path/to/config.json

Next you can turn on the led from the command line. You can either ssh into the same beaglebone that is running gogagdgets, or you can install gadgets again on another machine. If you were to install gogadgets on a remote machine then you can turn on the led like this::

$ $GOPATH/bin/gogadgets cmd "turn on lab led"

Robot Command Language

All Gadgets in the system respond to Robot Command Language (RCL) messages. A RCL command is a string consisting of::

  <action> <location> <device name> <for|to> <command argument> <units>

So, for example::

turn on living room light
turn on living room light for 30 minutes
heat boiler to 22 C

Methods

A Method is a sequence of RCL messages. Let's say you had a gadgets system like this::

{
    "gadgets": [
        {
            "location": "lab",
            "name": "led",
            "pin": {
                "type": "gpio",
                "port": "8",
                "pin": "9",
            }
        },
        {
            "location": "lab",
            "name": "motion sensor",
            "pin": {
                "type": "switch",
                "port": "8",
                "pin": "11",
            }
        }
    ]
}

Documentation

Index

Constants

View Source
const (
	NANO = 1000000000.0
)
View Source
const (
	Version = "0.0.3"
)

Variables

View Source
var (
	COMMAND      = "command"
	ERROR        = "error"
	METHOD       = "method"
	DONE         = "done"
	UPDATE       = "update"
	GADGET       = "gadget"
	STATUS       = "status"
	METHODUPDATE = "method update"
)
View Source
var (
	GPIO_DEV_PATH = "/sys/class/gpio"
	GPIO_DEV_MODE = os.ModeDevice
)
View Source
var (
	Pins = map[string]map[string]map[string]string{
		"gpio": map[string]map[string]string{
			"8": map[string]string{
				"7":  "66",
				"8":  "67",
				"9":  "69",
				"10": "68",
				"11": "45",
				"12": "44",
				"14": "26",
				"15": "47",
				"16": "46",
				"26": "61",
			},
			"9": map[string]string{
				"12": "60",
				"14": "50",
				"15": "48",
				"16": "51",
			},
		},
		"pwm": map[string]map[string]string{
			"8": map[string]string{
				"13": "bone_pwm_p8_13",
				"19": "bone_pwm_p8_19",
			},
			"9": map[string]string{
				"14": "bone_pwm_p9_14",
				"16": "bone_pwm_p9_16",
				"21": "bone_pwm_p9_21",
				"22": "bone_pwm_p9_22",
			},
		},
	}
	PiPins = map[string]string{
		"7":  "4",
		"11": "17",
		"12": "18",
		"13": "27",
		"15": "22",
		"16": "23",
		"18": "24",
		"22": "25",
		"29": "5",
		"31": "6",
		"32": "12",
		"33": "13",
		"35": "19",
		"36": "16",
		"37": "26",
		"38": "20",
		"40": "21",
	}
)

The beaglebone black GPIO pins that are available by default. You can use the device tree overlay to get more.

View Source
var (
	PWMMode     = os.ModeDevice
	PWM_DEVPATH = "/sys/devices/ocp.*/pwm_test_P%s_%s.*"
	TREEPATH    = "/sys/devices/bone_capemgr.*/slots"
)

Functions

func CronAfter

func CronAfter(a Afterer) func(*Cron) error

func CronJobs

func CronJobs(j []string) func(*Cron) error

func CronSleep

func CronSleep(d time.Duration) func(*Cron) error

func FileExists

func FileExists(path string) bool

FileExists tells you if the file exists.

func GetUUID

func GetUUID() string

GetUUID generates a random UUID according to RFC 4122

func ParseCommand

func ParseCommand(cmd string) (float64, string, error)

func RegisterInput

func RegisterInput(name string, f CreateInputDevice)

func RegisterOutput

func RegisterOutput(name string, f CreateOutputDevice)

func XBeeSerialPort

func XBeeSerialPort(p serial.Port) func(InputDevice) error

Types

type Afterer

type Afterer func(d time.Duration) <-chan time.Time

type Alarm

type Alarm struct {
	// contains filtered or unexported fields
}

Alarm (when 'on') turns on its output devices when any of the events defined in pin.Args.Events happens. It turns off after:

1: alarm.duration has passed
2: the alarm is turned off

func (*Alarm) Commands

func (a *Alarm) Commands(location, name string) *Commands

func (*Alarm) Off

func (a *Alarm) Off() error

func (*Alarm) On

func (a *Alarm) On(val *Value) error

func (*Alarm) Status

func (a *Alarm) Status() map[string]bool

func (*Alarm) Update

func (a *Alarm) Update(msg *Message) bool

type App

type App struct {
	// contains filtered or unexported fields
}

App holds all the gadgets and handles passing Messages to them, and receiving Messages from them. It is the central part of Gadgets system.

func New

func New(cfg interface{}, gadgets ...Gadgeter) *App

New creates a new Gadgets system. The cfg argument can be a path to a json file or a Config object itself.

func (*App) GoStart

func (a *App) GoStart(input <-chan Message)

GoStart enables a gadgets system to be started by either a test suite that needs it to run as a goroutine or a client app that starts gogadget systems upon a command from a central web app.

func (*App) Start

func (a *App) Start()

Start is the main entry point for a Gadget system. It takes a chan in case the system is started as a goroutine, but it can just be called directly.

type Boiler

type Boiler struct {
	// contains filtered or unexported fields
}

Configure a boiler like:

{
    "host": "http://192.168.1.30:6111",
    "gadgets": [
        {
            "location": "the lab",
            "name": "temperature",
            "pin": {
                "type": "thermometer",
                "OneWireId": "28-0000041cb544",
                "Units": "F"
            }
        },
        {
            "location": "the lab",
            "name": "heater",
            "pin": {
                "type": "boiler",
                "port": "8",
                "pin": "11",
                "args": {
                    "type": "heater",
                    "sensor": "the lab temperature",
                    "high": 150.0,
                    "low": 120.0
                }
            }
        }
    ]
}

With this config the boiler will react to temperatures from 'the lab temperature' (which is the location + name of the thermometer) and turn on the gpio if the temperature is > 120.0, turn and turn it off when the temperature > 150.0.

If you set args.type = "cooler" then it will start cooling when the temperature gets above 150, and stop cooling when the temperature gets below 120.

func (*Boiler) Commands

func (b *Boiler) Commands(location, name string) *Commands

func (*Boiler) Off

func (b *Boiler) Off() error

func (*Boiler) On

func (b *Boiler) On(val *Value) error

func (*Boiler) Status

func (b *Boiler) Status() map[string]bool

func (*Boiler) Update

func (b *Boiler) Update(msg *Message) bool

type Broker

type Broker struct {
	// contains filtered or unexported fields
}

All the gadgets of the system push their messages here.

func NewBroker

func NewBroker(channels map[string]chan Message, input <-chan Message, collect <-chan Message) *Broker

func (*Broker) Start

func (b *Broker) Start()

type Commands

type Commands struct {
	On  []string
	Off []string
}

type Comparitor

type Comparitor func(msg *Message) bool

type Config

type Config struct {
	Master  string         `json:"master,omitempty"`
	Host    string         `json:"host,omitempty"`
	Port    int            `json:"port,omitempty"`
	Gadgets []GadgetConfig `json:"gadgets,omitempty"`
}

func GetConfig

func GetConfig(config interface{}) *Config

func (Config) CreateGadgets

func (c Config) CreateGadgets(gadgets ...Gadgeter) []Gadgeter

type Cooler

type Cooler struct {
	// contains filtered or unexported fields
}

func (*Cooler) Commands

func (c *Cooler) Commands(location, name string) *Commands

func (*Cooler) Off

func (c *Cooler) Off() error

func (*Cooler) On

func (c *Cooler) On(val *Value) error

func (*Cooler) Status

func (c *Cooler) Status() map[string]bool

func (*Cooler) Update

func (c *Cooler) Update(msg *Message) bool

type CreateInputDevice

type CreateInputDevice func(pin *Pin, opts ...func(InputDevice) error) (InputDevice, error)

type CreateOutputDevice

type CreateOutputDevice func(pin *Pin) (OutputDevice, error)

type Cron

type Cron struct {
	// contains filtered or unexported fields
}

func NewCron

func NewCron(config *GadgetConfig, options ...func(*Cron) error) (*Cron, error)

func (*Cron) GetDirection

func (c *Cron) GetDirection() string

func (*Cron) GetUID

func (c *Cron) GetUID() string

func (*Cron) Start

func (c *Cron) Start(in <-chan Message, out chan<- Message)

type File

type File struct {
	// contains filtered or unexported fields
}

File is a way to a debug gadgets system. Doesn't really do anything.

func (*File) Commands

func (f *File) Commands(location, name string) *Commands

func (*File) Off

func (f *File) Off() error

func (*File) On

func (f *File) On(val *Value) error

func (*File) Status

func (f *File) Status() map[string]bool

func (*File) Update

func (f *File) Update(msg *Message) bool

type FlowMeter

type FlowMeter struct {
	GPIO Poller

	//Value represents the total volume represented by
	//a pulse (rate is calculated from this total volume).
	Value float64

	//min_span is the minimum number of seconds between
	//2 pulses from the physical flow meter.  It is used
	//for de-bouncing the signal.
	MinSpan float64
	Units   string
	// contains filtered or unexported fields
}

FlowMeter waits for a high pulse from a gpio pin then caclulates the flow based on the time between high pulses.

func (*FlowMeter) GetValue

func (f *FlowMeter) GetValue() *Value

func (*FlowMeter) SendValue

func (f *FlowMeter) SendValue()

func (*FlowMeter) Start

func (f *FlowMeter) Start(in <-chan Message, out chan<- Value)

type GPIO

type GPIO struct {
	// contains filtered or unexported fields
}

GPIO interacts with the linux sysfs interface for GPIO to turn pins on and off. The pins that are listed in gogadgets.Pins have been found to be availabe by default but by using the device tree overlay you can make more pins available. GPIO also has a Wait method and can poll a pin and wait for a change of direction.

func (*GPIO) Commands

func (g *GPIO) Commands(location, name string) *Commands

func (*GPIO) Init

func (g *GPIO) Init() error

func (*GPIO) Off

func (g *GPIO) Off() error

func (*GPIO) On

func (g *GPIO) On(val *Value) error

func (*GPIO) Status

func (g *GPIO) Status() map[string]bool

func (*GPIO) Update

func (g *GPIO) Update(msg *Message) bool

func (*GPIO) Wait

func (g *GPIO) Wait() error

type Gadget

type Gadget struct {
	Type        string
	Location    string
	Name        string
	Output      OutputDevice
	Input       InputDevice
	Direction   string
	OnCommands  []string
	OffCommands []string

	InitialValue string

	UID string

	Operator string
	// contains filtered or unexported fields
}

Each part of a Gadgets system that controls a single piece of hardware (for example: a gpio pin) is represented by Gadget. A Gadget must have either an InputDevice or an OutputDevice. Gadget fulfills the GoGaget interface.

func (*Gadget) GetDirection

func (g *Gadget) GetDirection() string

func (*Gadget) GetUID

func (g *Gadget) GetUID() string

func (*Gadget) Start

func (g *Gadget) Start(in <-chan Message, out chan<- Message)

Start is one of the two interface methods of GoGadget. Start takes in in and out chan and is meant to be called as a goroutine.

type GadgetConfig

type GadgetConfig struct {
	Type         string                 `json:"type,omitempty"`
	Location     string                 `json:"location,omitempty"`
	Name         string                 `json:"name,omitempty"`
	OnCommands   []string               `json:"on_commands,omitempty"`
	OffCommands  []string               `json:"off_commands,omitempty"`
	OnValue      string                 `json:"on_value,omitempty"`
	OffValue     string                 `json:"off_value,omitempty"`
	InitialValue string                 `json:"initial_value,omitempty"`
	Pin          Pin                    `json:"pin,omitempty"`
	Args         map[string]interface{} `json:"args,omitempty"`
}

type Gadgeter

type Gadgeter interface {
	GetUID() string
	GetDirection() string
	Start(in <-chan Message, out chan<- Message)
}

func NewGadget

func NewGadget(config *GadgetConfig) (Gadgeter, error)

NewGadget returns a gadget with an input or output device There are several types of Input/Output devices build into GoGadgets (eg: header, cooler, gpio, thermometer and switch) NewGadget reads a GadgetConfig and creates the correct type of Gadget.

type GoGadgeter

type GoGadgeter interface {
	GetUID() string
	Start(input <-chan Message, output chan<- Message)
}

type Heater

type Heater struct {
	// contains filtered or unexported fields
}

Heater represents an electic heating element. It provides a way to heat up something to a target temperature. In order to use this there must be a thermometer in the same Location.

func (*Heater) Commands

func (h *Heater) Commands(location, name string) *Commands

func (*Heater) Off

func (h *Heater) Off() error

func (*Heater) On

func (h *Heater) On(val *Value) error

func (*Heater) Status

func (h *Heater) Status() map[string]bool

func (*Heater) Update

func (h *Heater) Update(msg *Message) bool

type Info

type Info struct {
	Direction string   `json:"direction,omitempty"`
	Type      string   `json:"type,omitempty"`
	On        []string `json:"on,omitempty"`
	Off       []string `json:"off,omitempty"`
}

type InputDevice

type InputDevice interface {
	Start(<-chan Message, chan<- Value)
	GetValue() *Value
}

Inputdevices are started as goroutines by the Gadget that contains it.

func NewFlowMeter

func NewFlowMeter(pin *Pin, opts ...func(InputDevice) error) (InputDevice, error)

func NewInputDevice

func NewInputDevice(pin *Pin) (dev InputDevice, err error)

func NewSwitch

func NewSwitch(pin *Pin, opts ...func(InputDevice) error) (InputDevice, error)

func NewThermometer

func NewThermometer(pin *Pin, opts ...func(InputDevice) error) (InputDevice, error)

func NewXBee

func NewXBee(pin *Pin, opts ...func(InputDevice) error) (InputDevice, error)

type Message

type Message struct {
	UUID        string    `json:"uuid"`
	From        string    `json:"from,omitempty"`
	Name        string    `json:"name,omitempty"`
	Location    string    `json:"location,omitempty"`
	Type        string    `json:"type,omitempty"`
	Sender      string    `json:"sender,omitempty"`
	Target      string    `json:"target,omitempty"`
	Body        string    `json:"body,omitempty"`
	Host        string    `json:"host,omitempty"`
	Method      Method    `json:"method,omitempty"`
	Timestamp   time.Time `json:"timestamp,omitempty"`
	Value       Value     `json:"value,omitempty"`
	TargetValue *Value    `json:"target_value,omitempty"`
	Info        Info      `json:"info,omitempty"`
	Config      Config    `json:"config,omitempty"`
}

Message is what all Gadgets pass around to each other.

type Method

type Method struct {
	Step  int      `json:"step,omitempty"`
	Steps []string `json:"steps,omitempty"`
	Time  int      `json:"time,omitempty"`
}

type MethodRunner

type MethodRunner struct {
	// contains filtered or unexported fields
}

Gadgets respond to the Robot Command Language (RCL) and a list of RCL messages can be run to form a method. Runner takes a method as input and runs it.

If a RCL message starts with 'wait' runner pauses the method and waits for the condition if the wait to be fulfilled. For example, if the RCL message

'wait for 5 seconds'

is recieved, Runner waits for 5 seconds and continues with the the rest of the message.

Another example would be

'wait for boiler temperature >= 200 F'.

MethodRunner would then wait for a message from the boiler that says its temperature is 200 F (or more). It then sends the next message of the method

func (*MethodRunner) GetDirection

func (m *MethodRunner) GetDirection() string

func (*MethodRunner) GetUID

func (m *MethodRunner) GetUID() string

func (*MethodRunner) Start

func (m *MethodRunner) Start(in <-chan Message, out chan<- Message)

type Motor

type Motor struct {
	// contains filtered or unexported fields
}

Motor controls a http://www.pololu.com/product/1451 motor driver carrier.

   |					 |
   |					 |
   | O O O O O O O O O O |
   --|--------------------
   	 |
	 |
   	 |
   	 |
   	===

func (*Motor) Commands

func (m *Motor) Commands(location, name string) *Commands

func (*Motor) Off

func (m *Motor) Off() error

func (*Motor) On

func (m *Motor) On(val *Value) error

func (*Motor) Status

func (m *Motor) Status() map[string]bool

func (*Motor) Update

func (m *Motor) Update(msg *Message) bool

type OutputDevice

type OutputDevice interface {
	On(val *Value) error
	Off() error
	Update(msg *Message) bool
	Status() map[string]bool
	Commands(string, string) *Commands
}

OutputDevice turns things on and off. Currently the

func NewAlarm

func NewAlarm(pin *Pin) (OutputDevice, error)

func NewBoiler

func NewBoiler(pin *Pin) (OutputDevice, error)

func NewCooler

func NewCooler(pin *Pin) (OutputDevice, error)

func NewFile

func NewFile(pin *Pin) (OutputDevice, error)

func NewGPIO

func NewGPIO(pin *Pin) (OutputDevice, error)

func NewHeater

func NewHeater(pin *Pin) (OutputDevice, error)

func NewMotor

func NewMotor(pin *Pin) (OutputDevice, error)

func NewOutputDevice

func NewOutputDevice(pin *Pin) (dev OutputDevice, err error)

func NewPWM

func NewPWM(pin *Pin) (OutputDevice, error)

func NewRecorder

func NewRecorder(pin *Pin) (OutputDevice, error)

func NewSMS

func NewSMS(pin *Pin) (OutputDevice, error)

func NewThermostat

func NewThermostat(pin *Pin) (OutputDevice, error)

type PWM

type PWM struct {
	// contains filtered or unexported fields
}

echo am33xx_pwm > /sys/devices/bone_capemgr.9/slots echo bone_pwm_P8_13 > /sys/devices/bone_capemgr.9/slots /sys/devices/ocp.3/pwm_test_P8_13.15

func (*PWM) Commands

func (p *PWM) Commands(location, name string) *Commands

func (*PWM) Off

func (p *PWM) Off() error

func (*PWM) On

func (p *PWM) On(val *Value) error

func (*PWM) Status

func (p *PWM) Status() map[string]bool

func (*PWM) Update

func (p *PWM) Update(msg *Message) bool

type Pin

type Pin struct {
	Type        string        `json:"type,omitempty"`
	Port        string        `json:"port,omitempty"`
	Pin         string        `json:"pin,omitempty"`
	Direction   string        `json:"direction,omitempty"`
	Edge        string        `json:"edge,omitempty"`
	ActiveLow   string        `json:"active_low,omitempty"`
	OneWirePath string        `json:"onewire_path,omitempty"`
	OneWireId   string        `json:"onewire_id,omitempty"`
	Sleep       time.Duration `json:"sleep,omitempty"`
	Value       interface{}   `json:"value,omitempty"`
	Units       string        `json:"units,omitempty"`
	//Platform is either "rpi" or "beaglebone"
	Platform  string                 `json:"platform,omitempty"`
	Frequency int                    `json:"frequency,omitempty"`
	Args      map[string]interface{} `json:"args,omitempty"`
	Pins      map[string]Pin         `json:"pins,omitempty"`
	Lock      *sync.Mutex            `json:"-"`
	// contains filtered or unexported fields
}

type Poller

type Poller interface {
	Wait() error
	Status() map[string]bool
}

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

All of the gadgets in a gadgets app push their messages through a single channel. This queue guarantees that all gadgets with be able to send their message without being blocked.

func NewQueue

func NewQueue() *Queue

func (*Queue) Get

func (q *Queue) Get() *Message

func (*Queue) Len

func (q *Queue) Len() int

func (*Queue) Lock

func (q *Queue) Lock()

func (*Queue) Push

func (q *Queue) Push(item *Message)

func (*Queue) Unlock

func (q *Queue) Unlock()

func (*Queue) Wait

func (q *Queue) Wait()

One goroutine pushes the incoming messages to this queue, and another goroutine grabs messages from the queue and pushes them back out to the system. This method adds synchronization so that when the queue is empty the second goroutine is blocked until a message is pushed to the queue.

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

Recorder takes all the update messages it receives and saves them by posting to quimby

func (*Recorder) Commands

func (r *Recorder) Commands(location, name string) *Commands

func (*Recorder) Off

func (r *Recorder) Off() error

func (*Recorder) On

func (r *Recorder) On(val *Value) error

func (*Recorder) Status

func (r *Recorder) Status() map[string]bool

func (*Recorder) Update

func (r *Recorder) Update(msg *Message) bool

type SMS

type SMS struct {
	// contains filtered or unexported fields
}

func (*SMS) Commands

func (s *SMS) Commands(location, name string) *Commands

func (*SMS) Off

func (s *SMS) Off() error

func (*SMS) On

func (s *SMS) On(val *Value) error

func (*SMS) Status

func (s *SMS) Status() map[string]bool

func (*SMS) Update

func (s *SMS) Update(msg *Message) bool

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(host, master string, port int) *Server

func (*Server) GetDirection

func (s *Server) GetDirection() string

func (*Server) GetUID

func (s *Server) GetUID() string

func (*Server) Start

func (s *Server) Start(i <-chan Message, o chan<- Message)

type Switch

type Switch struct {
	GPIO  Poller
	Value bool
	Units string
	// contains filtered or unexported fields
}

Switch is an input device that waits for a GPIO pin to change value (1 to 0 or 0 to 1). When that change happens it sends an update to the rest of the system.

func (*Switch) GetValue

func (s *Switch) GetValue() *Value

func (*Switch) SendValue

func (s *Switch) SendValue()

func (*Switch) Start

func (s *Switch) Start(in <-chan Message, out chan<- Value)

type Thermometer

type Thermometer struct {
	// contains filtered or unexported fields
}

func (*Thermometer) GetValue

func (t *Thermometer) GetValue() *Value

func (*Thermometer) Start

func (t *Thermometer) Start(in <-chan Message, out chan<- Value)

This is an InputDevice, so it must have a Start.

type Thermostat

type Thermostat struct {
	// contains filtered or unexported fields
}

Thermostat is used for controlling a furnace. Configure a thermostat like:

	{
	    "host": "http://192.168.1.18:6111",
	    "gadgets": [
	        {
	            "location": "home",
	            "name": "temperature",
	            "pin": {
	                "type": "thermometer",
	                "OneWireId": "28-0000041cb544",
	                "Units": "F"
	            }
	        },
	        {
	            "location": "home",
	            "name": "furnace",
	            "pin": {
	                "type": "thermostat",
                    "pins": {
                        "heat": {
                            "platform": "rpi",
	                        "pin": "11",
                            "direction": "out"
                        },
                        "cool": {
                            "platform": "rpi",
	                        "pin": "13",
                            "direction": "out"
                        },
                        "fan": {
                            "platform": "rpi",
	                        "pin": "15",
                            "direction": "out"
                        }
                    },
	                "args": {
	                    "sensor": "home temperature",
                        "timeout": "5m"
	                }
	            }
	        }
	    ]
	}

With this config the thermostat will react to temperatures from 'the lab temperature' (which is the location + name of the thermometer) and turn on the gpio if the temperature is > 120.0, turn and turn it off when the temperature > 150.0.

If you set args.type = "cooler" then it will start cooling when the temperature gets above 150, and stop cooling when the temperature gets below 120.

func (*Thermostat) Commands

func (t *Thermostat) Commands(location, name string) *Commands

func (*Thermostat) Off

func (t *Thermostat) Off() error

func (*Thermostat) On

func (t *Thermostat) On(val *Value) error

func (*Thermostat) Status

func (t *Thermostat) Status() map[string]bool

func (*Thermostat) Update

func (t *Thermostat) Update(msg *Message) bool

type Value

type Value struct {
	Value  interface{}     `json:"value,omitempty"`
	Units  string          `json:"units,omitempty"`
	Output map[string]bool `json:"io,omitempty"`
	ID     string          `json:"id,omitempty"`
	Cmd    string          `json:"command,omitempty"`
	// contains filtered or unexported fields
}

func (*Value) GetName

func (v *Value) GetName() string

func (*Value) ToFloat

func (v *Value) ToFloat() (f float64, ok bool)

type XBee

type XBee struct {
	// contains filtered or unexported fields
}

func (*XBee) GetValue

func (x *XBee) GetValue() *Value

func (*XBee) Start

func (x *XBee) Start(ch <-chan Message, val chan<- Value)

type XBeeConfig

type XBeeConfig struct {
	//           pin    type
	ADC map[string]string `json:"adc"`
	//           pin    name
	DIO      map[string]string `json:"dio"`
	Location string            `json:"location"`
}

Directories

Path Synopsis
cmd
examples
lib

Jump to

Keyboard shortcuts

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