smartswitch

package module
v0.0.0-...-d6e8b66 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2018 License: Apache-2.0 Imports: 14 Imported by: 1

README

smartswitch

Package that provides a simple interface for any go app to emulate a Belkin Wemo switch. I built this to use in my garagedoor project, so that my Alexa devices could control my garage door over it's LAN-only API.

Usage

Basic example of package usage can be found in the example application.(https://github.com/forfuncsake/smartswitch/tree/master/cmd/example).

Documentation

godoc can be found here: https://godoc.org/github.com/forfuncsake/smartswitch

Contributions

Feedback, Issues and PRs are all welcome!

Build Status Go Report Card

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

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

A Controller manages SSDP advertisement and client interactions for a Switch

func NewController

func NewController(name string, s Switch, opts ...ControllerOption) *Controller

NewController creates a smart switch controller with the specified options

func (*Controller) Start

func (c *Controller) Start() (location string, err error)

Start will create and serve an HTTP service to manage a smart switch and advertise the service using SSDP

func (*Controller) Stop

func (c *Controller) Stop() error

Stop will close the HTTP server and stop advertising over SSDP

type ControllerOption

type ControllerOption func(*Controller)

ControllerOption values are accepted by NewController for custom configurations

func WithInterface

func WithInterface(name string) ControllerOption

WithInterface allows the caller to specify a network interface to use for the Controller. The Controller will advertise services on the first IPv4 address of this interface

func WithListenAddress

func WithListenAddress(addr net.IP) ControllerOption

WithListenAddress allows the caller to specify a single listen address for the controller to use (default is all IP addresses)

func WithListenPort

func WithListenPort(p uint) ControllerOption

WithListenPort allows the caller to specify a strict TCP port to use for services provided by the Controller (default is system-assigned ephemeral port)

func WithMinissdpSocket

func WithMinissdpSocket(path string) ControllerOption

WithMinissdpSocket is used to configure the controller to advertise via the Minissdpd service instead of starting an SSDP server (for Synology device support)

func WithURIPrefix

func WithURIPrefix(s string) ControllerOption

WithURIPrefix allows the caller to configure a path prefix for the Wemo control URIs

func WithUUID

func WithUUID(s string) ControllerOption

WithUUID allows the caller to specify a UUID value for the emulated switch (default: generated ID)

type Switch

type Switch interface {
	Status() (bool, error)
	Set(bool) error
}

The Switch interface must be implemented by the device that you wish to control with Wemo clients

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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