smarthome

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

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

Go to latest
Published: Nov 8, 2019 License: MIT Imports: 14 Imported by: 0

README

smarthome

Smarthome API

go test -v --cover github.com/preimmortal/smarthome go test -v --cover github.com/preimmortal/smarthome -run Encrypt

docker build

docker build -t github.com/preimmortal/smarthome:latest .

docker run

docker run --network host github.com/preimmortal/smarthome:latest

TODO: BE: - Figure out how to organize my data models (i.e. DBDevice and Device should be the same model) - Data input and output should rely solely on this data model FE: - Set up docker for build/deployment

High Level:
    x CI/CD Pipeline

Backlog:
    - API calls for other devices

Documentation

Index

Constants

View Source
const (
	TPLINK_API_PORT      = "9999"
	TPLINK_API_PORT_INT  = 9999
	TPLINK_API_INFO      = "{\"system\":{\"get_sysinfo\":{}}}"
	TPLINK_API_RELAY_ON  = "{\"system\":{\"set_relay_state\":{\"state\":1}}}"
	TPLINK_API_RELAY_OFF = "{\"system\":{\"set_relay_state\":{\"state\":0}}}"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DBDevice

type DBDevice struct {
	Key   string
	Name  string
	Ip    string
	Alias string
	State string
}

type Database

type Database struct{}

func (*Database) HasIp

func (d *Database) HasIp(ip string) (bool, error)

func (*Database) Init

func (d *Database) Init() error

func (*Database) Insert

func (d *Database) Insert(key, name, ip, alias, state string) error

func (*Database) ReadAll

func (d *Database) ReadAll() (memdb.ResultIterator, error)

type Scan

type Scan struct {
	Db *Database
}

func (*Scan) FindFirstIP

func (s *Scan) FindFirstIP() (string, error)

func (*Scan) Scan

func (s *Scan) Scan(ip string) (*nmap.Run, error)

Scan implements a searcher for local network devices

func (*Scan) Start

func (s *Scan) Start(test bool) error
type Tplink struct{}

func (Tplink) Send

func (t Tplink) Send(ip, command string) ([]byte, error)

type TplinkInfo

type TplinkInfo struct {
	System struct {
		GetSysInfo struct {
			ErrorCode  int     `json:"err_code"`
			SwVersion  string  `json:"sw_ver"`
			HwVersion  string  `json:"hw_ver"`
			Type       string  `json:"type"`
			Model      string  `json:"model"`
			Mac        string  `json:"mac"`
			DeviceId   string  `json:"deviceId"`
			HwID       string  `json:"hwId"`
			FwID       string  `json:"fwId"`
			OemId      string  `json:"oemId"`
			Alias      string  `json:"alias"`
			DevName    string  `json:"dev_name"`
			IconHash   string  `json:"icon_hash"`
			RelayState int     `json:"relay_state"`
			OnTime     int     `json:"on_time"`
			ActiveMode string  `json:"active_mode"`
			Feature    string  `json:"feature"`
			Updating   int     `json:"updating"`
			Rssi       int     `json:"rssi"`
			LedOff     int     `json:"led_off"`
			Latitude   float32 `json:"latitude"`
			Longitude  float32 `json:"longitude"`
		} `json:"get_sysinfo"`
	} `json:"system"`
}

Directories

Path Synopsis
cmd
smarthome command

Jump to

Keyboard shortcuts

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