wallconnector

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

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

Go to latest
Published: Jul 19, 2024 License: MIT Imports: 14 Imported by: 0

README

wallconnector

A super simple client which can query data from Tesla's Wall Connector v3.

This library also exposes a prometheus collector. The types are defined under the metrics.proto annotations. To run it, use go run ./cmd/prom -target <wall_connector_ip>.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Conversion_name = map[int32]string{
		0: "NONE",
		1: "INVERSE",
		2: "WH_TO_J",
	}
	Conversion_value = map[string]int32{
		"NONE":    0,
		"INVERSE": 1,
		"WH_TO_J": 2,
	}
)

Enum value maps for Conversion.

View Source
var (
	Metric_Type_name = map[int32]string{
		0: "GAUGE",
		1: "COUNTER",
	}
	Metric_Type_value = map[string]int32{
		"GAUGE":   0,
		"COUNTER": 1,
	}
)

Enum value maps for Metric_Type.

View Source
var (
	// optional com.winstondurand.wallconnector.Metric prometheus = 50000;
	E_Prometheus = &file_metrics_proto_extTypes[0]
)

Extension fields to descriptorpb.FieldOptions.

View Source
var File_metrics_proto protoreflect.FileDescriptor

Functions

func NewCollector

func NewCollector(client *Client) prometheus.Collector

NewCollector creates a new collector for wallconnector stats.

func WithTimeout

func WithTimeout(t time.Duration) func(*connectorOpts)

func WithTransport

func WithTransport(t http.RoundTripper) func(*connectorOpts)

Types

type Client

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

func NewClient

func NewClient(addr string, opts ...ConnectorConfig) (*Client, error)

func (*Client) Lifetime

func (c *Client) Lifetime(ctx context.Context) (*Lifetime, error)

Lifetime returns the lifetime stats of the wallconnector.

func (*Client) Version

func (c *Client) Version(ctx context.Context) (*Version, error)

Version returns the version info of the wallconnector.

func (*Client) Vitals

func (c *Client) Vitals(ctx context.Context) (*Vitals, error)

Vitals returns the current vitals of the wallconnector.

func (*Client) Wifi

func (c *Client) Wifi(ctx context.Context) (*Wifi, error)

WifiStatus returns the wifi status of the wallconnector.

type ConnectorConfig

type ConnectorConfig func(*connectorOpts)

type Conversion

type Conversion int32
const (
	Conversion_NONE Conversion = 0
	// Compute the inverse of the value.
	Conversion_INVERSE Conversion = 1
	// Convert from watt-hours to joules.
	Conversion_WH_TO_J Conversion = 2
)

func (Conversion) Descriptor

func (Conversion) Descriptor() protoreflect.EnumDescriptor

func (Conversion) Enum

func (x Conversion) Enum() *Conversion

func (Conversion) EnumDescriptor deprecated

func (Conversion) EnumDescriptor() ([]byte, []int)

Deprecated: Use Conversion.Descriptor instead.

func (Conversion) Number

func (x Conversion) Number() protoreflect.EnumNumber

func (Conversion) String

func (x Conversion) String() string

func (Conversion) Type

type Lifetime

type Lifetime struct {
	ContactorCycles       int32   `protobuf:"varint,1,opt,name=contactor_cycles,json=contactorCycles,proto3" json:"contactor_cycles,omitempty"`
	ContactorCyclesLoaded int32   `` /* 127-byte string literal not displayed */
	AlertCount            int32   `protobuf:"varint,3,opt,name=alert_count,json=alertCount,proto3" json:"alert_count,omitempty"`
	ThermalFoldbackCount  int32   `protobuf:"varint,4,opt,name=thermal_foldback_count,json=thermalFoldbackCount,proto3" json:"thermal_foldback_count,omitempty"`
	AvgStartupTime        float64 `protobuf:"fixed64,5,opt,name=avg_startup_time,json=avgStartupTime,proto3" json:"avg_startup_time,omitempty"`
	ChargeStarts          int32   `protobuf:"varint,6,opt,name=charge_starts,json=chargeStarts,proto3" json:"charge_starts,omitempty"`
	EnergyWh              int64   `protobuf:"varint,7,opt,name=energy_wh,json=energyWh,proto3" json:"energy_wh,omitempty"`
	ConnectorCycles       int32   `protobuf:"varint,8,opt,name=connector_cycles,json=connectorCycles,proto3" json:"connector_cycles,omitempty"`
	UptimeS               int64   `protobuf:"varint,9,opt,name=uptime_s,json=uptimeS,proto3" json:"uptime_s,omitempty"`
	ChargeTimeS           int32   `protobuf:"varint,10,opt,name=charge_time_s,json=chargeTimeS,proto3" json:"charge_time_s,omitempty"`
	// contains filtered or unexported fields
}

Lifetime represents the lifetime stats of the wallconnector.

See Wall Monitor FAQ for more details: https://wallmonitor.app/faq/explain_lifetime

func (*Lifetime) Descriptor deprecated

func (*Lifetime) Descriptor() ([]byte, []int)

Deprecated: Use Lifetime.ProtoReflect.Descriptor instead.

func (*Lifetime) GetAlertCount

func (x *Lifetime) GetAlertCount() int32

func (*Lifetime) GetAvgStartupTime

func (x *Lifetime) GetAvgStartupTime() float64

func (*Lifetime) GetChargeStarts

func (x *Lifetime) GetChargeStarts() int32

func (*Lifetime) GetChargeTimeS

func (x *Lifetime) GetChargeTimeS() int32

func (*Lifetime) GetConnectorCycles

func (x *Lifetime) GetConnectorCycles() int32

func (*Lifetime) GetContactorCycles

func (x *Lifetime) GetContactorCycles() int32

func (*Lifetime) GetContactorCyclesLoaded

func (x *Lifetime) GetContactorCyclesLoaded() int32

func (*Lifetime) GetEnergyWh

func (x *Lifetime) GetEnergyWh() int64

func (*Lifetime) GetThermalFoldbackCount

func (x *Lifetime) GetThermalFoldbackCount() int32

func (*Lifetime) GetUptimeS

func (x *Lifetime) GetUptimeS() int64

func (*Lifetime) ProtoMessage

func (*Lifetime) ProtoMessage()

func (*Lifetime) ProtoReflect

func (x *Lifetime) ProtoReflect() protoreflect.Message

func (*Lifetime) Reset

func (x *Lifetime) Reset()

func (*Lifetime) String

func (x *Lifetime) String() string

type Metric

type Metric struct {
	Name       string      `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Type       Metric_Type `protobuf:"varint,2,opt,name=type,proto3,enum=com.winstondurand.wallconnector.Metric_Type" json:"type,omitempty"`
	Help       string      `protobuf:"bytes,3,opt,name=help,proto3" json:"help,omitempty"`
	Labels     []string    `protobuf:"bytes,4,rep,name=labels,proto3" json:"labels,omitempty"`
	Conversion Conversion  `protobuf:"varint,5,opt,name=conversion,proto3,enum=com.winstondurand.wallconnector.Conversion" json:"conversion,omitempty"`
	// Skip this field when generating the prometheus metrics.
	// Note: Even when this is set to true, the field still requires a name.
	Skip bool `protobuf:"varint,20,opt,name=skip,proto3" json:"skip,omitempty"`
	// contains filtered or unexported fields
}

func (*Metric) ConvertValue

func (m *Metric) ConvertValue(v float64) float64

func (*Metric) Descriptor deprecated

func (*Metric) Descriptor() ([]byte, []int)

Deprecated: Use Metric.ProtoReflect.Descriptor instead.

func (*Metric) GetConversion

func (x *Metric) GetConversion() Conversion

func (*Metric) GetHelp

func (x *Metric) GetHelp() string

func (*Metric) GetLabels

func (x *Metric) GetLabels() []string

func (*Metric) GetName

func (x *Metric) GetName() string

func (*Metric) GetSkip

func (x *Metric) GetSkip() bool

func (*Metric) GetType

func (x *Metric) GetType() Metric_Type

func (*Metric) LabelKeys

func (m *Metric) LabelKeys() []string

func (*Metric) LabelValues

func (m *Metric) LabelValues() []string

func (*Metric) ProtoMessage

func (*Metric) ProtoMessage()

func (*Metric) ProtoReflect

func (x *Metric) ProtoReflect() protoreflect.Message

func (*Metric) Reset

func (x *Metric) Reset()

func (*Metric) String

func (x *Metric) String() string

type Metric_Type

type Metric_Type int32
const (
	Metric_GAUGE   Metric_Type = 0
	Metric_COUNTER Metric_Type = 1
)

func (Metric_Type) Descriptor

func (Metric_Type) Enum

func (x Metric_Type) Enum() *Metric_Type

func (Metric_Type) EnumDescriptor deprecated

func (Metric_Type) EnumDescriptor() ([]byte, []int)

Deprecated: Use Metric_Type.Descriptor instead.

func (Metric_Type) Number

func (x Metric_Type) Number() protoreflect.EnumNumber

func (Metric_Type) String

func (x Metric_Type) String() string

func (Metric_Type) Type

type Version

type Version struct {
	FirmwareVersion string `protobuf:"bytes,1,opt,name=firmware_version,json=firmwareVersion,proto3" json:"firmware_version,omitempty"`
	PartNumber      string `protobuf:"bytes,2,opt,name=part_number,json=partNumber,proto3" json:"part_number,omitempty"`
	SerialNumber    string `protobuf:"bytes,3,opt,name=serial_number,json=serialNumber,proto3" json:"serial_number,omitempty"`
	// contains filtered or unexported fields
}

Version represents the version info of the wallconnector.

func (*Version) Descriptor deprecated

func (*Version) Descriptor() ([]byte, []int)

Deprecated: Use Version.ProtoReflect.Descriptor instead.

func (*Version) GetFirmwareVersion

func (x *Version) GetFirmwareVersion() string

func (*Version) GetPartNumber

func (x *Version) GetPartNumber() string

func (*Version) GetSerialNumber

func (x *Version) GetSerialNumber() string

func (*Version) ProtoMessage

func (*Version) ProtoMessage()

func (*Version) ProtoReflect

func (x *Version) ProtoReflect() protoreflect.Message

func (*Version) Reset

func (x *Version) Reset()

func (*Version) String

func (x *Version) String() string

type Vitals

type Vitals struct {
	ContactorClosed   bool    `protobuf:"varint,1,opt,name=contactor_closed,json=contactorClosed,proto3" json:"contactor_closed,omitempty"`
	VehicleConnected  bool    `protobuf:"varint,2,opt,name=vehicle_connected,json=vehicleConnected,proto3" json:"vehicle_connected,omitempty"`
	SessionS          float64 `protobuf:"fixed64,3,opt,name=session_s,json=sessionS,proto3" json:"session_s,omitempty"`
	GridV             float64 `protobuf:"fixed64,4,opt,name=grid_v,json=gridV,proto3" json:"grid_v,omitempty"`
	GridHz            float64 `protobuf:"fixed64,5,opt,name=grid_hz,json=gridHz,proto3" json:"grid_hz,omitempty"`
	VehicleCurrentA   float64 `protobuf:"fixed64,6,opt,name=vehicle_current_a,json=vehicleCurrentA,proto3" json:"vehicle_current_a,omitempty"`
	CurrentAA         float64 `protobuf:"fixed64,7,opt,name=currentA_a,json=currentAA,proto3" json:"currentA_a,omitempty"`
	CurrentBA         float64 `protobuf:"fixed64,8,opt,name=currentB_a,json=currentBA,proto3" json:"currentB_a,omitempty"`
	CurrentCA         float64 `protobuf:"fixed64,9,opt,name=currentC_a,json=currentCA,proto3" json:"currentC_a,omitempty"`
	CurrentNA         float64 `protobuf:"fixed64,10,opt,name=currentN_a,json=currentNA,proto3" json:"currentN_a,omitempty"`
	VoltageAV         float64 `protobuf:"fixed64,11,opt,name=voltageA_v,json=voltageAV,proto3" json:"voltageA_v,omitempty"`
	VoltageBV         float64 `protobuf:"fixed64,12,opt,name=voltageB_v,json=voltageBV,proto3" json:"voltageB_v,omitempty"`
	VoltageCV         float64 `protobuf:"fixed64,13,opt,name=voltageC_v,json=voltageCV,proto3" json:"voltageC_v,omitempty"`
	RelayCoilV        float64 `protobuf:"fixed64,14,opt,name=relay_coil_v,json=relayCoilV,proto3" json:"relay_coil_v,omitempty"`
	PcbaTempC         float64 `protobuf:"fixed64,15,opt,name=pcba_temp_c,json=pcbaTempC,proto3" json:"pcba_temp_c,omitempty"`
	HandleTempC       float64 `protobuf:"fixed64,16,opt,name=handle_temp_c,json=handleTempC,proto3" json:"handle_temp_c,omitempty"`
	McuTempC          float64 `protobuf:"fixed64,17,opt,name=mcu_temp_c,json=mcuTempC,proto3" json:"mcu_temp_c,omitempty"`
	UptimeS           float64 `protobuf:"fixed64,18,opt,name=uptime_s,json=uptimeS,proto3" json:"uptime_s,omitempty"`
	InputThermopileUv float64 `protobuf:"fixed64,19,opt,name=input_thermopile_uv,json=inputThermopileUv,proto3" json:"input_thermopile_uv,omitempty"`
	ProxV             float64 `protobuf:"fixed64,20,opt,name=prox_v,json=proxV,proto3" json:"prox_v,omitempty"`
	PilotHighV        float64 `protobuf:"fixed64,21,opt,name=pilot_high_v,json=pilotHighV,proto3" json:"pilot_high_v,omitempty"`
	PilotLowV         float64 `protobuf:"fixed64,22,opt,name=pilot_low_v,json=pilotLowV,proto3" json:"pilot_low_v,omitempty"`
	SessionEnergyWh   float64 `protobuf:"fixed64,23,opt,name=session_energy_wh,json=sessionEnergyWh,proto3" json:"session_energy_wh,omitempty"`
	ConfigStatus      int32   `protobuf:"varint,24,opt,name=config_status,json=configStatus,proto3" json:"config_status,omitempty"`
	EvseState         int32   `protobuf:"varint,25,opt,name=evse_state,json=evseState,proto3" json:"evse_state,omitempty"`
	CurrentAlerts     []int32 `protobuf:"varint,26,rep,packed,name=current_alerts,json=currentAlerts,proto3" json:"current_alerts,omitempty"`
	// contains filtered or unexported fields
}

Vitals represents the current state of the wallconnector.

Note: Several fields like SessionS, and UptimeS are probably ints, but they're it's impossible to say parsing JSON from the API.

See Wall Monitor FAQ for more details: https://wallmonitor.app/faq/explain_technical

func (*Vitals) Descriptor deprecated

func (*Vitals) Descriptor() ([]byte, []int)

Deprecated: Use Vitals.ProtoReflect.Descriptor instead.

func (*Vitals) GetConfigStatus

func (x *Vitals) GetConfigStatus() int32

func (*Vitals) GetContactorClosed

func (x *Vitals) GetContactorClosed() bool

func (*Vitals) GetCurrentAA

func (x *Vitals) GetCurrentAA() float64

func (*Vitals) GetCurrentAlerts

func (x *Vitals) GetCurrentAlerts() []int32

func (*Vitals) GetCurrentBA

func (x *Vitals) GetCurrentBA() float64

func (*Vitals) GetCurrentCA

func (x *Vitals) GetCurrentCA() float64

func (*Vitals) GetCurrentNA

func (x *Vitals) GetCurrentNA() float64

func (*Vitals) GetEvseState

func (x *Vitals) GetEvseState() int32

func (*Vitals) GetGridHz

func (x *Vitals) GetGridHz() float64

func (*Vitals) GetGridV

func (x *Vitals) GetGridV() float64

func (*Vitals) GetHandleTempC

func (x *Vitals) GetHandleTempC() float64

func (*Vitals) GetInputThermopileUv

func (x *Vitals) GetInputThermopileUv() float64

func (*Vitals) GetMcuTempC

func (x *Vitals) GetMcuTempC() float64

func (*Vitals) GetPcbaTempC

func (x *Vitals) GetPcbaTempC() float64

func (*Vitals) GetPilotHighV

func (x *Vitals) GetPilotHighV() float64

func (*Vitals) GetPilotLowV

func (x *Vitals) GetPilotLowV() float64

func (*Vitals) GetProxV

func (x *Vitals) GetProxV() float64

func (*Vitals) GetRelayCoilV

func (x *Vitals) GetRelayCoilV() float64

func (*Vitals) GetSessionEnergyWh

func (x *Vitals) GetSessionEnergyWh() float64

func (*Vitals) GetSessionS

func (x *Vitals) GetSessionS() float64

func (*Vitals) GetUptimeS

func (x *Vitals) GetUptimeS() float64

func (*Vitals) GetVehicleConnected

func (x *Vitals) GetVehicleConnected() bool

func (*Vitals) GetVehicleCurrentA

func (x *Vitals) GetVehicleCurrentA() float64

func (*Vitals) GetVoltageAV

func (x *Vitals) GetVoltageAV() float64

func (*Vitals) GetVoltageBV

func (x *Vitals) GetVoltageBV() float64

func (*Vitals) GetVoltageCV

func (x *Vitals) GetVoltageCV() float64

func (*Vitals) ProtoMessage

func (*Vitals) ProtoMessage()

func (*Vitals) ProtoReflect

func (x *Vitals) ProtoReflect() protoreflect.Message

func (*Vitals) Reset

func (x *Vitals) Reset()

func (*Vitals) String

func (x *Vitals) String() string

type Wifi

type Wifi struct {
	WifiSignalStrength int32 `protobuf:"varint,1,opt,name=wifi_signal_strength,json=wifiSignalStrength,proto3" json:"wifi_signal_strength,omitempty"`
	WifiRssi           int32 `protobuf:"varint,2,opt,name=wifi_rssi,json=wifiRssi,proto3" json:"wifi_rssi,omitempty"`
	WifiSnr            int32 `protobuf:"varint,3,opt,name=wifi_snr,json=wifiSnr,proto3" json:"wifi_snr,omitempty"`
	WifiConnected      bool  `protobuf:"varint,4,opt,name=wifi_connected,json=wifiConnected,proto3" json:"wifi_connected,omitempty"`
	Internet           bool  `protobuf:"varint,5,opt,name=internet,proto3" json:"internet,omitempty"`
	// contains filtered or unexported fields
}

Wifi represents the wifi info of the wallconnector.

func (*Wifi) Descriptor deprecated

func (*Wifi) Descriptor() ([]byte, []int)

Deprecated: Use Wifi.ProtoReflect.Descriptor instead.

func (*Wifi) GetInternet

func (x *Wifi) GetInternet() bool

func (*Wifi) GetWifiConnected

func (x *Wifi) GetWifiConnected() bool

func (*Wifi) GetWifiRssi

func (x *Wifi) GetWifiRssi() int32

func (*Wifi) GetWifiSignalStrength

func (x *Wifi) GetWifiSignalStrength() int32

func (*Wifi) GetWifiSnr

func (x *Wifi) GetWifiSnr() int32

func (*Wifi) ProtoMessage

func (*Wifi) ProtoMessage()

func (*Wifi) ProtoReflect

func (x *Wifi) ProtoReflect() protoreflect.Message

func (*Wifi) Reset

func (x *Wifi) Reset()

func (*Wifi) String

func (x *Wifi) String() string

Directories

Path Synopsis
cmd
prom command
Pull stats from a wall connector and serve them as prometheus metrics.
Pull stats from a wall connector and serve them as prometheus metrics.
proxy command
Create a proxy server that will forward requests to the real server and return the response to the client.
Create a proxy server that will forward requests to the real server and return the response to the client.

Jump to

Keyboard shortcuts

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