gotracerwifi

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 11, 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 GetLoadStatus added in v0.0.5

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

func ToggleLoad added in v0.0.5

func ToggleLoad(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 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