vrm

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

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

Go to latest
Published: Oct 5, 2020 License: MIT Imports: 15 Imported by: 0

README

Victron Energy Go Clients

NOTE: This project is not production ready, yet.

This project makes Victron's Remote Management API and its MQTT broker accessible in Go.

Build

$ make build-static

Documentation

Index

Examples

Constants

View Source
const (

	// Widgets
	WidgetGraph               string = "Graph"
	WidgetVeBusState          string = "VeBusState"
	WidgetMPPTState           string = "MPPTState"
	WidgetBatterySummary      string = "BatterySummary"
	WidgetSolarChargerSummary string = "SolarChargerSummary"
	WidgetBMSDiagnostics      string = "BMSDiagnostics"
	WidgetHistoricData        string = "HistoricData"
	WidgetIOExtenderInOut     string = "IOExtenderInOut"
	WidgetLithiumBMS          string = "LithiumBMS"
	WidgetMotorSummary        string = "MotorSummary"
	WidgetPVInverterStatus    string = "PVInverterStatus"
	WidgetStatus              string = "Status"
	WidgetAlarm               string = "Alarm"
	WidgetGPS                 string = "GPS"
	WidgetHoursOfAC           string = "HoursOfAC"

	DemoUserID int = 22
)

Variables

This section is empty.

Functions

func BrokerIndexFromPortalID

func BrokerIndexFromPortalID(portalID string) int

func BrokerURL

func BrokerURL(brokerIndex int) string

func ConnectBroker

func ConnectBroker(broker, username, password string) (*brokerConnection, error)

func Login

func Login(username, password string, opts ...LoginOption) (*vrmSession, error)
Example
package main

import (
	"github.com/rs/zerolog/log"

	"victron/vrm"
)

func main() {
	session, err := vrm.Login("username", "password", vrm.WithSMSToken("123456"))
	if err != nil {
		log.Error().Err(err).Msg("login failed")
	}

	_ = session.Logout()
}
Output:

func LoginAsDemo

func LoginAsDemo() (*vrmSession, error)

func MapTemplate

func MapTemplate(templateText string, replacements map[string]string) (string, error)

MapTemplate formats the given string by applying the replacement map

Types

type DiagnosticsResponse

type DiagnosticsResponse struct {
	Success bool `json:"success"`
	Records []struct {
		ID                      uint            `json:"id"`
		Device                  string          `json:"Device"`
		Instance                uint            `json:"instance"`
		Description             string          `json:"description"`
		SiteID                  uint            `json:"idSite"`
		Timestamp               uint            `json:"timestamp"`
		FormatWithUnit          string          `json:"formatWithUnit"`
		DBusServiceType         json.RawMessage `json:"dbusServiceType"`
		DBusPath                json.RawMessage `json:"dbusPath"`
		FormattedValue          json.RawMessage `json:"formattedValue"`
		DataAttributeID         uint            `json:"idDataAttribute"`
		DataAttributeEnumValues []struct {
			Name  string          `json:"nameEnum"`
			Value json.RawMessage `json:"valueEnum"`
		} `json:"dataAttributeEnumValues"`
	} `json:"records"`
	NumRecords uint `json:"num_records"`
}

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type InstallationsResponse

type InstallationsResponse struct {
	Success bool `json:"success"`
	Records []struct {
		Name            string `json:"name"`
		SiteID          int    `json:"idSite"`
		UserID          int    `json:"idUser"`
		PVMax           int    `json:"pvMax"`
		ReportsEnabled  bool   `json:"reports_enabled"`
		AccessLevel     int    `json:"accessLevel"`
		Timezone        string `json:"timezone"`
		Owner           bool   `json:"owner"`
		Geofence        string `json:"geofence"`
		GeofenceEnabled bool   `json:"geofenceEnabled"`
		DeviceIcon      string `json:"device_icon"`
		Alarm           bool   `json:"alarm,omitempty"`
		LastTimestamp   int    `json:"last_timestamp,omitempty"`
		Tags            []struct {
			TagID int    `json:"idTag"`
			Name  string `json:"name"`
		} `json:"tags,omitempty"`
		TimezoneOffset int `json:"timezone_offset,omitempty"`
		Extended       []struct {
			DataAttributeID int             `json:"idDataAttribute"`
			Code            string          `json:"code"`
			Description     string          `json:"description"`
			FormatWithUnit  string          `json:"formatWithUnit"`
			RawValue        json.RawMessage `json:"rawValue"`
			TextValue       string          `json:"textValue"`
			FormattedValue  string          `json:"formattedValue"`
		} `json:"extended,omitempty"`
		CurrentTime string `json:"current_time,omitempty"`
	} `json:"records"`
}

type LoginOption

type LoginOption func(*LoginRequest)

func WithSMSToken

func WithSMSToken(smsToken string) LoginOption

type LoginRequest

type LoginRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
	SMSToken string `json:"sms_token,omitempty"`
}

type StatsResponse

type StatsResponse struct {
	Success bool `json:"success"`
	Records struct {
		Pc [][]json.RawMessage `json:"Pc"`
	} `json:"records"`
	Totals struct {
		Pb  float64 `json:"Pb"`
		Pc  float64 `json:"Pc"`
		Gb  float64 `json:"Gb"`
		Gc  float64 `json:"Gc"`
		Pg  float64 `json:"Pg"`
		Bc  float64 `json:"Bc"`
		Kwh float64 `json:"kwh"`
	} `json:"totals"`
}

type SystemOverviewResponse

type SystemOverviewResponse struct {
	Success bool `json:"success"`
	Records struct {
		Devices []struct {
			Name                 string `json:"name"`
			ProductCode          string `json:"productCode"`
			ProductName          string `json:"productName"`
			FirmwareVersion      string `json:"firmwareVersion,omitempty"`
			LastConnection       uint   `json:"lastConnection"`
			Class                string `json:"class"`
			LoggingInterval      uint   `json:"loggingInterval"`
			LastPowerUpOrRestart uint   `json:"lastPowerUpOrRestart,omitempty"`
			Instance             uint   `json:"instance,omitempty"`
		} `json:"devices"`
		UnconfiguredDevices bool `json:"unconfigured_devices"`
	} `json:"records"`
}

type URLParams

type URLParams map[string]string

type UsersResponse

type UsersResponse struct {
	Success bool `json:"success"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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