powersupply

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package powersupply tracks the power supply/usage on the host.

Index

Constants

View Source
const (
	StateNamePowerSupply = "power_supply"

	StateKeyBatteryCapacity      = "battery_capacity"
	StateKeyBatteryCapacityFound = "battery_capacity_found"
)
View Source
const DefaultBatteryCapacityFile = "/sys/class/power_supply/BAT0/capacity"
View Source
const Name = "power-supply"

Variables

This section is empty.

Functions

func Get

func Get(ctx context.Context) (_ any, e error)

func New

Types

type Config

type Config struct {
	Query query_config.Config `json:"query"`
}

func ParseConfig

func ParseConfig(b any, db *sql.DB) (*Config, error)

func (Config) Validate

func (cfg Config) Validate() error

type Output

type Output struct {
	BatteryCapacity      uint64 `json:"battery_capacity"`
	BatteryCapacityFound bool   `json:"battery_capacity_found"`
}

func ParseOutputJSON

func ParseOutputJSON(data []byte) (*Output, error)

func ParseStatePowerSupply

func ParseStatePowerSupply(m map[string]string) (*Output, error)

func ParseStatesToOutput

func ParseStatesToOutput(states ...components.State) (*Output, error)

func (*Output) JSON

func (o *Output) JSON() ([]byte, error)

func (*Output) States

func (o *Output) States() ([]components.State, error)

Jump to

Keyboard shortcuts

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