daikin

package module
v0.0.0-...-0d10d6d Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2016 License: MIT Imports: 17 Imported by: 0

README

Daikin AC - Golang API

Ported from https://bitbucket.org/JonathanGiles/jdaikin by NinjaBlocks.

WIP. This hasn't actually been tested with any actual hardware.

TODO:

  • There are other endpoints and data being ignored.
  • Is there any way to do discovery?
Getting started
ac := daikin.NewWirelessAC("192.168.0.100", time.Second*3)

If you don't actually have a Daikin air conditioner handy (what, you don't carry one with you?), you can fire up the very simple emulator.

emulator.StartWirelessAC(9999)
ac := daikin.NewWirelessAC("localhost:9999", time.Second*3)
Listening for state updates
go func() {
  for state := range ac.OnStateUpdate() {
    log.Printf("Inside temperature: %f. Target temperature %f.", state.InsideTemperature, state.TargetTemperature)
  }
}()
Controlling the AC
ac.ControlState().Power = daikin.PowerOn
ac.ControlState().Fan = daikin.FanAuto
ac.ControlState().FanDirection = daikin.FanDirectionHorizontal
ac.ControlState().Mode = daikin.ModeCool
ac.ControlState().TargetTemperature = 21

err := ac.SendState()
if err != nil {
  panic(err)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PowerOn  = Power{"On", "1"}
	PowerOff = Power{"Off", "0"}
)
View Source
var (
	FanAuto = Fan{"FAuto", "A"}
	FanF1   = Fan{"Fun1", "3"}
	FanF2   = Fan{"Fun2", "4"}
	FanF3   = Fan{"Fun3", "5"}
	FanF4   = Fan{"Fun4", "6"}
	FanF5   = Fan{"Fun5", "7"}
	FanNone = Fan{"FunNone", "B"}
)
View Source
var (
	FanDirectionOff                   = FanDirection{"Off", ""}
	FanDirectionNone                  = FanDirection{"None", "0"}
	FanDirectionVertical              = FanDirection{"Ud", "1"}
	FanDirectionHorizontal            = FanDirection{unsupported, "2"}
	FanDirectionVerticalAndHorizontal = FanDirection{unsupported, "3"}
)
View Source
var (
	// only these options are available for wireless daikins
	ModeAuto = Mode{"Auto", "0"}
	ModeDry  = Mode{"Dry", "2"}
	ModeCool = Mode{"Cool", "3"}
	ModeHeat = Mode{"Heat", "4"}
	ModeFan  = Mode{"Fan", "6"}

	// the non-wireless daikins also support the following:
	ModeOnlyFun = Mode{"OnlyFun", unsupported}
	ModeNight   = Mode{"Night", unsupported}
	ModeNone    = Mode{"None", ""}
)
View Source
var (
	TimerOffOff = Timer{"OFF/OFF", unsupported}
	TimerOnOff  = Timer{"ON/OFF", unsupported}
	TimerOffOn  = Timer{"OFF/ON", unsupported}
	TimerOnOn   = Timer{"ON/ON", unsupported}
	TimerNone   = Timer{"NONE", unsupported}
)

Functions

func Discover

func Discover(discoverInterval time.Duration) (chan AC, error)

func NewWirelessAC

func NewWirelessAC(host string) *wirelessAC

Types

type AC

type AC interface {
	AutoRefresh(interval time.Duration)
	BasicInfo() *BasicInfo
	RefreshBasicInfo() (*BasicInfo, error)
	SendState() error
	RefreshState() (*ControlState, *SensorState, error)
	ControlState() *ControlState
	SensorState() *SensorState
	OnStateUpdate() chan ACState
}

type ACState

type ACState struct {
	ControlState
	SensorState
}

type BasicInfo

type BasicInfo struct {
	Ret         string
	Type        string
	Reg         string
	Dst         int
	Ver         string
	Pow         int
	Err         int
	Location    int
	Name        string
	Icon        int
	Method      string
	Port        int
	Id          string
	Pw          string
	LpwFlag     int
	AdpKind     int
	Pv          int
	Cpv         int
	Led         int
	EnSetzone   int
	Mac         string
	AdpMode     string
	UDPAddress  net.UDPAddr
	HTTPAddress net.TCPAddr
}

type ControlState

type ControlState struct {
	Power             Power
	TargetTemperature float64
	TargetHumidity    int
	Mode              Mode
	Fan               Fan
	FanDirection      FanDirection
	Timer             Timer
}

func (*ControlState) GetWirelessValues

func (s *ControlState) GetWirelessValues() url.Values

func (*ControlState) ParseWirelessValues

func (s *ControlState) ParseWirelessValues(values url.Values) error

type Fan

type Fan command

type FanDirection

type FanDirection command

type Mode

type Mode command

type Power

type Power command

type SensorState

type SensorState struct {
	// sensor info
	InsideTemperature  float64
	InsideHumidity     int
	OutsideTemperature float64
}

func (*SensorState) GetWirelessValues

func (s *SensorState) GetWirelessValues() url.Values

func (*SensorState) ParseWirelessValues

func (s *SensorState) ParseWirelessValues(values url.Values)

type Timer

type Timer command

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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