powerwall

package
v0.0.0-...-6ca3741 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package powerwall extracts information from a powerwall on demand.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregates

type Aggregates struct {
	Site    MeterDetails `json:"site"`
	Battery MeterDetails `json:"battery"`
	Load    MeterDetails `json:"load"`
	Solar   MeterDetails `json:"solar"`
}

type Config

type Config struct {
	VIN string `json:"vin"`
}

type Diagnostic

type Diagnostic struct {
	Name       string `json:"name"`     // "Commissioning"
	Category   string `json:"category"` // "InternalComms"
	Disruptive bool   `json:"disruptive"`
	// inputs is null, so I cannot determine the schema
	Checks []DiagnosticCheck `json:"checks"`
}

type DiagnosticCheck

type DiagnosticCheck struct {
	Name      string `json:"name"`   // CAN connectivity
	Status    string `json:"status"` // fail
	StartTime Time   `json:"start_time"`
	EndTime   Time   `json:"end_time"`
	Message   string `json:"message"`
}

type Duration

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

func (Duration) Duration

func (d Duration) Duration() time.Duration

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

type FloatDurationSeconds

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

func (FloatDurationSeconds) Duration

func (f FloatDurationSeconds) Duration() time.Duration

func (*FloatDurationSeconds) UnmarshalJSON

func (f *FloatDurationSeconds) UnmarshalJSON(b []byte) error

type GridCode

type GridCode struct {
	Code         string `json:"grid_code"` // "60Hz_240V_s_UL1741SA:2018_ISO-NE"
	Voltage      int    `json:"grid_voltage_setting"`
	Frequency    int    `json:"grid_freq_setting"`
	PhaseSetting string `json:"grid_phase_setting"` // "Split
	Country      string `json:"country"`
	State        string `json:"state"`
	Distributor  string `json:"distributor"` // *
	Utility      string `json:"utility"`     // Eversource Energy (NSTAR-Cambridge Electric Light)
	Retailer     string `json:"retailer"`    // *
	Region       string `json:"region"`      // UL1741SA-IOS-NE:2018

}

type GridState

type GridState int
const (
	Compliant GridState = iota
	Qualifying
	Uncompliant
)

func (GridState) String

func (g GridState) String() string

func (*GridState) UnmarshalJSON

func (g *GridState) UnmarshalJSON(b []byte) error

type GridStatus

type GridStatus struct {
	Status SystemStatus `json:"grid_status"`          // SystemGridConnected
	Active bool         `json:"grid_services_active"` // false in normal operation.  Unclear what this means.
}

type HTTPMethod

type HTTPMethod string

type IP

type IP struct {
	IPAddress string `json:"ip"`
	Netmask   int    `json:"netmask"`
}

type Installer

type Installer struct {
	Company                string   `json:"company"`
	CustomerID             string   `json:"customer_id"`
	Phone                  string   `json:"phone"`
	Email                  string   `json:"email"`
	Location               string   `json:"location"`
	Mounting               string   `json:"mounting"`
	Wiring                 string   `json:"wiring"`
	BackupConfiguration    string   `json:"backup_configuration"`
	SolarInstallation      string   `json:"solar_installation"`
	HasStackKit            bool     `json:"has_stack_kit"`
	HasPowerlineToEthernet bool     `json:"has_powerline_to_ethernet"`
	RunSitemaster          bool     `json:"run_sitemaster"`
	VerifiedConfig         bool     `json:"verified_config"`
	InstallationTypes      []string `json:"installation_types"`
}

type MeterDetails

type MeterDetails struct {
	LastCommunicationTime             Time    `json:"last_communication_time"` // YYYY-MM-DDTHH:MM:SS-HH:MM
	InstantPower                      float64 `json:"instant_power"`
	InstantReactivePower              float64 `json:"instant_reactive_power"`
	InstantApparentPower              float64 `json:"instant_apparant_power"`
	Frequency                         float64 `json:"frequency"`
	EnergyExported                    float64 `json:"energy_exported"`
	EnergyImported                    float64 `json:"energy_imported"`
	InstantAverageVoltage             float64 `json:"instant_average_voltage"`
	InstantTotalCurrent               float64 `json:"instant_total_current"`
	IACurrent                         float64 `json:"i_a_current"`
	IBCurrent                         float64 `json:"i_b_current"`
	ICCurrent                         float64 `json:"i_c_current"`
	LastPhaseVoltageCommunicationTime Time    `json:"last_phase_voltage_communication_time"`
	LastPhasePowerCommunicationTime   Time    `json:"last_phase_power_communication_time"`
	// Would like to turn Timeout into a time.Duration, but I need to know units.
	Timeout int64 `json:"timeout"`
}

type Monitor

type Monitor interface {
	io.Closer
	GetNetworks() ([]Network, error)
	GetSiteInfo() (*SiteInfo, error)
	GetOperation() (*Operation, error)
	GetConfig() (*Config, error)
	GetPowerwalls() (*Powerwalls, error)
	GetStatus() (*Status, error)
	GetSiteMaster() (*SiteMaster, error)
	GetAggregates() (*Aggregates, error)
	GetSOE() (*SOE, error)
	GetGridStatus() (*GridStatus, error)
	GetSolars() ([]Solar, error)
	GetInstaller() (*Installer, error)
}

func New

func New(opts Options) (Monitor, error)

New returns a powerwall.Monitor that can extract information from the gateway.

type Network

type Network struct {
	Name      string           `json:"network_name"`
	Interface NetworkInterface `json:"interface"`
	DHCP      bool             `json:"dhcp"`
	Enabled   bool             `json:"enabled"`
	ExtraIPs  []IP             `json:"extra_ips"`
	Active    bool             `json:"active"`
	Primary   bool             `json:"primary"`
	Info      NetworkInfo      `json:"iface_network_info"`
}

type NetworkInfo

type NetworkInfo struct {
	Name            string           `json:"network_name"`
	Networks        []IP             `json:"networks"`
	Gateway         string           `json:"gateway"`
	Interface       NetworkInterface `json:"interface"`
	State           string           `json:"state"`
	StateReason     string           `json:"state_reason"`
	SignalStrength  int              `json:"signal_strength"`
	HardwareAddress string           `json:"hw_address"`
}

type NetworkInterface

type NetworkInterface int
const (
	Ethernet NetworkInterface = iota
	Cellular
	Wifi
)

func (NetworkInterface) String

func (n NetworkInterface) String() string

func (*NetworkInterface) UnmarshalJSON

func (n *NetworkInterface) UnmarshalJSON(b []byte) error

type OperatingMode

type OperatingMode int
const (
	Backup OperatingMode = iota
	SelfConsumption
	Autonomous
	Scheduler
	SiteControl
)

func (OperatingMode) String

func (o OperatingMode) String() string

func (*OperatingMode) UnmarshalJSON

func (n *OperatingMode) UnmarshalJSON(b []byte) error

type Operation

type Operation struct {
	RealMode                OperatingMode `json:"real_mode"` // "backup"
	BackupReservePercent    float64       `json:"backup_reserve_percent"`
	FreqShiftLoadShedSOE    float64       `json:"freq_shift_load_shed_soe"`
	FreqShiftLoadShedDeltaF float64       `json:"freq_shift_load_shed_delta_f"`
}

type Options

type Options struct {
	// Gateway is the hostname or IP address of the Tesla
	// Energy gateway.
	Gateway string
	// Username should be the "customer" username for the gateway.
	// You'll have to setup these credentials by pointing your
	// browser at the gateway and going through the customer
	// account setup flow before using this monitor.
	Username string
	// Password should be the "customer" password for the gateway.
	Password string
}

Options describes the information needed to extract information from the Tesla Energy Gateway about your powerwalls.

type Powerwall

type Powerwall struct {
	UnusedType                  string `json:"Type"`
	PackagePartNumber           string
	PackageSerialNumber         string
	Type                        string               `json:"type"`       // acpw
	GridState                   GridState            `json:"grid_state"` // "Grid_Uncompliant"
	GridReconnectionTimeSeconds FloatDurationSeconds `json:"grid_reconnection_time_seconds"`
	UnderPhaseDetection         bool                 `json:"under_phase_detection"`
	Updating                    bool                 `json:"updating"`
	CommissioningDiagnostic     Diagnostic           `json:"commissioning_diagnostic"`
	UpdateDiagnostic            Diagnostic           `json:"update_diagnostic"`
}

type Powerwalls

type Powerwalls struct {
	Enumerating                bool        `json:"enumerating"`
	Updating                   bool        `json:"updating"`
	CheckingIfOffGrid          bool        `json:"checking_if_offgrid"`
	RunningPhaseDetection      bool        `json:"running_phase_detection"`
	PhaseDetectionLastError    string      `json:"phase_detection_last_error"`
	BubbleShedding             bool        `json:"bubble_shedding"`
	OnGridCheckError           string      `json:"on_grid_check_error"`
	GridQualifying             bool        `json:"grid_qualifying"`
	GridCodeValidating         bool        `json:"grid_code_validating"`
	PhaseDetectionNotAvailable bool        `json:"phase_detection_not_available"`
	Powerwalls                 []Powerwall `json:"powerwalls"`
}

type SOE

type SOE struct {
	Percentage float64 `json:"percentage"`
}

type SiteInfo

type SiteInfo struct {
	MaxSystemEnergykWh     int64    `json:"max_system_energy_kWh"`
	MaxSystemPowerkW       int64    `json:"max_system_power_kW"`
	SiteName               string   `json:"site_name"`
	TimeZone               TimeZone `json:"timezone"`
	MaxSiteMeterPowerkW    int64    `json:"max_site_meter_power_kW"`
	MinSiteMeterPowerkW    int64    `json:"min_site_meter_power_kW"`
	NominalSystemEnergykWh float64  `json:"nominal_system_energy_kWh"`
	NominalSystemPowerkW   float64  `json:"nominal_system_power_kW"`
	GridCode               GridCode `json:"grid_code"`
}

type SiteMaster

type SiteMaster struct {
	Status           string `json:"status"` // StatusUp
	Running          bool   `json:"running"`
	ConnectedToTesla bool   `json:"connected_to_tesla"`
	PowerSupplyMode  bool   `json:"power_supply_mode"`
}

type Solar

type Solar struct {
	Brand            string `json:"brand"`              // "SolarEdge Technologies"
	Model            string `json:"model"`              // SE 1000A-US (240V)
	PowerRatingWatts int    `json:"power_rating_watts"` // 15170
}

type Status

type Status struct {
	StartTime       Time     `json:"start_time"`
	UpTime          Duration `json:"up_time_seconds"`
	IsNew           bool     `json:"is_new"`
	Version         string   `json:"version"`          // 20.49.0
	GitHash         string   `json:"git_hash"`         // hexadecimal sequence
	CommissionCount int      `json:"commission_count"` // 0
	// jrester code suggests gateway1 == "hec", gateway2 == "teg",
	// and a not yet attributed value "smc"
	DeviceType string `json:"device_type"` // "hec"
	// jrester code suggests sync type values can include
	// "v1", "v2", and "v2.1"
	SyncType string `json:"sync_type"` // v1
}

type SystemStatus

type SystemStatus int
const (
	GridConnected SystemStatus = iota
	IslandedReady
	IslandedActive
	TransitionToGrid
)

func (SystemStatus) String

func (s SystemStatus) String() string

func (*SystemStatus) UnmarshalJSON

func (s *SystemStatus) UnmarshalJSON(b []byte) error

type Time

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

func (Time) Time

func (t Time) Time() time.Time

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

type TimeZone

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

func (TimeZone) Location

func (t TimeZone) Location() *time.Location

func (TimeZone) MarshalJSON

func (t TimeZone) MarshalJSON() ([]byte, error)

func (*TimeZone) UnmarshalJSON

func (t *TimeZone) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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