gotracerwifi

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: LGPL-3.0 Imports: 5 Imported by: 0

README

Go Tracer WiFi

A Go package to communicate with an EPSolar Tracer A/AN charge controller equipped with the eBox-Wifi-01 or HiFlying Elfin EW11

Only tested with EPSolar Tracer3210AN equipped with a eBox-Wifi-01 and HiFlying Elfin EW11

Example

TCP example
package main

import (
	"encoding/json"
	"github.com/pterm/pterm"
	"github.com/Gaz492/gotracerwifi"
	"time"
)

func main()  {
	tracer, err := goTracerWiFi.Status("192.168.1.181", "8088", 5 * time.Second, "TCP")
	if err != nil {
		pterm.Fatal.Println(err)
	}

	response, err := json.Marshal(tracer)
	if err != nil {
		pterm.Error.Println(err)
		return
	}
	pterm.Info.Println(string(response))
}
RTU over TCP example
package main

import (
	"encoding/json"
	"github.com/pterm/pterm"
	"github.com/Gaz492/gotracerwifi"
	"time"
)

func main()  {
	tracer, err := goTracerWiFi.Status("192.168.1.181", "8088", 5 * time.Second, "RTU_TCP")
	if err != nil {
		pterm.Fatal.Println(err)
	}

	response, err := json.Marshal(tracer)
	if err != nil {
		pterm.Error.Println(err)
		return
	}
	pterm.Info.Println(string(response))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OldGetLoadStatus added in v1.0.0

func OldGetLoadStatus(client modbus.Client) (status int)

func OldToggleLoad added in v1.0.0

func OldToggleLoad(ip string, port string, timeout time.Duration, protocol string) (err error)

Types

type Battery

type Battery struct {
	Voltage       float32 `json:"voltage"`
	Current       float32 `json:"current"`
	MaxVoltage    float32 `json:"max_voltage"`
	MinVoltage    float32 `json:"min_voltage"`
	Temp          float32 `json:"temp"`
	BatteryStatus string  `json:"battery_status"`
	ChargeStatus  string  `json:"charge_status"`
}

type Client added in v1.0.0

type Client struct {
	modbus.Client
}

func NewTCPClient added in v1.0.0

func NewTCPClient(ip string, port string, timeout time.Duration, protocol string) (Client, error)

func (Client) ConsumedAnnual added in v1.0.0

func (c Client) ConsumedAnnual() (float32, error)

func (Client) ConsumedDay added in v1.0.0

func (c Client) ConsumedDay() (float32, error)

func (Client) ConsumedMonth added in v1.0.0

func (c Client) ConsumedMonth() (float32, error)

func (Client) ConsumedTotal added in v1.0.0

func (c Client) ConsumedTotal() (float32, error)

func (Client) GeneratedAnnual added in v1.0.0

func (c Client) GeneratedAnnual() (float32, error)

func (Client) GeneratedDay added in v1.0.0

func (c Client) GeneratedDay() (float32, error)

func (Client) GeneratedMonth added in v1.0.0

func (c Client) GeneratedMonth() (float32, error)

func (Client) GeneratedTotal added in v1.0.0

func (c Client) GeneratedTotal() (float32, error)

func (Client) GetBatteryCurrent added in v1.0.0

func (c Client) GetBatteryCurrent() (float32, error)

func (Client) GetBatteryMaxVoltage added in v1.0.0

func (c Client) GetBatteryMaxVoltage() (float32, error)

func (Client) GetBatteryMin added in v1.0.0

func (c Client) GetBatteryMin() (float32, error)

func (Client) GetBatterySOC added in v1.0.0

func (c Client) GetBatterySOC() (float32, error)

func (Client) GetBatteryVoltage added in v1.0.0

func (c Client) GetBatteryVoltage() (float32, error)

func (Client) GetLoadCurrent added in v1.0.0

func (c Client) GetLoadCurrent() (float32, error)

func (Client) GetLoadPower added in v1.0.0

func (c Client) GetLoadPower() (float32, error)

func (Client) GetLoadStatus added in v1.0.0

func (c Client) GetLoadStatus() (int, error)

Load stuff

func (Client) GetLoadVoltage added in v1.0.0

func (c Client) GetLoadVoltage() (float32, error)

func (Client) GetSolarCurrent added in v1.0.0

func (c Client) GetSolarCurrent() (float32, error)

func (Client) GetSolarPower added in v1.0.0

func (c Client) GetSolarPower() (float32, error)

func (Client) GetSolarVoltage added in v1.0.0

func (c Client) GetSolarVoltage() (float32, error)

Solar stuff

func (Client) GetTemp added in v1.0.0

func (c Client) GetTemp() (float32, error)

func (Client) SetLoadOff added in v1.0.0

func (c Client) SetLoadOff() error

func (Client) SetLoadOn added in v1.0.0

func (c Client) SetLoadOn() error

type Consumed

type Consumed struct {
	Day    float32 `json:"day"`
	Month  float32 `json:"month"`
	Annual float32 `json:"annual"`
	Total  float32 `json:"total"`
}

type Energy

type Energy struct {
	Generated Generated `json:"generated"`
	Consumed  Consumed  `json:"consumed"`
}

type Generated

type Generated struct {
	Day    float32 `json:"day"`
	Month  float32 `json:"month"`
	Annual float32 `json:"annual"`
	Total  float32 `json:"total"`
}

type Load

type Load struct {
	Voltage float32 `json:"voltage"`
	Current float32 `json:"current"`
	Power   float32 `json:"power"`
	Status  int     `json:"status"`
}

type Response

type Response struct {
	Solar     Solar     `json:"solar"`
	Battery   Battery   `json:"battery"`
	Load      Load      `json:"load"`
	Stats     Stats     `json:"stats"`
	Timestamp time.Time `json:"timestamp"`
}

func Status

func Status(ip string, port string, timeout time.Duration, protocol string) (r Response, err error)

type Solar

type Solar struct {
	Voltage float32 `json:"voltage"`
	Current float32 `json:"current"`
	Power   float32 `json:"power"`
}

type Stats

type Stats struct {
	Energy Energy `json:"energy"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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