sensonetlib

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CLIENT_ID = "myvaillant"

	AUTH_BASE_URL = "https://identity.vaillant-group.com/auth/realms"
	LOGIN_URL     = AUTH_BASE_URL + "/%s/login-actions/authenticate"
	TOKEN_URL     = AUTH_BASE_URL + "/%s/protocol/openid-connect/token"
	AUTH_URL      = AUTH_BASE_URL + "/%s/protocol/openid-connect/auth"
	API_URL_BASE  = "https://api.vaillant-group.com/service-connected-control/end-user-app-api/v1"
)
View Source
const (
	HOTWATERBOOST_URL = "/systems/%s/tli/domestic-hot-water/%01d/boost"
	ZONEQUICKVETO_URL = "/systems/%s/tli/zones/%01d/quick-veto"

	// SYSTEM_URL     = "/systemcontrol/tli/v1"
	// FACILITIES_URL = "not to be used"
	// LIVEREPORT_URL = "/livereport/v1"
	HOTWATERINDEX_DEFAULT = 255
)
View Source
const REALM_GERMANY = "vaillant-germany-b2c"

Variables

View Source
var (
	JSONContent = "application/json"
	// JSONEncoding specifies application/json
	JSONEncoding = map[string]string{
		"Content-Type": JSONContent,
		"Accept":       JSONContent,
	}
	// AcceptJSON accepting application/json
	AcceptJSON = map[string]string{
		"Accept": JSONContent,
	}
)

Functions

func Oauth2ConfigForRealm

func Oauth2ConfigForRealm(realm string) *oauth2.Config

func ReadBody

func ReadBody(resp *http.Response) ([]byte, error)

ReadBody reads HTTP response and returns error on response codes other than HTTP 2xx. It closes the request body after reading.

func RefreshTokenSource

func RefreshTokenSource(token *oauth2.Token, refresher TokenRefresher) oauth2.TokenSource

func ResponseError

func ResponseError(resp *http.Response) error

ResponseError turns an HTTP status code into an error

Types

type ConfigurationCircuit

type ConfigurationCircuit struct {
	Index                                  int     `json:"index"`
	HeatingCurve                           float64 `json:"heatingCurve"`
	HeatingFlowTemperatureMinimumSetpoint  float64 `json:"heatingFlowTemperatureMinimumSetpoint"`
	HeatingFlowTemperatureMaximumSetpoint  float64 `json:"heatingFlowTemperatureMaximumSetpoint"`
	HeatDemandLimitedByOutsideTemperature  float64 `json:"heatDemandLimitedByOutsideTemperature"`
	HeatingCircuitFlowSetpointExcessOffset float64 `json:"heatingCircuitFlowSetpointExcessOffset"`
	SetBackModeEnabled                     bool    `json:"setBackModeEnabled"`
	RoomTemperatureControlMode             string  `json:"roomTemperatureControlMode"`
}

type ConfigurationDhw

type ConfigurationDhw struct {
	Index                      int         `json:"index"`
	OperationModeDhw           string      `json:"operationModeDhw"`
	TappingSetpoint            float64     `json:"tappingSetpoint"`
	HolidayStartDateTime       time.Time   `json:"holidayStartDateTime"`
	HolidayEndDateTime         time.Time   `json:"holidayEndDateTime"`
	TimeProgramDhw             TimeProgram `json:"timeProgramDhw"`
	TimeProgramCirculationPump TimeProgram `json:"timeProgramCirculationPump"`
}

type ConfigurationDomesticHotWater

type ConfigurationDomesticHotWater struct {
	Index                         int         `json:"index"`
	OperationModeDomesticHotWater string      `json:"operationModeDomesticHotWater"`
	TappingSetpoint               float64     `json:"tappingSetpoint"`
	HolidayStartDateTime          time.Time   `json:"holidayStartDateTime"`
	HolidayEndDateTime            time.Time   `json:"holidayEndDateTime"`
	TimeProgramDomesticHotWater   TimeProgram `json:"timeProgramDomesticHotWater"`
	TimeProgramCirculationPump    TimeProgram `json:"timeProgramCirculationPump"`
}

type ConfigurationZone

type ConfigurationZone struct {
	Index   int `json:"index"`
	General struct {
		Name                 string    `json:"name"`
		HolidayStartDateTime time.Time `json:"holidayStartDateTime"`
		HolidayEndDateTime   time.Time `json:"holidayEndDateTime"`
		HolidaySetpoint      float64   `json:"holidaySetpoint"`
	} `json:"general"`
	Heating struct {
		OperationModeHeating      string      `json:"operationModeHeating"`
		SetBackTemperature        float64     `json:"setBackTemperature"`
		ManualModeSetpointHeating float64     `json:"manualModeSetpointHeating"`
		TimeProgramHeating        TimeProgram `json:"timeProgramHeating"`
	} `json:"heating"`
}

type Connection

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

Connection is the Sensonet connection

func NewConnection

func NewConnection(client *http.Client, credentials *CredentialsStruct, token *oauth2.Token) (*Connection, *oauth2.Token, error)

NewConnection creates a new Sensonet device connection.

func (*Connection) GetHomes

func (c *Connection) GetHomes() (Homes, error)

Returns all "homes" that belong to the current user under the myVaillant portal

func (*Connection) GetSystem

func (c *Connection) GetSystem(systemId string) (SystemStatus, error)

Returns the system report (state, properties and configuration) for a specific systemId

func (*Connection) StartHotWaterBoost

func (c *Connection) StartHotWaterBoost(systemId string, hotwaterIndex int) error

func (*Connection) StartZoneQuickVeto

func (c *Connection) StartZoneQuickVeto(systemId string, zone int, setpoint float32, duration float32) error

func (*Connection) StopHotWaterBoost

func (c *Connection) StopHotWaterBoost(systemId string, hotwaterIndex int) error

func (*Connection) StopZoneQuickVeto

func (c *Connection) StopZoneQuickVeto(systemId string, zone int) error

type CredentialsStruct

type CredentialsStruct struct {
	User     string `json:"user"`
	Password string `json:"password"`
	Realm    string `json:"realm"`
}

type Helper

type Helper struct {
	*http.Client
}

Helper provides utility primitives

func NewHelper

func NewHelper(client *http.Client) *Helper

NewHelper creates http helper for simplified PUT GET logic

func (*Helper) DoBody

func (r *Helper) DoBody(req *http.Request) ([]byte, error)

DoBody executes HTTP request and returns the response body

func (*Helper) DoJSON

func (r *Helper) DoJSON(req *http.Request, res interface{}) error

DoJSON executes HTTP request and decodes JSON response. It returns a StatusError on response codes other than HTTP 2xx.

type Homes

type Homes []struct {
	HomeName string `json:"homeName"`
	Address  struct {
		Street      string `json:"street"`
		Extension   any    `json:"extension"`
		City        string `json:"city"`
		PostalCode  string `json:"postalCode"`
		CountryCode string `json:"countryCode"`
	} `json:"address"`
	SerialNumber    string `json:"serialNumber"`
	SystemID        string `json:"systemId"`
	ProductMetadata struct {
		ProductType    string `json:"productType"`
		ProductionYear string `json:"productionYear"`
		ProductionWeek string `json:"productionWeek"`
		ArticleNumber  string `json:"articleNumber"`
	} `json:"productMetadata"`
	State               string    `json:"state"`
	MigrationState      string    `json:"migrationState"`
	MigrationFinishedAt time.Time `json:"migrationFinishedAt"`
	OnlineState         string    `json:"onlineState"`
	Firmware            struct {
		Version        string `json:"version"`
		UpdateEnabled  bool   `json:"updateEnabled"`
		UpdateRequired bool   `json:"updateRequired"`
	} `json:"firmware"`
	Nomenclature       string `json:"nomenclature"`
	Cag                bool   `json:"cag"`
	CountryCode        string `json:"countryCode"`
	ProductInformation string `json:"productInformation"`
	FirmwareVersion    string `json:"firmwareVersion"`
}

type Identity

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

func NewIdentity

func NewIdentity(client *Helper, credentials *CredentialsStruct) (*Identity, error)

func (*Identity) Login

func (v *Identity) Login() (*oauth2.Token, error)

func (*Identity) RefreshToken

func (v *Identity) RefreshToken(token *oauth2.Token) (*oauth2.Token, error)

func (*Identity) TokenSource

func (v *Identity) TokenSource(token *oauth2.Token) (oauth2.TokenSource, error)

type MetaInfo

type MetaInfo struct {
	MinSlotsPerDay          int  `json:"minSlotsPerDay"`
	MaxSlotsPerDay          int  `json:"maxSlotsPerDay"`
	SetpointRequiredPerSlot bool `json:"setpointRequiredPerSlot"`
}

type PropertiesCircuit

type PropertiesCircuit struct {
	Index                    int    `json:"index"`
	MixerCircuitTypeExternal string `json:"mixerCircuitTypeExternal"`
	HeatingCircuitType       string `json:"heatingCircuitType"`
}

type PropertiesDhw

type PropertiesDhw struct {
	Index       int     `json:"index"`
	MinSetpoint float64 `json:"minSetpoint"`
	MaxSetpoint float64 `json:"maxSetpoint"`
}

type PropertiesDomesticHotWater

type PropertiesDomesticHotWater struct {
	Index       int     `json:"index"`
	MinSetpoint float64 `json:"minSetpoint"`
	MaxSetpoint float64 `json:"maxSetpoint"`
}

type PropertiesZone

type PropertiesZone struct {
	Index                  int    `json:"index"`
	IsActive               bool   `json:"isActive"`
	ZoneBinding            string `json:"zoneBinding"`
	IsCoolingAllowed       bool   `json:"isCoolingAllowed"`
	AssociatedCircuitIndex int    `json:"associatedCircuitIndex"`
}

type Setpoint

type Setpoint struct {
	StartTime int     `json:"startTime"`
	EndTime   int     `json:"endTime"`
	Setpoint  float64 `json:"setpoint"`
}

type StateCircuit

type StateCircuit struct {
	Index                         int     `json:"index"`
	CircuitState                  string  `json:"circuitState"`
	CurrentCircuitFlowTemperature float64 `json:"currentCircuitFlowTemperature,omitempty"`
	HeatingCircuitFlowSetpoint    float64 `json:"heatingCircuitFlowSetpoint"`
	CalculatedEnergyManagerState  string  `json:"calculatedEnergyManagerState"`
}

type StateDhw

type StateDhw struct {
	Index                  int     `json:"index"`
	CurrentSpecialFunction string  `json:"currentSpecialFunction"`
	CurrentDhwTemperature  float64 `json:"currentDhwTemperature"`
}

type StateDomesticHotWater

type StateDomesticHotWater struct {
	Index                              int     `json:"index"`
	CurrentSpecialFunction             string  `json:"currentSpecialFunction"`
	CurrentDomesticHotWaterTemperature float64 `json:"currentDomesticHotWaterTemperature"`
}

type StateZone

type StateZone struct {
	Index                                 int     `json:"index"`
	DesiredRoomTemperatureSetpointHeating float64 `json:"desiredRoomTemperatureSetpointHeating"`
	DesiredRoomTemperatureSetpoint        float64 `json:"desiredRoomTemperatureSetpoint"`
	CurrentRoomTemperature                float64 `json:"currentRoomTemperature,omitempty"`
	CurrentRoomHumidity                   float64 `json:"currentRoomHumidity,omitempty"`
	CurrentSpecialFunction                string  `json:"currentSpecialFunction"`
	HeatingState                          string  `json:"heatingState"`
}

type StatusError

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

StatusError indicates unsuccessful http response

func (StatusError) Error

func (e StatusError) Error() string

func (StatusError) Response

func (e StatusError) Response() *http.Response

Response returns the response with the unexpected error

func (StatusError) StatusCode

func (e StatusError) StatusCode() int

StatusCode returns the response's status code

type SystemStatus

type SystemStatus struct {
	State struct {
		System struct {
			OutdoorTemperature           float64 `json:"outdoorTemperature"`
			OutdoorTemperatureAverage24H float64 `json:"outdoorTemperatureAverage24h"`
			SystemFlowTemperature        float64 `json:"systemFlowTemperature"`
			SystemWaterPressure          float64 `json:"systemWaterPressure"`
			EnergyManagerState           string  `json:"energyManagerState"`
			SystemOff                    bool    `json:"systemOff"`
		} `json:"system"`
		Zones            []StateZone             `json:"zones"`
		Circuits         []StateCircuit          `json:"circuits"`
		Dhw              []StateDhw              `json:"dhw"`
		DomesticHotWater []StateDomesticHotWater `json:"domesticHotWater"`
	} `json:"state"`
	Properties struct {
		System struct {
			ControllerType                     string  `json:"controllerType"`
			SystemScheme                       int     `json:"systemScheme"`
			BackupHeaterType                   string  `json:"backupHeaterType"`
			BackupHeaterAllowedFor             string  `json:"backupHeaterAllowedFor"`
			ModuleConfigurationVR71            int     `json:"moduleConfigurationVR71"`
			EnergyProvidePowerCutBehavior      string  `json:"energyProvidePowerCutBehavior"`
			SmartPhotovoltaicBufferOffset      float64 `json:"smartPhotovoltaicBufferOffset"`
			ExternalEnergyManagementActivation bool    `json:"externalEnergyManagementActivation"`
		} `json:"system"`
		Zones            []PropertiesZone             `json:"zones"`
		Circuits         []PropertiesCircuit          `json:"circuits"`
		Dhw              []PropertiesDhw              `json:"dhw"`
		DomesticHotWater []PropertiesDomesticHotWater `json:"domesticHotWater"`
	} `json:"properties"`
	Configuration struct {
		System struct {
			ContinuousHeatingStartSetpoint float64 `json:"continuousHeatingStartSetpoint"`
			AlternativePoint               float64 `json:"alternativePoint"`
			HeatingCircuitBivalencePoint   float64 `json:"heatingCircuitBivalencePoint"`
			DhwBivalencePoint              float64 `json:"dhwBivalencePoint"`
			AdaptiveHeatingCurve           bool    `json:"adaptiveHeatingCurve"`
			DhwMaximumLoadingTime          int     `json:"dhwMaximumLoadingTime"`
			DhwHysteresis                  float64 `json:"dhwHysteresis"`
			DhwFlowSetpointOffset          float64 `json:"dhwFlowSetpointOffset"`
			ContinuousHeatingRoomSetpoint  float64 `json:"continuousHeatingRoomSetpoint"`
			HybridControlStrategy          string  `json:"hybridControlStrategy"`
			MaxFlowSetpointHpError         float64 `json:"maxFlowSetpointHpError"`
			DhwMaximumTemperature          float64 `json:"dhwMaximumTemperature"`
			MaximumPreheatingTime          int     `json:"maximumPreheatingTime"`
			ParalellTankLoadingAllowed     bool    `json:"paralellTankLoadingAllowed"`
		} `json:"system"`
		Zones            []ConfigurationZone             `json:"zones"`
		Circuits         []ConfigurationCircuit          `json:"circuits"`
		Dhw              []ConfigurationDhw              `json:"dhw"`
		DomesticHotWater []ConfigurationDomesticHotWater `json:"domesticHotWater"`
	} `json:"configuration"`
}

type TimeProgram

type TimeProgram struct {
	MetaInfo  MetaInfo   `json:"metaInfo"`
	Monday    []Setpoint `json:"monday"`
	Tuesday   []Setpoint `json:"tuesday"`
	Wednesday []Setpoint `json:"wednesday"`
	Thursday  []Setpoint `json:"thursday"`
	Friday    []Setpoint `json:"friday"`
	Saturday  []Setpoint `json:"saturday"`
	Sunday    []Setpoint `json:"sunday"`
}

type TimeSlot

type TimeSlot struct {
	StartTime int `json:"startTime"`
	EndTime   int `json:"endTime"`
}

type TokenRefresher

type TokenRefresher interface {
	RefreshToken(token *oauth2.Token) (*oauth2.Token, error)
}

type TokenRequestStruct

type TokenRequestStruct struct {
	oauth2.Token
	RefreshExpiresIn int64  `json:"refresh_expires_in"`
	NotBeforePolicy  int    `json:"not-before-policy"`
	SessionState     string `json:"session_state"`
	Scope            string `json:"scope"`
}

type TokenSource

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

func (*TokenSource) Token

func (ts *TokenSource) Token() (*oauth2.Token, error)

Jump to

Keyboard shortcuts

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