vitotrol

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

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

Go to latest
Published: Sep 19, 2024 License: MIT Imports: 11 Imported by: 4

README

Package go-vitotrol provides access to the Viessmann™ Vitotrol™ cloud API for controlling/monitoring boilers.

Build Status Coverage Status Go Report Card GoDoc

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

Only requests I really need are currently implemented:

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

Any pull-request is welcome.

Install

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.

Miscellaneous

Want to automatically feed an Influx database with attribute values? See vitotrol2influx.

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{
	IndoorTemp: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Indoor temperature",
		Name:   "IndoorTemp",
	},
	OutdoorTemp: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Outdoor temperature",
		Name:   "OutdoorTemp",
	},
	SmokeTemp: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Smoke temperature",
		Name:   "SmokeTemp",
	},
	BoilerTemp: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Boiler temperature",
		Name:   "BoilerTemp",
	},
	HotWaterTemp: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Hot water temperature",
		Name:   "HotWaterTemp",
	},
	HotWaterOutTemp: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Hot water outlet temperature",
		Name:   "HotWaterOutTemp",
	},
	HeatWaterOutTemp: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Heating water outlet temperature",
		Name:   "HeatWaterOutTemp",
	},
	HeatNormalTemp: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Setpoint of the normal room temperature",
		Name:   "HeatNormalTemp",
	},
	PartyModeTemp: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Party mode temperature",
		Name:   "PartyModeTemp",
	},
	HeatReducedTemp: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Setpoint of the reduced room temperature",
		Name:   "HeatReducedTemp",
	},
	HotWaterSetpointTemp: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Setpoint of the domestic hot water temperature",
		Name:   "HotWaterSetpointTemp",
	},
	BurnerHoursRun: {
		Type:   TypeDouble,
		Access: ReadOnly,
		Doc:    "Burner hours run",
		Name:   "BurnerHoursRun",
	},
	BurnerHoursRunReset: {
		Type:   TypeDouble,
		Access: WriteOnly,
		Doc:    "Reset the burner hours run",
		Name:   "BurnerHoursRunReset",
	},
	BurnerState: {
		Type:   TypeOnOffEnum,
		Access: ReadOnly,
		Doc:    "Burner status",
		Name:   "BurnerState",
	},
	BurnerStarts: {
		Type:   TypeDouble,
		Access: ReadWrite,
		Doc:    "Burner starts",
		Name:   "BurnerStarts",
	},
	InternalPumpStatus: {
		Type: NewEnum([]string{
			"off",
			"on",
			"off2",
			"on2",
		}),
		Access: ReadOnly,
		Doc:    "Internal pump status",
		Name:   "InternalPumpStatus",
	},
	HeatingPumpStatus: {
		Type:   TypeOnOffEnum,
		Access: ReadOnly,
		Doc:    "Heating pump status",
		Name:   "HeatingPumpStatus",
	},
	CirculationPumpState: {
		Type:   TypeOnOffEnum,
		Access: ReadOnly,
		Doc:    "Statut pompe circulation",
		Name:   "CirculationPumpState",
	},
	PartyMode: {
		Type:   TypeEnabledEnum,
		Access: ReadWrite,
		Doc:    "Party mode status",
		Name:   "PartyMode",
	},
	EnergySavingMode: {
		Type:   TypeEnabledEnum,
		Access: ReadWrite,
		Doc:    "Energy saving mode status",
		Name:   "EnergySavingMode",
	},
	DateTime: {
		Type:   TypeDate,
		Access: ReadWrite,
		Doc:    "Current date and time",
		Name:   "DateTime",
	},
	CurrentError: {
		Type:   TypeString,
		Access: ReadOnly,
		Doc:    "Current error",
		Name:   "CurrentError",
	},
	HolidaysStart: {
		Type:   TypeDate,
		Access: ReadWrite,
		Doc:    "Holidays begin date",
		Name:   "HolidaysStart",
	},
	HolidaysEnd: {
		Type:   TypeDate,
		Access: ReadWrite,
		Doc:    "Holidays end date",
		Name:   "HolidaysEnd",
	},
	HolidaysStatus: {
		Type:   TypeEnabledEnum,
		Access: ReadOnly,
		Doc:    "Holidays program status",
		Name:   "HolidaysStatus",
	},
	Way3ValveStatus: {
		Type: NewEnum([]string{
			"undefined",
			"heating",
			"middle position",
			"hot water",
		}),
		Access: ReadOnly,
		Doc:    "3-way valve status",
		Name:   "3WayValveStatus",
	},
	OperatingModeRequested: {
		Type: NewEnum([]string{
			"off",
			"DHW only",
			"heating+DHW",
			"continuous reduced",
			"continuous normal",
		}),
		Access: ReadWrite,
		Doc:    "Operating mode requested",
		Name:   "OperatingModeRequested",
	},
	OperatingModeCurrent: {
		Type: NewEnum([]string{
			"stand-by",
			"reduced",
			"normal",
			"continuous normal",
		}),
		Access: ReadOnly,
		Doc:    "Operating mode",
		Name:   "OperatingModeCurrent",
	},
	FrostProtectionStatus: {
		Type:   TypeEnabledEnum,
		Access: ReadOnly,
		Doc:    "Frost protection status",
		Name:   "FrostProtectionStatus",
	},
}

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 (
	IndoorTemp             AttrID = 5367   // temp_rts_r
	OutdoorTemp            AttrID = 5373   // temp_ats_r
	SmokeTemp              AttrID = 5372   // temp_agt_r
	BoilerTemp             AttrID = 5374   // temp_kts_r
	HotWaterTemp           AttrID = 5381   // temp_ww_r
	HotWaterOutTemp        AttrID = 5382   // temp_auslauf_r
	HeatWaterOutTemp       AttrID = 6052   // temp_vts_r
	HeatNormalTemp         AttrID = 82     // konf_raumsolltemp_rw
	PartyModeTemp          AttrID = 79     // konf_partysolltemp_rw
	HeatReducedTemp        AttrID = 85     // konf_raumsolltemp_reduziert_rw
	HotWaterSetpointTemp   AttrID = 51     // konf_ww_solltemp_rw
	BurnerHoursRun         AttrID = 104    // anzahl_brennerstunden_r
	BurnerHoursRunReset    AttrID = 106    // anzahl_brennerstunden_w
	BurnerState            AttrID = 600    // zustand_brenner_r
	BurnerStarts           AttrID = 111    // anzahl_brennerstart_r
	InternalPumpStatus     AttrID = 245    // zustand_interne_pumpe_r
	HeatingPumpStatus      AttrID = 729    // zustand_heizkreispumpe_r
	CirculationPumpState   AttrID = 7181   // zustand_zirkulationspumpe_r
	PartyMode              AttrID = 7855   // konf_partybetrieb_rw
	EnergySavingMode       AttrID = 7852   // konf_sparbetrieb_rw
	DateTime               AttrID = 5385   // konf_uhrzeit_rw
	CurrentError           AttrID = 7184   // aktuelle_fehler_r
	HolidaysStart          AttrID = 306    // konf_ferien_start_rw
	HolidaysEnd            AttrID = 309    // konf_ferien_ende_rw
	HolidaysStatus         AttrID = 714    // zustand_ferienprogramm_r
	Way3ValveStatus        AttrID = 5389   // info_status_umschaltventil_r
	OperatingModeRequested AttrID = 92     // konf_betriebsart_rw
	OperatingModeCurrent   AttrID = 708    // aktuelle_betriebsart_r
	FrostProtectionStatus  AttrID = 717    // zustand_frostgefahr_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