shelly3em

package
v0.0.0-...-5182124 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const NotifyStatus = "NotifyStatus"

Variables

This section is empty.

Functions

This section is empty.

Types

type Counters

type Counters struct {
	Time   time.Time
	Device string
	PhaseA EnergyCounters
	PhaseB EnergyCounters
	PhaseC EnergyCounters
	Total  EnergyCounters
}

type DevicePayload

type DevicePayload struct {
	Source      string          `json:"src"`
	Destination string          `json:"dst"`
	Method      string          `json:"method"`
	Params      json.RawMessage `json:"params"`
}

type EnergyCounters

type EnergyCounters struct {
	Energy         float64
	EnergyReturned float64
}

type Handler

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

func NewHandler

func NewHandler(repo Repository) *Handler

func (*Handler) HandleMessage

func (h *Handler) HandleMessage(message *paho.Publish)

type Measurement

type Measurement struct {
	Time               time.Time
	Device             string
	PhaseA             PhaseMeasurement
	PhaseB             PhaseMeasurement
	PhaseC             PhaseMeasurement
	TotalActualPower   float64
	TotalApparentPower float64
	TotalCurrent       float64
}

type NotifyStatusEMData0

type NotifyStatusEMData0 struct {
	ID                         int32   `json:"id,omitempty"`
	ATotalActualEnergy         float64 `json:"a_total_act_energy,omitempty"`
	ATotalActualReturnedEnergy float64 `json:"a_total_act_ret_energy,omitempty"`
	BTotalActualEnergy         float64 `json:"b_total_act_energy,omitempty"`
	BTotalActualReturnedEnergy float64 `json:"b_total_act_ret_energy,omitempty"`
	CTotalActualEnergy         float64 `json:"c_total_act_energy,omitempty"`
	CTotalActualReturnedEnergy float64 `json:"c_total_act_ret_energy,omitempty"`
	TotalActual                float64 `json:"total_act,omitempty"`
	TotalActualReturned        float64 `json:"total_act_ret,omitempty"`
}

type NotifyStatusEm0

type NotifyStatusEm0 struct {
	ID int32 `json:"id,omitempty"`

	AActualPower   float64 `json:"a_act_power,omitempty"`
	AApparentPower float64 `json:"a_aprt_power,omitempty"`
	ACurrent       float64 `json:"a_current,omitempty"`
	AFrequency     float64 `json:"a_freq,omitempty"`
	APowerFactor   float64 `json:"a_pf,omitempty"`
	AVoltage       float64 `json:"a_voltage,omitempty"`

	BActualPower   float64 `json:"b_act_power,omitempty"`
	BApparentPower float64 `json:"b_aprt_power,omitempty"`
	BCurrent       float64 `json:"b_current,omitempty"`
	BFrequency     float64 `json:"b_freq,omitempty"`
	BPowerFactor   float64 `json:"b_pf,omitempty"`
	BVoltage       float64 `json:"b_voltage,omitempty"`

	CActualPower   float64 `json:"c_act_power,omitempty"`
	CApparentPower float64 `json:"c_aprt_power,omitempty"`
	CCurrent       float64 `json:"c_current,omitempty"`
	CFrequency     float64 `json:"c_freq,omitempty"`
	CPowerFactor   float64 `json:"c_pf,omitempty"`
	CVoltage       float64 `json:"c_voltage,omitempty"`

	// nil if there is no N clamp
	NCurrent           *float64 `json:"n_current,omitempty"`
	TotalActualPower   float64  `json:"total_act_power,omitempty"`
	TotalApparentPower float64  `json:"total_aprt_power,omitempty"`
	TotalCurrent       float64  `json:"total_current,omitempty"`
}

type NotifyStatusMessage

type NotifyStatusMessage struct {
	Timestamp UnixTimestamp        `json:"ts"`
	EM0       *NotifyStatusEm0     `json:"em:0"`
	EMData0   *NotifyStatusEMData0 `json:"emdata:0"`
}

type PhaseMeasurement

type PhaseMeasurement struct {
	ActualPower   float64
	ApparentPower float64
	Current       float64
	Frequency     float64
	PowerFactor   float64
	Voltage       float64
}

type Repository

type Repository interface {
	InsertMeasurements(ctx context.Context, measurement Measurement) error
	InsertCounters(ctx context.Context, counters Counters) error
}

type TimescaleRepository

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

func NewTimescaleRepository

func NewTimescaleRepository(db *sql.DB) *TimescaleRepository

func (*TimescaleRepository) InsertCounters

func (t *TimescaleRepository) InsertCounters(ctx context.Context, counters Counters) error

func (*TimescaleRepository) InsertMeasurements

func (t *TimescaleRepository) InsertMeasurements(ctx context.Context, measurement Measurement) error

type UnixTimestamp

type UnixTimestamp time.Time

func (*UnixTimestamp) UnmarshalJSON

func (ts *UnixTimestamp) UnmarshalJSON(msg []byte) error

Jump to

Keyboard shortcuts

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