devices

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DbConnect

func DbConnect() (redis.Conn, error)

***************************************************************** Redis functions

func DbDel

func DbDel(key string) error

func DbGet

func DbGet(key string) (values string, err error)

func DbGetKeys

func DbGetKeys(key string) (keys []string, err error)

func DbHashGet

func DbHashGet(key string) (values []interface{}, err error)

func DbHashSet

func DbHashSet(key string, data interface{}) error

func DbSet

func DbSet(key string, value []byte) error

func GetAllDevicesFromDb

func GetAllDevicesFromDb() (devices []string, err error)

func HandleDetails

func HandleDetails(w http.ResponseWriter, r *http.Request)

func HandleScheduleDel

func HandleScheduleDel(w http.ResponseWriter, r *http.Request)

func HandleScheduleGet

func HandleScheduleGet(w http.ResponseWriter, r *http.Request)

func HandleScheduleSet

func HandleScheduleSet(w http.ResponseWriter, r *http.Request)

func HandleScheduleUpdate

func HandleScheduleUpdate(w http.ResponseWriter, r *http.Request)

func HandleStatus

func HandleStatus(w http.ResponseWriter, r *http.Request)

func LoadDevices

func LoadDevices() error

func ReturnBad

func ReturnBad(w http.ResponseWriter, r *http.Request)

func ReturnInternalError

func ReturnInternalError(w http.ResponseWriter, r *http.Request)

func ReturnOk

func ReturnOk(w http.ResponseWriter, r *http.Request, resp http.Response)

***************************************************************** Http Response helper functions

func ScheduleDel

func ScheduleDel(device string) error

func ScheduleSet

func ScheduleSet(s *Schedules, device string) error

***************************************************************** Scheduler functions

func ScheduleUpdate

func ScheduleUpdate(device string, status string) error

func UpdateStatus

func UpdateStatus(deviceName string, status bool) error

Types

type DeviceAction

type DeviceAction struct {
	Action bool `json:"action"`
}

type Devices

type Devices struct {
	Device       string `json:"device"`
	Type         string `json:"type"`
	Name         string `json:"name"`
	Addr         string `json:"address"`
	NameFriendly string `json:"name_friendly"`
	NetPort      string `json:"port"`
	Id           string `json:"id"`
	Key          string `json:"key"`
	Dps          string `json:"dps"`
}

func DetailsGet

func DetailsGet(device string) (Devices, error)

type Inputs

type Inputs struct {
	Database string `json:"database"`
	Devices  []Devices
}

func ReadDeviceFile

func ReadDeviceFile() (Inputs, error)

type Schedule

type Schedule struct {
	Day    string `json:"day"`
	Status string `json:"status"`
	Desc   string `json:"desc"`
	Action string `json:"action"`
	On     string `json:"on"`
	Off    string `json:"off"`
}

type Schedules

type Schedules struct {
	Status    string     `json:"status"`
	Schedules []Schedule `json:"schedules"`
}

func ScheduleGet

func ScheduleGet(devName string) (hasSchedule bool, schedules Schedules, error error)

type Status

type Status struct {
	Device string `json:"device"`
	Alive  bool   `json:"alive"`
	Url    string `json:"url"`
}

func StatusGet

func StatusGet(device string) (Status, error)

***************************************************************** General device functions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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