ui

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const INTERVAL = 1

Variables

View Source
var (
	UI     *ui
	Client *natureremo.Client
)
View Source
var Dispatcher = &dispatcher{
	state: &State{},
}
View Source
var (
	IndexOutOfAppliances = errors.New("index out of appliances")
)

Functions

func ActionAppliancesPower

func ActionAppliancesPower(state *State, cli *natureremo.Client, ctx interface{}) error

func ActionGetAppliances

func ActionGetAppliances(state *State, cli *natureremo.Client, ctx interface{}) error

func ActionGetDevices

func ActionGetDevices(state *State, cli *natureremo.Client, ctx interface{}) error

func ActionOpenUpdateApplianceView

func ActionOpenUpdateApplianceView(state *State, cli *natureremo.Client, ctx interface{}) error

func ActionSendSignal

func ActionSendSignal(state *State, cli *natureremo.Client, ctx interface{}) error

func ActionSendTVButton

func ActionSendTVButton(state *State, cli *natureremo.Client, ctx interface{}) error

func ActionUpdateAirConSettings

func ActionUpdateAirConSettings(state *State, cli *natureremo.Client, ctx interface{}) error

func ActionUpdateLight

func ActionUpdateLight(state *State, cli *natureremo.Client, ctx interface{}) error

func ActionUpdateSelectIdx added in v0.0.2

func ActionUpdateSelectIdx(state *State, cli *natureremo.Client, ctx interface{}) error

func Start

func Start()

Types

type Action

type Action func(state *State, cli *natureremo.Client, ctx interface{}) error

type AppliancePowerOnOff

type AppliancePowerOnOff struct {
	Power natureremo.Button
	Row   int
}

type Appliances

type Appliances struct {
	*tview.Table
	// contains filtered or unexported fields
}

func NewAppliances

func NewAppliances() *Appliances

func (*Appliances) GetSelect

func (a *Appliances) GetSelect() int

func (*Appliances) OpenUpdateAirConView

func (a *Appliances) OpenUpdateAirConView(app *natureremo.Appliance)

func (*Appliances) OpenUpdateIRView

func (a *Appliances) OpenUpdateIRView(app *natureremo.Appliance)

func (*Appliances) OpenUpdateLightView

func (a *Appliances) OpenUpdateLightView(app *natureremo.Appliance)

func (*Appliances) OpenUpdateTVView

func (a *Appliances) OpenUpdateTVView(app *natureremo.Appliance)

func (*Appliances) UpdateView

func (a *Appliances) UpdateView(apps []*natureremo.Appliance)

type Context

type Context struct {
	Event Event
	Data  interface{}
}

type Devices

type Devices struct {
	*tview.Table
	// contains filtered or unexported fields
}

func NewDevices

func NewDevices() *Devices

func (*Devices) UpdateView

func (d *Devices) UpdateView(devices []*natureremo.Device)

type Event

type Event struct {
	Device  string
	Type    string
	Value   string
	Created time.Time
}

type Events

type Events struct {
	*tview.Table
	// contains filtered or unexported fields
}

func NewEvents

func NewEvents() *Events

func (*Events) UpdateView

func (e *Events) UpdateView(events []Event)
type Header struct {
	*tview.TextView
}

func NewHeader

func NewHeader() *Header

type LightSetting

type LightSetting struct {
	ID    string // appliance id
	Type  string // button or signal
	Value string // button name or signal id
}

type State

type State struct {
	SelectApplianceIdx int
	Devices            []*natureremo.Device
	Appliances         []*natureremo.Appliance
	Events             []Event
}

func (*State) PushEvent

func (s *State) PushEvent(ev Event)

func (*State) SelectAppliance added in v0.0.2

func (s *State) SelectAppliance() (*natureremo.Appliance, error)

func (*State) String

func (s *State) String() string

func (*State) UpdateAppliances

func (s *State) UpdateAppliances()

func (*State) UpdateDevices

func (s *State) UpdateDevices()

func (*State) UpdateEvents

func (s *State) UpdateEvents()

type TVSetting

type TVSetting struct {
	ID     string // appliance id
	Button string // TV button
}

type UpdateAirConFormData

type UpdateAirConFormData struct {
	Power     UpdateAirConFormItem
	Mode      UpdateAirConFormItem
	Temp      UpdateAirConFormItem
	Volume    UpdateAirConFormItem
	Direction UpdateAirConFormItem
}

func ToUpdateAirConViewData

func ToUpdateAirConViewData(app *natureremo.Appliance) UpdateAirConFormData

func (UpdateAirConFormData) String

func (u UpdateAirConFormData) String() string

type UpdateAirConFormItem

type UpdateAirConFormItem struct {
	Current int
	Values  []string
}

func (UpdateAirConFormItem) Value

func (u UpdateAirConFormItem) Value() string

Jump to

Keyboard shortcuts

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