zigbee2mqtt

package module
v0.0.0-...-b525ca0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 10 Imported by: 0

README

zigbee2mqtt

golang client for zigbee2mqtt

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler[T any](handler TypedMessageHandler[T]) mqtt.MessageHandler

Types

type AddGroup

type AddGroup struct {
	ID           int    `json:"id"`
	FriendlyName string `json:"friendly_name"`
}

type AqaraMotionSensor

type AqaraMotionSensor struct {
	CommonDevice
	Occupancy         bool    `json:"occupancy"`
	TriggerIndicator  bool    `json:"trigger_indicator"`
	MotionSensitity   string  `json:"motion_sensitivity"`
	DetectionInterval float64 `json:"detection_interval"`
	TemperatureC      float64 `json:"device_temperature"`
	Illuminance       float64 `json:"illuminance"`
	PowerOutageCount  int     `json:"power_outage_count"`
}

type Binding

type Binding struct {
	Cluster string `json:"cluster"`
	Target  Target `json:"target"`
}

type BridgeStateHandler

type BridgeStateHandler func(status string) error

type Cluster

type Cluster struct {
	Input  []string `json:"input"`
	Output []string `json:"output"`
}

type CommonDevice

type CommonDevice struct {
	LinkQuality float64 `json:"linkquality"`
	Battery     float64 `json:"battery"`
	Voltage     float64 `json:"voltage"`
}

type ConfigureReporting

type ConfigureReporting struct {
	ID                    string  `json:"id"`
	Cluster               string  `json:"cluster"`
	Attribute             string  `json:"attribute"`
	MinimumReportInterval int     `json:"minimum_report_interval"`
	MaximumReportInterval int     `json:"maximum_report_interval"`
	ReportableChange      float64 `json:"reportable_change"`
}

type CoordinatorCheck

type CoordinatorCheck struct {
	MissingRouters []DeviceIdentifier `json:"missing_routers"`
}

type Definition

type Definition struct {
	Vendor      string     `json:"vendor"`
	Model       string     `json:"model"`
	Description string     `json:"description"`
	SupportsOTA bool       `json:"supports_ota"`
	Exposes     []*Feature `json:"exposes"`
	Options     []*Feature `json:"options"`
}

type Device

type Device struct {
	DeviceIdentifier
	Type               string              `json:"type"`
	Manufacturer       string              `json:"manufacturer"`
	ModelID            string              `json:"model_id"`
	NetworkAddress     int                 `json:"network_address"`
	Description        string              `json:"description"`
	Endpoints          map[string]Endpoint `json:"endpoints"`
	Definition         *Definition         `json:"definition"`
	PowerSource        string              `json:"power_source"`
	DateCode           string              `json:"date_code"`
	Scenes             []Scene             `json:"scene"`
	Interviewing       bool                `json:"interviewing"`
	InterviewCompleted bool                `json:"interview_completed"`
	Supported          bool                `json:"supported"`
	Disabled           bool                `json:"disabled"`
	// contains filtered or unexported fields
}

type DeviceHandler

type DeviceHandler func(dev *Device) error

type DeviceIdentifier

type DeviceIdentifier struct {
	IEEEAddress  string `json:"ieee_address"`
	FriendlyName string `json:"friendly_name"`
}

type DeviceUpdate

type DeviceUpdate struct {
	Device *Device
	Update map[string]any
}

type Endpoint

type Endpoint struct {
	Bindings             []Binding   `json:"bindings"`
	Clusters             []Cluster   `json:"clusters"`
	ConfiguredReportings []Reporting `json:"configured_reportings"`
	Scenes               []Scene     `json:"scenes"`
}

type Event

type Event struct {
	Type string
	Data EventData
}

type EventData

type EventData struct {
	FriendlyName string      `json:"friendly_name"`
	IEEEAddress  string      `json:"ieee_address"`
	Status       *string     `json:"status"`
	Supported    *bool       `json:"supported"`
	Definition   *Definition `json:"definition"`
}

type EventHandler

type EventHandler func(evt *Event) error

type Feature

type Feature struct {
	Access      int        `json:"access"`
	Category    string     `json:"category"`
	Description string     `json:"description"`
	Label       string     `json:"label"`
	Name        string     `json:"name"`
	Property    string     `json:"property"`
	Type        string     `json:"type"`
	Unit        string     `json:"unit"`
	ValueOn     any        `json:"value_on"`
	ValueOff    any        `json:"value_off"`
	ValueMin    *float64   `json:"value_min"`
	ValueMax    *float64   `json:"value_max"`
	Values      []string   `json:"values"`
	Features    []*Feature `json:"features"`
	ItemType    *Feature   `json:"item_type"`
}

func (*Feature) Getable

func (feat *Feature) Getable() bool

func (*Feature) Readable

func (feat *Feature) Readable() bool

func (*Feature) Setable

func (feat *Feature) Setable() bool

type GroupMembers

type GroupMembers struct {
	Group  string `json:"group,omitempty"`
	Device string `json:"device"`
}

type GroupOptions

type GroupOptions struct {
	Retain     *bool   `json:"retain,omitempty"`
	Transition *int    `json:"transition,omitempty"`
	Optimistic *bool   `json:"optimistic,omitempty"`
	OffState   *string `json:"off_state,omitempty"`
}

type HealthCheck

type HealthCheck struct {
	Healthy bool `json:"healthy"`
}

type InstallCode

type InstallCode struct {
	Value string `json:"value"`
}

type InterviewDevice

type InterviewDevice struct {
	ID string `json:"id"`
}

type LogMessage

type LogMessage struct {
	Level   string `json:"level"`
	Message string `json:"message"`
}

type LoggingHandler

type LoggingHandler func(level, message string) error

type PermitJoinCommand

type PermitJoinCommand struct {
	Value  bool   `json:"value"`
	Device string `json:"device,omitempty"`
	Time   int    `json:"time,omitempty"`
}

type RemoveDevice

type RemoveDevice struct {
	ID    string `json:"id"`
	Block *bool  `json:"block,omitempty"`
	Force *bool  `json:"force,omitempty"`
}

type RemoveGroup

type RemoveGroup struct {
	ID any `json:"id"`
}

type RenameDevice

type RenameDevice struct {
	From                string `json:"from"`
	To                  string `json:"to"`
	HomeAssistantRename bool   `json:"homeassistant_rename,omitempty"`
}

type RenameGroup

type RenameGroup struct {
	From any    `json:"from"`
	To   string `json:"to"`
}

type Reporting

type Reporting struct {
	Attribute             string `json:"attribute"`
	Cluster               string `json:"cluster"`
	MaximumReportInterval int    `json:"maximum_report_interval"`
	MinimumReportInterval int    `json:"minimum_report_interval"`
	ReportableChange      int    `json:"reportable_change"`
}

type Request

type Request struct {
	Data        any
	Transaction int64
}

func (Request) MarshalJSON

func (req Request) MarshalJSON() ([]byte, error)

type Response

type Response struct {
	Data        json.RawMessage `json:"data"`
	Transaction int64           `json:"transaction"`
	Status      *string         `json:"status"`
}

type Scene

type Scene struct {
}

type SetGroupOptions

type SetGroupOptions struct {
	ID      any           `json:"id"`
	Options *GroupOptions `json:"options,omitempty"`
	From    *GroupOptions `json:"from,omitempty"`
	To      *GroupOptions `json:"to,omitempty"`
}

type SonoffContactSensor

type SonoffContactSensor struct {
	CommonDevice
	Contact    bool `json:"contact"`
	Tamper     bool `json:"contact"`
	BatteryLow bool `json:"battery_low"`
}

type SonoffTemperatureSensor

type SonoffTemperatureSensor struct {
	CommonDevice
	Humidity     float64 `json:"humidity"`
	TemperatureC float64 `json:"temperature"`
}

type State

type State struct {
	State string `json:"state"`
}

type Target

type Target struct {
	Endpoint    int    `json:"endpoint"`
	IEEEAddress string `json:"ieee_address"`
	Type        string `json:"type"`
}

type TelemHandler

type TelemHandler func(dev *Device, telem json.RawMessage) error

func TypedTelemHandler

func TypedTelemHandler[T any](handler func(*Device, T) error) TelemHandler

type ThirdRealityMotionSensor

type ThirdRealityMotionSensor struct {
	CommonDevice
	Occupancy  bool `json:"occupancy"`
	Tamper     bool `json:"tamper"`
	BatteryLow bool `json:"battery_low"`
}

type TypedMessageHandler

type TypedMessageHandler[T any] func(topic string, msg T) error

type Zigbee

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

func NewZigbee

func NewZigbee(client mqtt.Client) *Zigbee

func (*Zigbee) AddGroup

func (z *Zigbee) AddGroup(id int, name string) error

func (*Zigbee) AddGroupMembers

func (z *Zigbee) AddGroupMembers(group, device string) error

func (*Zigbee) ConfigureReporting

func (z *Zigbee) ConfigureReporting(id, cluster, attribute string, minInterval, maxInterval time.Duration, thresh float64) error

func (*Zigbee) CoordinatorCheck

func (z *Zigbee) CoordinatorCheck() (CoordinatorCheck, error)

func (*Zigbee) HealthCheck

func (z *Zigbee) HealthCheck() (HealthCheck, error)

func (*Zigbee) InstallCode

func (z *Zigbee) InstallCode(code string) error

func (*Zigbee) InterviewDevice

func (z *Zigbee) InterviewDevice(id string) error

func (*Zigbee) PermitJoin

func (z *Zigbee) PermitJoin() error

func (*Zigbee) PermitJoinFor

func (z *Zigbee) PermitJoinFor(dur time.Duration) error

func (*Zigbee) ProhibitJoin

func (z *Zigbee) ProhibitJoin() error

func (*Zigbee) RemoveAllGroupMembers

func (z *Zigbee) RemoveAllGroupMembers(device string) error

func (*Zigbee) RemoveDevice

func (z *Zigbee) RemoveDevice(id string) error

func (*Zigbee) RemoveGroup

func (z *Zigbee) RemoveGroup(id any) error

func (*Zigbee) RemoveGroupMembers

func (z *Zigbee) RemoveGroupMembers(group, device string) error

func (*Zigbee) RenameDevice

func (z *Zigbee) RenameDevice(id, name string) error

func (*Zigbee) RenameGroup

func (z *Zigbee) RenameGroup(id any, name string) error

func (*Zigbee) Restart

func (z *Zigbee) Restart() error

func (*Zigbee) SetGroupOptions

func (z *Zigbee) SetGroupOptions(id any, opts GroupOptions) (SetGroupOptions, error)

func (*Zigbee) SetOption

func (z *Zigbee) SetOption(device string, obj any) error

func (*Zigbee) Updates

func (z *Zigbee) Updates() <-chan DeviceUpdate

Jump to

Keyboard shortcuts

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