deviceadapters

package
v0.0.0-...-f8c32d9 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// "3V_2100" in zigbee2mqtt terminology
	BatteryCR2032 = &hubtypes.BatteryType{func(voltage float64) float64 {

		return float64(func() float64 {
			voltage := float64(voltage * 1000)

			switch {
			case voltage < 2100:
				return 0
			case voltage < 2440:
				return 6 - ((2440-voltage)*6)/340
			case voltage < 2740:
				return 18 - ((2740-voltage)*12)/300
			case voltage < 2900:
				return 42 - ((2900-voltage)*24)/160
			case voltage < 3000:
				return 100 - ((3000-voltage)*58)/100
			default:
				return 100
			}
		}()) / 100

	}}
)

Functions

func AttributeReportToAttributes

func AttributeReportToAttributes(
	report *cluster.AttributeReport,
	clusterId cluster.ClusterId,
	dev *ezstack.Device,
	adapter Adapter,
	actx *hubtypes.AttrsCtx,
) error

parses Zigbee AttributeReport message into structured sane attributes, taking into account manufacturer-specific "peculiarities"...

func ZclIncomingMessageToAttributes

func ZclIncomingMessageToAttributes(
	message *zcl.ZclIncomingMessage,
	actx *hubtypes.AttrsCtx,
	device *ezstack.Device,
) error

updates attributes from ReportAttributesCommand/ZoneStatusChangeNotificationCommand/etc.

Types

type Adapter

type Adapter interface {
	// given "genOnOff.onOff", returns parser for it
	ParserForAttribute(clusterAndAttribute string) customParser

	// handle any additional (non-AttributeReport) commands
	HandleCommand(command interface{}, actx *hubtypes.AttrsCtx) error

	// returns nil if not battery powered
	BatteryType() *hubtypes.BatteryType
}

func AdapterForModel

func AdapterForModel(model ezstack.Model) Adapter

func For

func For(dev *ezstack.Device) Adapter

helper

type Attribute

type Attribute struct {
	Id        uint8
	Attribute *zcl.AttributeDataTypeValue
}

type AttributeList

type AttributeList []Attribute

func ParseAttributeList

func ParseAttributeList(xiaomiBytes []byte) (AttributeList, error)

func (AttributeList) Find

Jump to

Keyboard shortcuts

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