vitotrol

package module
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: MIT Imports: 11 Imported by: 0

README

Das Paket go-vitotrol ermöglicht einen Zugriff auf die Viessmann™ Vitotrol™ cloud API und damit zur Anzeige und Steuerung einer Heizungsanlage.

Siehe auch https://www.viessmann.com/app_vitodata/VIIWebService-1.16.0.0/iPhoneWebService.asmx

Folgende Befehle sind umgesetzt und funktionieren für eine Heizungsanlage vom Typ Vitodens 333-F:

  • Login
  • GetDevices
  • RequestRefreshStatus
  • RequestWriteStatus
  • GetData
  • WriteData
  • RefreshData
  • GetErrorHistory
  • GetTimesheet
  • WriteTimesheetData
  • GetTypeInfo

Installation

The vitotrol command

To obtain a vitotrol executable in $GOPATH/bin/ directory if GOPATH environment variable exists or in $HOME/go/bin otherwise:

starting go 1.18
go install github.com/maxatome/go-vitotrol/cmd/vitotrol@master
before go 1.18
go get -u github.com/maxatome/go-vitotrol/cmd/vitotrol

The library

go get -u github.com/maxatome/go-vitotrol

-u became useless since go 1.18.

Example

See cmd/vitotrol/*.go for an example of use.

Executable vitotrol usage follows:

usage: vitotrol [OPTIONS] ACTION [PARAMS]
  -config string
        login+password config file
  -debug
        print debug information
  -device string
        DeviceID, index, DeviceName, DeviceId@LocationID, DeviceName@LocationName (see `devices' action) (default "0")
  -json
        used by `timesheet' action to display timesheets using JSON format
  -login string
        login on vitotrol API
  -password string
        password on vitotrol API
  -verbose
        print verbose information

ACTION & PARAMS can be:
- devices              list all available devices
- list [attrs|timesheets]  list attribute (default) or timesheet names
- get ATTR_NAME ...    get the value of attributes ATTR_NAME, ... on vitodata
                         server
- get all              get all known attributes on vitodata server
- rget ATTR_NAME ...   refresh then get the value of attributes ATTR_NAME, ...
                         on vitodata server
- rget all             refresh than get all known attributes on vitodata server
- bget ATTR_IDX ...    get the value of attributes ATTR_IDX, ... on vitodata
                         server without checking their validity before (for
                         developing purpose)
- rbget ATTR_IDX ...   refresh then get the value of attributes ATTR_IDX, ...
                         on vitodata server without checking their validity
                         before (for developing purpose)
- set ATTR_NAME VALUE  set the value of attribute ATTR_NAME to VALUE
- timesheet TIMESHEET ...
                       get the timesheet TIMESHEET data
- set_timesheet TIMESHEET '{"wday":[{"from":630,"to":2200},...],...}'
                       replace the whole timesheet TIMESHEET
                       wday is either a day (eg. mon) or a range of days
                       (eg. mon-wed or sat-mon)
                       The JSON content can be in a file with the syntax @file
- errors               get the error history
- remote_attrs         list server available attributes
                         (for developing purpose)

The config file is a two lines file containing the LOGIN on the first line and the PASSWORD on the second, and is named $HOME/.vitotrol-api by default (when all --config, --login and --password options are missing or empty):

LOGIN
PASSWORD

License

go-vitotrol is released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// WriteDataWaitDuration defines the duration to wait in
	// WriteDataWait after the WriteData call before calling
	// RequestWriteStatus for the first time. After that first call, the
	// next pause duration will be divided by 4 and so on.
	WriteDataWaitDuration = 4 * time.Second
	// WriteDataWaitMinDuration defines the minimal duration of pauses
	// between RequestWriteStatus calls.
	WriteDataWaitMinDuration = 1 * time.Second
	// WriteDataWaitTimeout is the max amount of time to wait during
	// WriteDataWait method call before returning a ErrTimeout error.
	WriteDataWaitTimeout = 60 * time.Second
)
View Source
var (
	// RefreshDataWaitDuration defines the duration to wait in
	// RefreshDataWait after the RefreshData call before calling
	// RequestRefreshStatus for the first time. After that first call, the
	// next pause duration will be divided by 4 and so on.
	RefreshDataWaitDuration = 8 * time.Second
	// RefreshDataWaitMinDuration defines the minimal duration of pauses
	// between RequestRefreshStatus calls.
	RefreshDataWaitMinDuration = 1 * time.Second
	// RefreshDataWaitTimeout is the max amount of time to wait during
	// RefreshDataWait method call before returning a ErrTimeout error.
	RefreshDataWaitTimeout = 60 * time.Second
)
View Source
var (
	// WriteTimesheetDataWaitDuration defines the duration to wait in
	// WriteTimesheetDataWait after the WriteTimesheetData call before
	// calling RequestWriteStatus for the first time. After that first
	// call, the next pause duration will be divided by 4 and so on.
	WriteTimesheetDataWaitDuration = 8 * time.Second
	// WriteTimesheetDataWaitMinDuration defines the minimal duration of pauses
	// between RequestWriteStatus calls.
	WriteTimesheetDataWaitMinDuration = 1 * time.Second
	// WriteTimesheetDataWaitTimeout is the max amount of time to wait
	// during WriteTimesheetDataWait method call before returning a
	// ErrTimeout error.
	WriteTimesheetDataWaitTimeout = 60 * time.Second
)
View Source
var (
	TypeDouble    = (*VitodataDouble)(nil)
	TypeInteger   = (*VitodataInteger)(nil)
	TypeDate      = (*VitodataDate)(nil)
	TypeString    = (*VitodataString)(nil)
	TypeOnOffEnum = NewEnum([]string{
		"off",
		"on",
	})
	TypeEnabledEnum = NewEnum([]string{
		"disabled",
		"enabled",
	})

	TypeNames = map[string]VitodataType{
		TypeDouble.Type():  TypeDouble,
		TypeInteger.Type(): TypeInteger,
		TypeDate.Type():    TypeDate,
		TypeString.Type():  TypeString,
	}
)

Singletons matching Vitodata™ types.

View Source
var AccessToStr = map[AttrAccess]string{
	ReadOnly:  "read-only",
	WriteOnly: "write-only",
	ReadWrite: "read/write",
}

AccessToStr map allows to translate AttrAccess values to strings.

View Source
var Attributes = computeAttributes()

Attributes lists the AttrIDs for all available attributes.

View Source
var AttributesNames2IDs = computeNames2IDs()

AttributesNames2IDs maps the attributes names to their AttrID counterpart.

View Source
var AttributesRef = map[AttrID]*AttrRef{
	AussenTemp: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Außen Temperatur",
		Name:   "AussenTemp",
	},
	AbgasTemp: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Abgas Temperatur",
		Name:   "AbgasTemp",
	},
	BoilerTemp: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Boiler Temperatur",
		Name:   "BoilerTemp",
	},
	HeisswasserTemp: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Heißwasser Temperatur",
		Name:   "HeisswasserTemp",
	},
	HeisswasserAusgangTemp: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Heißwasser Ausgangstemperatur",
		Name:   "HeisswasserAusgangTemp",
	},
	HeizwasserAusgangTemp: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Heizwasser Ausgangstemperatur",
		Name:   "HeizwasserAusgangTemp",
	},
	HeizNormalTempM1: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Normale Raumsolltemperatur Heizkörper",
		Name:   "HeizNormalTempM1",
	},
	HeizNormalTempM2: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Normale Raumsolltemperatur Fußbodenheizung",
		Name:   "HeizNormalTempM2",
	},
	HeizPartyTempM1: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Party Raumtemperatur Heizkörper",
		Name:   "HeizPartyTempM1",
	},
	HeizPartyTempM2: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Party Raumtemperatur Fußbodenheizung",
		Name:   "HeizPartyTempM2",
	},
	HeizReduziertTempM1: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Reduzierte Raumtemperatur Heizkörper",
		Name:   "HeizReduziertTempM1",
	},
	HeizReduziertTempM2: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Reduzierte Raumtemperatur Fußbodenheizung",
		Name:   "HeizReduziertTempM2",
	},
	HeisswasserSollTemp: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Solltemperatur Warmwasser",
		Name:   "HeisswasserSollTemp",
	},
	AnzahlBrennerstunden: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Brennerstundenanzahl",
		Name:   "AnzahlBrennerstunden",
	},
	BrennerStatus: {
		Type: NewEnum([]string{
			"Aus",
			"Ein",
		}),
		Access: ReadOnly,
		Doc:    "Brenner Status",
		Name:   "BrennerStatus",
	},
	AnzahlBrennerStarts: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Anzahl von Brennerstarts",
		Name:   "AnzahlBrennerStarts",
	},
	InternerPumpenStatus: {
		Type: NewEnum([]string{
			"Aus",
			"Ein",
			"Aus2",
			"Ein2",
		}),
		Access: ReadOnly,
		Doc:    "Interner Pumpen Status",
		Name:   "InternerPumpenStatus",
	},
	HeizPumpenStatusM1: {
		Type: NewEnum([]string{
			"Aus",
			"Ein",
		}),
		Access: ReadOnly,
		Doc:    "Zustand Heizkreispumpe Heizkörper",
		Name:   "HeizPumpenStatusM1",
	},
	HeizPumpenStatusM2: {
		Type: NewEnum([]string{
			"Aus",
			"Ein",
		}),
		Access: ReadOnly,
		Doc:    "Zustand Heizkreispumpe Hußbodenheizung",
		Name:   "HeizPumpenStatusM2",
	},
	ZirkPumpenStatus: {
		Type: NewEnum([]string{
			"Aus",
			"Ein",
		}),
		Access: ReadOnly,
		Doc:    "Zustand Zirkulationspumpe",
		Name:   "ZirkPumpenStatus",
	},
	PartyModusM1: {
		Type: NewEnum([]string{
			"Aus",
			"Ein",
		}),
		Access: ReadWrite,
		Doc:    "Partymodus Heizkörper",
		Name:   "PartyModusM1",
	},
	PartyModusM2: {
		Type: NewEnum([]string{
			"Aus",
			"Ein",
		}),
		Access: ReadWrite,
		Doc:    "Partymodus Fußbodenheizung",
		Name:   "PartyModusM2",
	},
	EnergieSparmodusM1: {
		Type: NewEnum([]string{
			"Aus",
			"Ein",
		}),
		Access: ReadWrite,
		Doc:    "Energiesparmodus Heizkörper",
		Name:   "EnergieSparmodusM1",
	},
	EnergieSparmodusM2: {
		Type: NewEnum([]string{
			"Aus",
			"Ein",
		}),
		Access: ReadWrite,
		Doc:    "Energiesparmodus Fußbodenheizung",
		Name:   "EnergieSparmodusM2",
	},
	DatumUhrzeit: {
		Type:   TypeDate,
		Access: ReadWrite,
		Doc:    "Aktuelles Datum mir Uhrzeit",
		Name:   "DatumUhrzeit",
	},
	AktuellerFehler: {
		Type:   TypeString,
		Access: ReadOnly,
		Doc:    "Fehlermeldung",
		Name:   "AktuellerFehler",
	},
	FerienStartM1: {
		Type:   TypeDate,
		Access: ReadWrite,
		Doc:    "Start der Ferienzeit für Heizkörper",
		Name:   "FerienStartM1",
	},
	FerienStartM2: {
		Type:   TypeDate,
		Access: ReadWrite,
		Doc:    "Start der Ferienzeit für Fußbodenheizung",
		Name:   "FerienStartM2",
	},
	FerienEndeM1: {
		Type:   TypeDate,
		Access: ReadWrite,
		Doc:    "Ende der Ferienzeit für Heizkörper",
		Name:   "FerienEndeM1",
	},
	FerienEndeM2: {
		Type:   TypeDate,
		Access: ReadWrite,
		Doc:    "Ende der Ferienzeit für Fußbodenheizung",
		Name:   "FerienEndeM2",
	},
	ZustandFerienProgM1: {
		Type: NewEnum([]string{
			"inaktiv",
			"aktiv",
		}),
		Access: ReadOnly,
		Doc:    "Zustand Ferienprogramm Heizkörper",
		Name:   "ZustandFerienProgM1",
	},
	ZustandFerienProgM2: {
		Type: NewEnum([]string{
			"inaktiv",
			"aktiv",
		}),
		Access: ReadOnly,
		Doc:    "Zustand Ferienprogramm Fußbodenheizung",
		Name:   "ZustandFerienProgM2",
	},
	AktuelleBetriebsartM1: {
		Type: NewEnum([]string{
			"Abschaltbetrieb",
			"Reduzierter Betrieb",
			"Normalbetrieb",
			"Dauernd Normalbetrieb",
		}),
		Access: ReadOnly,
		Doc:    "Betriebsart Heizkörper",
		Name:   "AktuelleBetriebsartM1",
	},
	AktuelleBetriebsartM2: {
		Type: NewEnum([]string{
			"Abschaltbetrieb",
			"Reduzierter Betrieb",
			"Normalbetrieb",
			"Dauernd Normalbetrieb",
		}),
		Access: ReadOnly,
		Doc:    "Betriebsart Fußbodenheizung",
		Name:   "AktuelleBetriebsartM2",
	},
	ZustandFrostgefahrM1: {
		Type: NewEnum([]string{
			"inaktiv",
			"aktiv",
		}),
		Access: ReadOnly,
		Doc:    "Zustand Frostgefahr Heizkörper",
		Name:   "ZustandFrostgefahrM1",
	},
	ZustandFrostgefahrM2: {
		Type: NewEnum([]string{
			"inaktiv",
			"aktiv",
		}),
		Access: ReadOnly,
		Doc:    "Zustand Frostgefahr Fußbodenheizung",
		Name:   "ZustandFrostgefahrM2",
	},
	BetriebsartM1: {
		Type: NewEnum([]string{
			"Abschalt",
			"Nur WW",
			"Heizen + WW",
			"Dauernd Reduziert",
			"Dauernd Normal",
		}),
		Access: ReadWrite,
		Doc:    "Betriebsart Heizkörper",
		Name:   "BetriebsartM1",
	},
	BetriebsartM2: {
		Type: NewEnum([]string{
			"Abschalt",
			"Nur WW",
			"Heizen + WW",
			"Dauernd Reduziert",
			"Dauernd Normal",
		}),
		Access: ReadWrite,
		Doc:    "Betriebsart Fußbodenheizung",
		Name:   "BetriebsartM2",
	},
	NeigungM1: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Neigung Heizkörper",
		Name:   "NeigungM1",
	},
	NeigungM2: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Neigung Fußbodenheizung",
		Name:   "NeigungM2",
	},
	NiveauM1: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Niveau Heizkörper",
		Name:   "NiveauM1",
	},
	NiveauM2: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Niveau Fußbodenheizung",
		Name:   "NiveauM2",
	},
	Heizungsschema: {
		Type: NewEnum([]string{
			"",
			"1 A1",
			"2 A1 + WW",
			"3 M2",
			"4 M2 + WW",
			"5 A1 + M2",
			"6 A1 + M2 + WW",
			"7 M2 + M3",
			"8 M2 + M3 + WW",
			"9 A1 + M2 + M3",
			"10 A1 + M2 + M3 + WW",
		}),
		Access: ReadOnly,
		Doc:    "Heizungsschema für Anlage",
		Name:   "Heizungsschema",
	},
}

AttributesRef lists the reference for each attribute ID.

View Source
var ErrEnumInvalidValue = errors.New("Invalid Enum value")

ErrEnumInvalidValue is returned when trying to convert to an enum a value that cannot match any value of this enum.

View Source
var ErrTimeout = errors.New("Timeout")

ErrTimeout is the error returned by WriteDataWait, RefreshDataWait and WriteTimesheetDataWait methods when the response wait times out.

View Source
var MainURL = `https://www.viessmann.com/app_vitodata/VIIWebService-1.16.0.0/iPhoneWebService.asmx`

MainURL is the Viessmann Vitodata API URL.

View Source
var TimesheetsNames2IDs = func() map[string]TimesheetID {
	ret := make(map[string]TimesheetID, len(TimesheetsRef))
	for timesheetID, pTimesheetRef := range TimesheetsRef {
		ret[pTimesheetRef.Name] = timesheetID
	}
	return ret
}()

TimesheetsNames2IDs maps the timesheet names to their TimesheetID counterpart.

View Source
var TimesheetsRef = map[TimesheetID]*TimesheetRef{
	HotWaterLoopTimesheet: {
		Name: "HotWaterLoopTimesheet",
		Doc:  "Time program for domestic hot water recirculation pump",
	},
	HotWaterTimesheet: {
		Name: "HotWaterTimesheet",
		Doc:  "Time program for domestic hot water heating",
	},
	HeatingTimesheet: {
		Name: "HeatingTimesheet",
		Doc:  "Time program for central heating",
	},
}

TimesheetsRef lists the reference for each timesheet ID.

Functions

func AddAttributeRef

func AddAttributeRef(attrID AttrID, ref AttrRef)

AddAttributeRef adds a new attribute to the "official" list. This new attribute will only differ from others by its Custom field set to true.

No check is done to avoid overriding existing attributes.

Types

type AttrAccess

type AttrAccess uint8

An AttrAccess defines attributes access rights.

const (
	ReadOnly AttrAccess = 1 << iota
	WriteOnly
	ReadWrite AttrAccess = ReadOnly | WriteOnly
)

Availables access rights.

type AttrID

type AttrID uint16

An AttrID defines an attribute ID.

const (
	AussenTemp             AttrID = 5373   // temp_ats_r
	AbgasTemp              AttrID = 5372   // temp_agt_r
	BoilerTemp             AttrID = 5374   // temp_kts_r
	HeisswasserTemp        AttrID = 5381   // temp_ww_r
	HeisswasserAusgangTemp AttrID = 5382   // temp_auslauf_r
	HeizwasserAusgangTemp  AttrID = 6053   // temp_vts_r
	HeizNormalTempM1       AttrID = 82     // konf_raumsolltemp_rw
	HeizNormalTempM2       AttrID = 83     // konf_raumsolltemp_rw
	HeizPartyTempM1        AttrID = 79     // konf_partysolltemp_rw
	HeizPartyTempM2        AttrID = 80     // konf_partysolltemp_rw
	HeizReduziertTempM1    AttrID = 85     // konf_raumsolltemp_reduziert_rw
	HeizReduziertTempM2    AttrID = 86     // konf_raumsolltemp_reduziert_rw
	HeisswasserSollTemp    AttrID = 51     // konf_ww_solltemp_rw
	AnzahlBrennerstunden   AttrID = 104    // anzahl_brennerstunden_r
	BrennerStatus          AttrID = 600    // zustand_brenner_r
	AnzahlBrennerStarts    AttrID = 111    // anzahl_brennerstart_r
	InternerPumpenStatus   AttrID = 245    // zustand_interne_pumpe_r
	HeizPumpenStatusM1     AttrID = 729    // zustand_heizkreispumpe_r
	HeizPumpenStatusM2     AttrID = 730    // zustand_heizkreispumpe_r
	ZirkPumpenStatus       AttrID = 7181   // zustand_zirkulationspumpe_r
	PartyModusM1           AttrID = 7855   // konf_partybetrieb_rw
	PartyModusM2           AttrID = 7856   // konf_partybetrieb_rw
	EnergieSparmodusM1     AttrID = 7852   // konf_sparbetrieb_rw
	EnergieSparmodusM2     AttrID = 7853   // konf_sparbetrieb_rw
	DatumUhrzeit           AttrID = 5385   // konf_uhrzeit_rw
	AktuellerFehler        AttrID = 7184   // aktuelle_fehler_r
	FerienStartM1          AttrID = 306    // konf_ferien_start_rw
	FerienStartM2          AttrID = 307    // konf_ferien_start_rw
	FerienEndeM1           AttrID = 309    // konf_ferien_ende_rw
	FerienEndeM2           AttrID = 310    // konf_ferien_ende_rw
	ZustandFerienProgM1    AttrID = 714    // zustand_ferienprogramm_r
	ZustandFerienProgM2    AttrID = 715    // zustand_ferienprogramm_r
	AktuelleBetriebsartM1  AttrID = 708    // aktuelle_betriebsart_r
	AktuelleBetriebsartM2  AttrID = 709    // aktuelle_betriebsart_r
	ZustandFrostgefahrM1   AttrID = 717    // zustand_frostgefahr_r
	ZustandFrostgefahrM2   AttrID = 718    // zustand_frostgefahr_r
	BetriebsartM1          AttrID = 92     // konf_betriebsart_rw
	BetriebsartM2          AttrID = 94     // konf_betriebsart_rw
	NeigungM1              AttrID = 2869   // konf_neigung_rw
	NeigungM2              AttrID = 2871   // konf_neigung_rw
	NiveauM1               AttrID = 2875   // konf_niveau_rw
	NiveauM2               AttrID = 2877   // konf_niveau_rw
	Heizungsschema         AttrID = 801    // konf_heizungsschema_r
	NoAttr                 AttrID = 0xffff // Used in error cases
)

Attribute IDs currently supported by the library. For each, the Vitotrol™ name.

type AttrRef

type AttrRef struct {
	Type   VitodataType
	Access AttrAccess
	Name   string
	Doc    string
	Custom bool
}

An AttrRef describes an attribute reference: its type, access and name.

func (*AttrRef) String

func (r *AttrRef) String() string

String returns all information contained in this attribute reference.

type AttributeInfo

type AttributeInfo struct {
	AttributeInfoBase
	AttributeID AttrID
	EnumValues  map[uint32]string // only if AttributeType == "ENUM"
}

AttributeInfo defines an attribute.

type AttributeInfoBase

type AttributeInfoBase struct {
	AttributeName      string `xml:"DatenpunktName"` // German one, more funny :)
	AttributeType      string `xml:"DatenpunktTyp"`
	AttributeTypeValue uint32 `xml:"DatenpunktTypWert"` // ???
	MinValue           string `xml:"MinimalWert"`
	MaxValue           string `xml:"MaximalWert"`
	DataPointGroup     string `xml:"DatenpunktGruppe"`
	HeatingCircuitID   uint32 `xml:"HeizkreisId"`
	DefaultValue       string `xml:"Auslieferungswert"`
	Readable           bool   `xml:"IstLesbar"`
	Writable           bool   `xml:"IstSchreibbar"`
}

AttributeInfoBase defines the base information the GetTypeInfo request returns.

type Device

type Device struct {
	LocationID   uint32 // Vitotrol™ ID of location (AnlageId field)
	LocationName string // location name (AnlageName field)
	DeviceID     uint32 // Vitotrol™ ID of device (GeraetId field)
	DeviceName   string // device name (GeraetName field)
	HasError     bool   // ORed HatFehler field of Device & Location
	IsConnected  bool   // IstVerbunden field of Device

	// cache of last read attributes values (filled by GetData)
	Attributes map[AttrID]*Value
	// cache of last read timesheets data (filled by GetTimesheetData)
	Timesheets map[TimesheetID]map[string]TimeslotSlice
	// cache of last read errors (filled by GetErrorHistory)
	Errors []ErrorHistoryEvent
}

Device represents one Vitotrol™ device (a priori a boiler).

func (*Device) FormatAttributes

func (d *Device) FormatAttributes(attrs []AttrID) string

FormatAttributes displays informations about selected attributes. Displays information about all known attributes when a nil slice is passed.

func (*Device) GetData

func (d *Device) GetData(v *Session, attrIDs []AttrID) error

GetData launches the Vitotrol™ GetData request. Populates the internal cache before returning (see Attributes field).

func (*Device) GetErrorHistory

func (d *Device) GetErrorHistory(v *Session) error

GetErrorHistory launches the Vitotrol™ GetErrorHistory request. Populates the internal cache before returning (see Errors field).

func (*Device) GetTimesheetData

func (d *Device) GetTimesheetData(v *Session, id TimesheetID) error

GetTimesheetData launches the Vitotrol™ GetTimesheetData request. Populates the internal cache before returning (see Timesheets field).

func (*Device) GetTypeInfo

func (d *Device) GetTypeInfo(v *Session) ([]*AttributeInfo, error)

GetTypeInfo launches the Vitotrol™ GetTypeInfo request.

func (*Device) RefreshData

func (d *Device) RefreshData(v *Session, attrIDs []AttrID) (string, error)

RefreshData launches the Vitotrol™ RefreshData request and returns the "refresh ID" sent back by the server. Use RefreshDataWait instead.

func (*Device) RefreshDataWait

func (d *Device) RefreshDataWait(v *Session, attrIDs []AttrID) (<-chan error, error)

RefreshDataWait launches the Vitotrol™ RefreshData request and returns a channel on which the final error (asynchronous one) will be received (nil if the data has been correctly written).

If an error occurs during the RefreshData call (synchronous one), a nil channel is returned with an error.

func (*Device) WriteData

func (d *Device) WriteData(v *Session, attrID AttrID, value string) (string, error)

WriteData launches the Vitotrol™ WriteData request and returns the "refresh ID" sent back by the server. Use WriteDataWait instead.

func (*Device) WriteDataWait

func (d *Device) WriteDataWait(v *Session, attrID AttrID, value string) (<-chan error, error)

WriteDataWait launches the Vitotrol™ WriteData request and returns a channel on which the final error (asynchronous one) will be received (nil if the data has been correctly written).

If an error occurs during the WriteData call (synchronous one), a nil channel is returned with an error.

func (*Device) WriteTimesheetData

func (d *Device) WriteTimesheetData(v *Session, id TimesheetID, data map[string]TimeslotSlice) (string, error)

WriteTimesheetData launches the Vitotrol™ WriteTimesheetData request and returns the "refresh ID" sent back by the server. Does not populate the internal cache before returning (Timesheets field), use WriteTimesheetDataWait instead.

func (*Device) WriteTimesheetDataWait

func (d *Device) WriteTimesheetDataWait(v *Session, id TimesheetID, data map[string]TimeslotSlice) (<-chan error, error)

WriteTimesheetDataWait launches the Vitotrol™ WriteTimesheetData request and returns a channel on which the final error (asynchronous one) will be received (nil if the data has been correctly written).

If an error occurs during the WriteTimesheetData call (synchronous one), a nil channel is returned with an error.

type ErrorHistoryEvent

type ErrorHistoryEvent struct {
	Error    string `xml:"FehlerCode"`
	Message  string `xml:"FehlerMeldung"`
	Time     Time   `xml:"Zeitstempel"`
	IsActive bool   `xml:"FehlerIstAktiv"`
}

ErrorHistoryEvent represents a timestamped history event generally found in a GetErrorHistoryResponse.

func (*ErrorHistoryEvent) String

func (e *ErrorHistoryEvent) String() string

type GetDataResponse

type GetDataResponse struct {
	GetDataResult struct {
		ResultHeader
		Values []getDataValue `xml:"DatenwerteListe>WerteListe"`
	} `xml:"Body>GetDataResponse>GetDataResult"`
}

GetDataResponse is a response to a GetData request.

func (*GetDataResponse) ResultHeader

func (r *GetDataResponse) ResultHeader() *ResultHeader

ResultHeader returns the ResultHeader address in the response.

type GetDevicesResponse

type GetDevicesResponse struct {
	GetDevicesResult struct {
		ResultHeader
		Locations []getDevicesLocation `xml:"AnlageListe>AnlageV2"`
	} `xml:"Body>GetDevicesResponse>GetDevicesResult"`
}

GetDevicesResponse is a response to a GetDevices request.

func (*GetDevicesResponse) ResultHeader

func (r *GetDevicesResponse) ResultHeader() *ResultHeader

ResultHeader returns the ResultHeader address in the response.

type GetErrorHistoryResponse

type GetErrorHistoryResponse struct {
	GetErrorHistoryResult struct {
		ResultHeader
		Events []ErrorHistoryEvent `xml:"FehlerListe>FehlerHistorie"`
	} `xml:"Body>GetErrorHistoryResponse>GetErrorHistoryResult"`
}

GetErrorHistoryResponse is a response to a GetErrorHistory request.

func (*GetErrorHistoryResponse) ResultHeader

func (r *GetErrorHistoryResponse) ResultHeader() *ResultHeader

ResultHeader returns the ResultHeader address in the response.

type GetTimesheetDataResponse

type GetTimesheetDataResponse struct {
	GetTimesheetDataResult struct {
		ResultHeader
		ID       uint16    `xml:"SchaltsatzDaten>DatenpunktID"`
		DaySlots []daySlot `xml:"SchaltsatzDaten>Schaltzeiten>Schaltzeit"`
	} `xml:"Body>GetTimesheetDataResponse>GetTimesheetDataResult"`
}

GetTimesheetDataResponse is a response to a GetTimesheetData request.

func (*GetTimesheetDataResponse) ResultHeader

func (r *GetTimesheetDataResponse) ResultHeader() *ResultHeader

ResultHeader returns the ResultHeader address in the response.

type GetTypeInfoResponse

type GetTypeInfoResponse struct {
	GetTypeInfoResult struct {
		ResultHeader
		Attributes []*attributeInfo `xml:"TypeInfoListe>DatenpunktTypInfo"`
	} `xml:"Body>GetTypeInfoResponse>GetTypeInfoResult"`
}

GetTypeInfoResponse is a response to a GetTypeInfo request.

func (*GetTypeInfoResponse) ResultHeader

func (r *GetTypeInfoResponse) ResultHeader() *ResultHeader

ResultHeader returns the ResultHeader address in the response.

type HasResultHeader

type HasResultHeader interface {
	ResultHeader() *ResultHeader
}

HasResultHeader is the interface for abstrating Result part of each Vitotrol™ Response message.

type LoginResponse

type LoginResponse struct {
	LoginResult struct {
		ResultHeader
		Version   string `xml:"TechVersion"`
		Firstname string `xml:"Vorname"`
		Lastname  string `xml:"Nachname"`
	} `xml:"Body>LoginResponse>LoginResult"`
}

LoginResponse is a response to a Login request.

func (*LoginResponse) ResultHeader

func (r *LoginResponse) ResultHeader() *ResultHeader

ResultHeader returns the ResultHeader address in the response.

type RefreshDataResponse

type RefreshDataResponse struct {
	RefreshDataResult struct {
		ResultHeader
		RefreshID string `xml:"AktualisierungsId"`
	} `xml:"Body>RefreshDataResponse>RefreshDataResult"`
}

RefreshDataResponse is a response to a RefreshData request.

func (*RefreshDataResponse) ResultHeader

func (r *RefreshDataResponse) ResultHeader() *ResultHeader

ResultHeader returns the ResultHeader address in the response.

type RequestRefreshStatusResponse

type RequestRefreshStatusResponse struct {
	RequestRefreshStatusResult struct {
		ResultHeader
		Status int `xml:"Status"`
	} `xml:"Body>RequestRefreshStatusResponse>RequestRefreshStatusResult"`
}

RequestRefreshStatusResponse is a response to a RequestRefreshStatus request.

func (*RequestRefreshStatusResponse) ResultHeader

func (r *RequestRefreshStatusResponse) ResultHeader() *ResultHeader

ResultHeader returns the ResultHeader address in the response.

type RequestWriteStatusResponse

type RequestWriteStatusResponse struct {
	RequestWriteStatusResult struct {
		ResultHeader
		Status int `xml:"Status"`
	} `xml:"Body>RequestWriteStatusResponse>RequestWriteStatusResult"`
}

RequestWriteStatusResponse is a response to a RequestWriteStatus request.

func (*RequestWriteStatusResponse) ResultHeader

func (r *RequestWriteStatusResponse) ResultHeader() *ResultHeader

ResultHeader returns the ResultHeader address in the response.

type ResultHeader

type ResultHeader struct {
	ErrorNum int    `xml:"Ergebnis"`
	ErrorStr string `xml:"ErgebnisText"`
}

ResultHeader included in each Result part of each Vitotrol™ Response message.

func (*ResultHeader) Error

func (e *ResultHeader) Error() string

Error returns the result as a string.

func (*ResultHeader) IsError

func (e *ResultHeader) IsError() bool

IsError allows to know if this result is an error or not from the Vitotrol™ point of view.

type Session

type Session struct {
	Cookies []string

	Devices []Device

	Debug bool
}

Session keep a cache of all informations downloaded from the Vitotrol™ server. See Login method as entry point.

func (*Session) GetDevices

func (v *Session) GetDevices() error

GetDevices launches the Vitotrol™ GetDevices request. Populates the internal cache before returning (see Devices field).

func (*Session) Login

func (v *Session) Login(login, password string) error

Login authenticates the session on the Vitotrol™ server using the Login request.

func (*Session) RequestRefreshStatus

func (v *Session) RequestRefreshStatus(refreshID string) (int, error)

RequestRefreshStatus launches the Vitotrol™ RequestRefreshStatus request to follow the status of the RefreshData request matching the passed refresh ID. Use RefreshDataWait instead.

func (*Session) RequestWriteStatus

func (v *Session) RequestWriteStatus(refreshID string) (int, error)

RequestWriteStatus launches the Vitotrol™ RequestWriteStatus request to follow the status of the WriteData request matching the passed refresh ID. Use WriteDataWait instead.

type Time

type Time time.Time

Time handle the Vitotrol™ time format.

func ParseVitotrolTime

func ParseVitotrolTime(value string) (Time, error)

ParseVitotrolTime parses a Vitotrol™ time information. Without a time zone it is considered as a local time.

func (Time) String

func (t Time) String() string

String returns the time formatted using the format string

2006-01-02 15:04:05

considered as being a localtime value.

func (*Time) UnmarshalXML

func (t *Time) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML decodes a Vitotrol™ time embedded in XML.

type TimesheetID

type TimesheetID uint16

A TimesheetID allows to reference a specific timesheet. See *Timesheet consts.

const (
	HotWaterLoopTimesheet TimesheetID = 7193 // Programmation bouclage ECS
	HotWaterTimesheet     TimesheetID = 7192 // Programmation ECS
	HeatingTimesheet      TimesheetID = 7191 // Programmation chauffage
)

All available/recognized TimesheetID values.

type TimesheetRef

type TimesheetRef struct {
	Name string
	Doc  string
}

A TimesheetRef describe a time program reference.

func (*TimesheetRef) String

func (t *TimesheetRef) String() string

String returns a string describing a time program reference.

type Timeslot

type Timeslot struct {
	From uint16 `json:"from"`
	To   uint16 `json:"to"`
}

Timeslot represents a time slot. Hours and minutes are packed on 16 bits by multiplying hours by 100 before adding them to minutes.

func (*Timeslot) String

func (t *Timeslot) String() string

String returns a string representing the time slot.

type TimeslotSlice

type TimeslotSlice []Timeslot

TimeslotSlice allows to sort Timeslot slices.

func (TimeslotSlice) Len

func (t TimeslotSlice) Len() int

func (TimeslotSlice) Less

func (t TimeslotSlice) Less(i, j int) bool

func (TimeslotSlice) Swap

func (t TimeslotSlice) Swap(i, j int)

type Value

type Value struct {
	Value string
	Time  Time
}

Value is the timestamped value of an attribute.

func (*Value) Num

func (v *Value) Num() (ret float64)

Num returns the numerical value of this value. If the value is not a numerical one, 0 is returned.

type VitodataDate

type VitodataDate struct{}

A VitodataDate represent the Vitodata™ Date type.

func (*VitodataDate) Human2VitodataValue

func (v *VitodataDate) Human2VitodataValue(value string) (string, error)

Human2VitodataValue checks that the value is Vitodata™ formatted date and returns it after reformatting.

func (*VitodataDate) Type

func (v *VitodataDate) Type() string

Type returns the "human" name of the type.

func (*VitodataDate) Vitodata2HumanValue

func (v *VitodataDate) Vitodata2HumanValue(value string) (string, error)

Vitodata2HumanValue checks that the value is Vitodata™ formatted date and returns it after reformatting.

func (*VitodataDate) Vitodata2NativeValue

func (v *VitodataDate) Vitodata2NativeValue(value string) (interface{}, error)

Vitodata2NativeValue extract the Vitodata™ date from the passed string and returns it as a vitotrol.Time.

type VitodataDouble

type VitodataDouble struct{}

A VitodataDouble represent the Vitodata™ Double type.

func (*VitodataDouble) Human2VitodataValue

func (v *VitodataDouble) Human2VitodataValue(value string) (string, error)

Human2VitodataValue checks that the value is a float number and returns it after reformatting.

func (*VitodataDouble) Type

func (v *VitodataDouble) Type() string

Type returns the "human" name of the type.

func (*VitodataDouble) Vitodata2HumanValue

func (v *VitodataDouble) Vitodata2HumanValue(value string) (string, error)

Vitodata2HumanValue checks that the value is a float number and returns it after reformatting.

func (*VitodataDouble) Vitodata2NativeValue

func (v *VitodataDouble) Vitodata2NativeValue(value string) (interface{}, error)

Vitodata2NativeValue extract the number from the passed string and returns it as a float64.

type VitodataEnum

type VitodataEnum struct {
	// contains filtered or unexported fields
}

VitodataEnum represents any Vitodata™ Enum type. See NewEnum to specialize it.

func NewEnum

func NewEnum(values []string) *VitodataEnum

NewEnum specializes an enum to a set of values and returns it.

func (*VitodataEnum) Human2VitodataValue

func (v *VitodataEnum) Human2VitodataValue(value string) (string, error)

Human2VitodataValue checks that the value is a Vitodata™ enum value and returns its numeric counterpart.

func (*VitodataEnum) Type

func (v *VitodataEnum) Type() string

Type returns the "human" name of the type.

func (*VitodataEnum) Vitodata2HumanValue

func (v *VitodataEnum) Vitodata2HumanValue(value string) (string, error)

Vitodata2HumanValue check that the (numeric) value is a Vitodata™ enum value and returns its string counterpart.

func (*VitodataEnum) Vitodata2NativeValue

func (v *VitodataEnum) Vitodata2NativeValue(value string) (interface{}, error)

Vitodata2NativeValue extract the numeric Vitodata™ enum value from the passed string and returns it as a uint64.

type VitodataInteger

type VitodataInteger struct{}

A VitodataInteger represent the Vitodata™ Integer type.

func (*VitodataInteger) Human2VitodataValue

func (v *VitodataInteger) Human2VitodataValue(value string) (string, error)

Human2VitodataValue checks that the value is an integer and returns it after reformatting.

func (*VitodataInteger) Type

func (v *VitodataInteger) Type() string

Type returns the "human" name of the type.

func (*VitodataInteger) Vitodata2HumanValue

func (v *VitodataInteger) Vitodata2HumanValue(value string) (string, error)

Vitodata2HumanValue checks that the value is an integer and returns it after reformatting.

func (*VitodataInteger) Vitodata2NativeValue

func (v *VitodataInteger) Vitodata2NativeValue(value string) (interface{}, error)

Vitodata2NativeValue extract the number from the passed string and returns it as an int64.

type VitodataString

type VitodataString struct{}

A VitodataString represent the Vitodata™ String type.

func (*VitodataString) Human2VitodataValue

func (v *VitodataString) Human2VitodataValue(value string) (string, error)

Human2VitodataValue is a no-op here, returning its argument.

func (*VitodataString) Type

func (v *VitodataString) Type() string

Type returns the "human" name of the type.

func (*VitodataString) Vitodata2HumanValue

func (v *VitodataString) Vitodata2HumanValue(value string) (string, error)

Vitodata2HumanValue is a no-op here, returning its argument.

func (*VitodataString) Vitodata2NativeValue

func (v *VitodataString) Vitodata2NativeValue(value string) (interface{}, error)

Vitodata2NativeValue is a no-op here, returning its argument.

type VitodataType

type VitodataType interface {
	Type() string
	Human2VitodataValue(string) (string, error)
	Vitodata2HumanValue(string) (string, error)
	Vitodata2NativeValue(string) (interface{}, error)
}

VitodataType is the interface implemented by each Vitodata™ type.

type WriteDataResponse

type WriteDataResponse struct {
	WriteDataResult struct {
		ResultHeader
		RefreshID string `xml:"AktualisierungsId"`
	} `xml:"Body>WriteDataResponse>WriteDataResult"`
}

WriteDataResponse is a response to a WriteData request.

func (*WriteDataResponse) ResultHeader

func (r *WriteDataResponse) ResultHeader() *ResultHeader

ResultHeader returns the ResultHeader address in the response.

type WriteTimesheetDataResponse

type WriteTimesheetDataResponse struct {
	WriteTimesheetDataResult struct {
		ResultHeader
		RefreshID string `xml:"AktualisierungsId"`
	} `xml:"Body>WriteTimesheetDataResponse>WriteTimesheetDataResult"`
}

WriteTimesheetDataResponse is a response to a WriteTimesheetData request.

func (*WriteTimesheetDataResponse) ResultHeader

func (r *WriteTimesheetDataResponse) ResultHeader() *ResultHeader

ResultHeader returns the ResultHeader address in the response.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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