daikin

package module
v0.0.0-...-3f7a3f2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2019 License: MIT Imports: 10 Imported by: 1

README

go-daikin - Daikin AirCon controller

This package provides an API for probing and controlling Daikin split systems fitted with a Wifi controller module.

This package is tested against the BRP072A42 interface.

Features

  • Discover devices on the local network
  • Query and set current operating parameters
  • Query current sensor values

Basic usage

Querying status for discovered devices:

package main

import (
  "fmt"

  "github.com/buxtronix/go-daikin"
  "github.com/golang/glog"
)

func main() {
  d, err := daikin.NewNetwork()
  if err != nil {
    glog.Exit(err)
  }
  if err := d.Discover(); err != nil {
    glog.Exit(err)
  }

  for addr, dev := range d.Devices {
    if err := dev.GetControlInfo(); err != nil {
      glog.Error(err)
      continue
    }
    if err := dev.GetSensorInfo(); err != nil {
      glog.Error(err)
      continue
    }
    fmt.Printf("%s:\n%s", addr, dev.String())
  }
}

Set state for a specific device:

package main

import(
  "flag"
  "fmt"

  "github.com/golang/glog"
  daikin "github.com/buxtronix/go-daikin"
)

var (
  address = flag.String("address", "", "Address of daikin unit")
)

func main() {
  flag.Parse()
  d, err := daikin.NewNetwork(daikin.AddressOption(*address))
  if err != nil {
    glog.Exit(err)
  }
  dev := d.Devices[*address]
  if err := dev.GetControlInfo(); err != nil {
    glog.Error(err)
    continue
  }
  if err := dev.GetSensorInfo(); err != nil {
    glog.Error(err)
    continue
  }
  fmt.Printf("%s:\n%s", addr, dev.String())

  dev.ControlInfo.Power = daikin.PowerOn
  dev.ControlInfo.Mode = daikin.ModeHeat
  dev.ControlInfo.Fan = daikin.FanAuto
  dev.ControlInfo.Temperature = 22.5

  if err := dev.SetControlInfo(); err != nil {
    glog.Exit(err)
  }
}

Documentation

Overview

Package daikin provides functionality to interact with Daikin split system air conditioners equipped with a Wifi module. It is tested to work with the BRP072A42 Wifi interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddressOption

func AddressOption(addr string) func(*DaikinNetwork)

AddressOption specifies a specific address to query.

func InterfaceOption

func InterfaceOption(i string) func(*DaikinNetwork)

InterfaceOption configures a specific interface to scan on.

Types

type ControlInfo

type ControlInfo struct {
	// Power is the current power status of the unit.
	Power Power
	// Mode is the operating mode of the unit.
	Mode Mode
	// Fan is the fan speed of the unit.
	Fan Fan
	// FanDir is the fan louvre setting of the unit.
	FanDir FanDir
	// Temperature is the current set temperature of the unit.
	Temperature Temperature
	// Humidity is the set humidity of the unit.
	Humidity Humidity
}

ControlInfo represents the control status of the unit.

func (*ControlInfo) String

func (c *ControlInfo) String() string

type Daikin

type Daikin struct {
	// Address is the IP address of the unit.
	Address string
	// Name is the human-readable name of the unit.
	Name Name
	// ControlInfo contains the environment control info.
	ControlInfo *ControlInfo
	// SensorInfo contains the environment sensor info.
	SensorInfo *SensorInfo
}

Daikin represents the settings of the Daikin unit.

func (*Daikin) GetControlInfo

func (d *Daikin) GetControlInfo() error

GetControlInfo gets the current control settings for the unit.

func (*Daikin) GetSensorInfo

func (d *Daikin) GetSensorInfo() error

GetSensorInfo gets the current sensor values for the unit.

func (*Daikin) SetControlInfo

func (d *Daikin) SetControlInfo() error

Set configures the current setting to the unit.

func (*Daikin) String

func (d *Daikin) String() string

type DaikinNetwork

type DaikinNetwork struct {
	// Interface is the name of the local network interface.
	Interface string

	// PollInterval is the interval to poll for Daikin devices.
	PollInterval time.Duration
	// PollCount is the number of times to poll for Daikin devices.
	PollCount int

	// Devices are the Daikin devices found on the DaikinNetwork.
	Devices map[string]*Daikin
	// contains filtered or unexported fields
}

A DaikinNetwork represents a local network with Daikin device(s).

func NewNetwork

func NewNetwork(o ...Option) (*DaikinNetwork, error)

NewNetwork returns a new DaikinNetwork, attached to the given interface.

func (*DaikinNetwork) Discover

func (d *DaikinNetwork) Discover() error

Discover runs a UDP polling cycle for Daikin devices. Sends UDP packet to broadcast address, dst port 30050 with payload: DAIKIN_UDP/common/basic_info

type Fan

type Fan string

Fan is the fan speed of the Daikin unit.

const (
	FanAuto   Fan = "A"
	FanSilent Fan = "B"
	Fan1      Fan = "3"
	Fan2      Fan = "4"
	Fan3      Fan = "5"
	Fan4      Fan = "6"
	Fan5      Fan = "7"
)

Fan values. Not all may be valid on all models.

func (*Fan) String

func (f *Fan) String() string

type FanDir

type FanDir int

FanDir is the louvre swing setting of the Daikin unit.

const (
	FanDirStopped    FanDir = 0
	FanDirVertical   FanDir = 1
	FanDirHorizontal FanDir = 2
	FanDirBoth       FanDir = 3
)

Supported louve settings. Not all models will support all values.

func (*FanDir) String

func (f *FanDir) String() string

type Humidity

type Humidity int32

Shum is the set humidity of the Daikin unit.

func (*Humidity) String

func (h *Humidity) String() string

type Mode

type Mode int

Mode is the operating mode of the Daikin unit.

const (
	ModeDehumidify Mode = 2
	ModeCool       Mode = 3
	ModeHeat       Mode = 4
	ModeFan        Mode = 6
	ModeAuto       Mode = 0
	ModeAuto1      Mode = 1
	ModeAuto7      Mode = 7
)

The valid modes supported by the Daikin Wifi module (not all units may support all values).

func (*Mode) String

func (m *Mode) String() string

type Name

type Name string

Name is the human-readable name of the Daikin unit.

func (*Name) String

func (n *Name) String() string

type Option

type Option func(*DaikinNetwork)

Option is an option type to pass to NewNetwork.

type Power

type Power int

Power represents the power status of the unit (off/on).

const (
	PowerOff Power = 0
	PowerOn  Power = 1
)

The power status of the unit.

func (*Power) String

func (p *Power) String() string

type SensorInfo

type SensorInfo struct {
	// HomeTemperature is the home (interior) temperature.
	HomeTemperature Temperature
	// OutsideTemperature is the external temperature.
	OutsideTemperature Temperature
	// Humidity is the current interior humidity.
	Humidity Humidity
}

SensorInfo represents current sensor values.

func (*SensorInfo) String

func (s *SensorInfo) String() string

type Temperature

type Temperature float64

Temperature is the set temperature of the Daikin unit, in Celcius.

func (*Temperature) String

func (t *Temperature) String() string

Directories

Path Synopsis
Package main is a command line tool for querying and controlling Daikin AC/Heatpump units.
Package main is a command line tool for querying and controlling Daikin AC/Heatpump units.

Jump to

Keyboard shortcuts

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