Documentation
¶
Overview ¶
Package zcl provides Zigbee Cluster Library primitives for encoding/decoding ZCL frames and working with standard clusters.
ZCL Frame Structure ¶
A ZCL frame has the following structure:
Frame Control (1 byte) - Frame Type (2 bits): global (0x00), cluster-specific (0x01) - Manufacturer Specific (1 bit) - Direction (1 bit): client→server (0), server→client (1) - Disable Default Response (1 bit) - Reserved (3 bits) Transaction Sequence Number (1 byte) Command (1 byte): varies by frame type Data (variable): command-specific payload
Creating Frames ¶
Create a read attributes request:
frame := zcl.Frame{
FrameControl: zcl.FrameTypeGlobal,
Direction: zcl.ClientToServer,
TransSeqNum: 1,
Command: zcl.CmdReadAttributes,
Data: attributes,
}
Encode to bytes:
data, err := zcl.Encode(frame)
Data Types ¶
ZCL defines various data types for attribute values:
Boolean: zcl.TypeData8, zcl.TypeBoolean Integer: zcl.TypeData8, TypeData16, TypeData24, TypeData32, TypeData40, TypeData48 Float: zcl.TypeSingle, TypeDouble, TypeHalf Strings: zcl.TypeString, TypeOctetString Arrays: zcl.TypeArray, TypeArray16 Special: zcl.TypeBitmap8, zcl.TypeEnumeration8, zcl.TypeUTC
Encoding a value:
encoded, err := zcl.WriteValue(uint16(1234))
Decoding a value:
decoded, remaining, err := zcl.ReadValue(data, zcl.TypeData16)
Clusters ¶
Standard Zigbee clusters are defined as constants in clusters.go:
Basic: 0x0000 Power Configuration: 0x0001 Identify: 0x0003 Groups: 0x0004 Scenes: 0x0005 On/Off: 0x0006 Level Control: 0x0008 Color Control: 0x0300 Temperature: 0x0402 Humidity: 0x0405 Occupancy: 0x0406 Electrical Measure: 0x0B04 Simple Metering: 0x0702
Attributes ¶
Each cluster has standard attributes. Read attributes to query device state:
results, err := adapter.ReadAttributes(ctx, nwkAddr, endpoint, zcl.ClusterOnOff, []zcl.AttributeID{
zcl.AttrOnOff,
})
Global Commands ¶
Work with any cluster:
Read Attributes: zcl.CmdReadAttributes Read Attributes Response: zcl.CmdReadAttributesResponse Write Attributes: zcl.CmdWriteAttributes Write Attributes Response: zcl.CmdWriteAttributesResponse Configure Reporting: zcl.CmdConfigureReporting Configure Reporting Response: zcl.CmdConfigureReportingResponse Discover Attributes: zcl.CmdDiscoverAttributes
Color Control ¶
Utilities for color conversion:
Kelvin to mireds: mireds := zcl.KelvinToMireds(2700) mireds to Kelvin: kelvin := zcl.MiredsToKelvin(370) RGB to XY: x, y := zcl.RGBToXY(255, 0, 0) HSV to Hue/Saturation (0-254): hue, sat := zcl.HSVToZigbee(120, 100)
Status Codes ¶
ZCL operations return status codes:
Success: 0x00 UnsupportedAttr: 0x86 InvalidValue: 0x87 ReadOnly: 0x82
Manufacturer-Specific Clusters ¶
Set manufacturer code in frame control:
frame.FrameControl.ManufacturerSpecific = true frame.ManufacturerCode = 0x115F // Tuya
Thread Safety ¶
Frame encoding/decoding functions are stateless and safe for concurrent use.
Index ¶
- Constants
- Variables
- func ClampToGamut(x, y float64, gamut Gamut) (float64, float64)
- func KelvinToMireds(kelvin uint16) uint16
- func MiredsToKelvin(mireds uint16) uint16
- func MustBool(v interface{}, def bool) bool
- func MustInt16(v interface{}, def int16) int16
- func MustString(v interface{}, def string) string
- func MustUint8(v interface{}, def uint8) uint8
- func MustUint16(v interface{}, def uint16) uint16
- func MustUint32(v interface{}, def uint32) uint32
- func RGBToXY(r, g, b uint8) (x, y uint16)
- func ReadValue(data []byte, dataType DataType) (interface{}, int, error)
- func ToBool(v interface{}) (bool, bool)
- func ToBoolFromUint8(v interface{}) (bool, bool)
- func ToBytes(v interface{}) ([]byte, bool)
- func ToFloat32(v interface{}) (float32, bool)
- func ToFloat64(v interface{}) (float64, bool)
- func ToInt8(v interface{}) (int8, bool)
- func ToInt16(v interface{}) (int16, bool)
- func ToInt32(v interface{}) (int32, bool)
- func ToInt64(v interface{}) (int64, bool)
- func ToString(v interface{}) (string, bool)
- func ToUint8(v interface{}) (uint8, bool)
- func ToUint16(v interface{}) (uint16, bool)
- func ToUint32(v interface{}) (uint32, bool)
- func ToUint64(v interface{}) (uint64, bool)
- func WriteValue(value interface{}, dataType DataType) ([]byte, error)
- func XYToRGB(x, y uint16, brightness uint8) (r, g, b uint8)
- type ArrayValue
- type AttributeID
- type AttributeValue
- type BatterySize
- type ClusterID
- type ConfigureReportingResult
- type DataType
- type Direction
- type DoorLockState
- type DoorState
- type EngineeringUnits
- type FanMode
- type FanModeSequence
- type Frame
- func BuildClusterCommand(seqNum uint8, commandID uint8, payload []byte) *Frame
- func BuildConfigureReportingRequest(seqNum uint8, configs []ReportingConfig) (*Frame, error)
- func BuildReadAttributesRequest(seqNum uint8, attributeIDs ...AttributeID) *Frame
- func BuildReadReportingConfigRequest(seqNum uint8, records []ReadReportingConfigRecord) *Frame
- func BuildWriteAttributesRequest(seqNum uint8, values map[AttributeID]AttributeValue) (*Frame, error)
- func ParseFrame(data []byte) (*Frame, error)
- type FrameControl
- type FrameType
- type Gamut
- type GlobalCommand
- type IASZoneType
- type IOReliability
- type MoveMode
- type OTAUpgradeStatus
- type Point
- type PowerSource
- type ReadAttributeResult
- type ReadReportingConfigRecord
- type ReportAttributeResult
- type ReportingConfig
- type ReportingConfigRecord
- type SirenLevel
- type StartUpOnOff
- type Status
- type StepMode
- type StrobeLevel
- type StructField
- type StructValue
- type ThermostatSystemMode
- type WarningMode
- type WindowCoveringType
- type WriteAttributeResult
Constants ¶
const ( CmdIdentify uint8 = 0x00 // Start identifying for N seconds. CmdIdentifyQuery uint8 = 0x01 // Query if device is identifying. CmdTriggerEffect uint8 = 0x40 // Trigger a specific effect (ZCL 6+). )
Identify Cluster Commands (0x0003).
const ( IdentifyEffectBlink uint8 = 0x00 // Light flashes on/off once. IdentifyEffectBreathe uint8 = 0x01 // Light fades in and out. IdentifyEffectOkay uint8 = 0x02 // Brief green flash (color lights). IdentifyEffectChannelChg uint8 = 0x0B // Brief orange flash (color lights). IdentifyEffectFinishEffect uint8 = 0xFE // Complete current effect gracefully. IdentifyEffectStopEffect uint8 = 0xFF // Stop immediately. )
Identify Effect IDs for TriggerEffect command.
const ( CmdGroupsAdd uint8 = 0x00 // Add group membership. CmdGroupsView uint8 = 0x01 // View group info. CmdGroupsGetMembership uint8 = 0x02 // Get list of groups device belongs to. CmdGroupsRemove uint8 = 0x03 // Remove from a group. CmdGroupsRemoveAll uint8 = 0x04 // Remove from all groups. CmdGroupsAddIfIdentifying uint8 = 0x05 // Add to group only if device is identifying. )
Groups Cluster Commands (0x0004).
const ( CmdGroupsAddResponse uint8 = 0x00 CmdGroupsViewResponse uint8 = 0x01 CmdGroupsGetMembershipResponse uint8 = 0x02 CmdGroupsRemoveResponse uint8 = 0x03 )
Groups Cluster Response Commands (0x0004).
const ( CmdScenesAdd uint8 = 0x00 // Add a scene with explicit attribute values. CmdScenesView uint8 = 0x01 // View scene details. CmdScenesRemove uint8 = 0x02 // Remove a scene. CmdScenesRemoveAll uint8 = 0x03 // Remove all scenes for a group. CmdScenesStore uint8 = 0x04 // Store current state as a scene. CmdScenesRecall uint8 = 0x05 // Recall/activate a scene. CmdScenesGetMembership uint8 = 0x06 // Get list of scenes for a group. CmdScenesCopy uint8 = 0x42 // Copy scenes between groups (ZCL 7+). )
Scenes Cluster Commands (0x0005).
const ( CmdScenesAddResponse uint8 = 0x00 CmdScenesViewResponse uint8 = 0x01 CmdScenesRemoveResponse uint8 = 0x02 CmdScenesRemoveAllResponse uint8 = 0x03 CmdScenesStoreResponse uint8 = 0x04 CmdScenesGetMembershipResponse uint8 = 0x06 )
Scenes Cluster Response Commands (0x0005).
const ( CmdPollControlCheckInResponse uint8 = 0x00 // Response to check-in. CmdPollControlFastPollStop uint8 = 0x01 // Stop fast polling. CmdPollControlSetLongPollInterval uint8 = 0x02 // Set long poll interval. CmdPollControlSetShortPollInterval uint8 = 0x03 // Set short poll interval. )
PollControl Cluster Commands - Client to Server (to sleepy device).
const ( CmdAlarmsResetAlarm uint8 = 0x00 // Reset a specific alarm. CmdAlarmsResetAllAlarms uint8 = 0x01 // Reset all alarms. CmdAlarmsGetAlarm uint8 = 0x02 // Get an alarm entry from the log. CmdAlarmsResetAlarmLog uint8 = 0x03 // Reset the alarm log. )
Alarms Cluster Commands - Client to Server (0x0009).
const ( CmdAlarmsAlarm uint8 = 0x00 // Alarm notification from device. CmdAlarmsGetAlarmResponse uint8 = 0x01 // Response to GetAlarm command. )
Alarms Cluster Commands - Server to Client (0x0009).
const ( CmdDoorLockLock uint8 = 0x00 // Lock the door CmdDoorLockUnlock uint8 = 0x01 // Unlock the door CmdDoorLockToggle uint8 = 0x02 // Toggle lock state CmdDoorLockUnlockWithTimeout uint8 = 0x03 // Unlock with automatic relock CmdDoorLockSetPINCode uint8 = 0x05 // Set user PIN code CmdDoorLockGetPINCode uint8 = 0x06 // Get user PIN code CmdDoorLockClearPINCode uint8 = 0x07 // Clear user PIN code CmdDoorLockClearAllPINCodes uint8 = 0x08 // Clear all PIN codes CmdDoorLockSetUserStatus uint8 = 0x09 // Set user status )
DoorLock Cluster Commands (0x0101)
const ( CmdWindowCoveringUpOpen uint8 = 0x00 // Open/raise CmdWindowCoveringDownClose uint8 = 0x01 // Close/lower CmdWindowCoveringStop uint8 = 0x02 // Stop movement CmdWindowCoveringGoToLiftValue uint8 = 0x04 // Move to lift value (uint16) CmdWindowCoveringGoToLiftPercent uint8 = 0x05 // Move to lift percentage (uint8) CmdWindowCoveringGoToTiltValue uint8 = 0x07 // Move to tilt value (uint16) CmdWindowCoveringGoToTiltPercent uint8 = 0x08 // Move to tilt percentage (uint8) )
WindowCovering Cluster Commands (0x0102)
const ( CmdColorMoveToHue uint8 = 0x00 // Move to hue CmdColorMoveHue uint8 = 0x01 // Move hue CmdColorStepHue uint8 = 0x02 // Step hue CmdColorMoveToSaturation uint8 = 0x03 // Move to saturation CmdColorMoveSaturation uint8 = 0x04 // Move saturation CmdColorStepSaturation uint8 = 0x05 // Step saturation CmdColorMoveToHueSaturation uint8 = 0x06 // Move to hue and saturation CmdColorMoveToColor uint8 = 0x07 // Move to XY color CmdColorMoveColor uint8 = 0x08 // Move color CmdColorStepColor uint8 = 0x09 // Step color CmdColorMoveToColorTemp uint8 = 0x0A // Move to color temperature // Enhanced Color Control commands (ZCL 6+) CmdColorEnhancedMoveToHue uint8 = 0x40 CmdColorEnhancedMoveHue uint8 = 0x41 CmdColorEnhancedStepHue uint8 = 0x42 CmdColorEnhancedMoveToHueAndSaturation uint8 = 0x43 CmdColorColorLoopSet uint8 = 0x44 CmdColorStopMoveStep uint8 = 0x47 // Stop move/step CmdColorMoveColorTemp uint8 = 0x4B // Move color temperature CmdColorStepColorTemp uint8 = 0x4C // Step color temperature )
Color Control Cluster Commands (0x0300)
const ( ColorCapabilityHueSaturation uint16 = 1 << 0 // Supports Hue/Saturation ColorCapabilityEnhancedHue uint16 = 1 << 1 // Supports Enhanced Hue ColorCapabilityColorLoop uint16 = 1 << 2 // Supports Color Loop ColorCapabilityXY uint16 = 1 << 3 // Supports XY attributes ColorCapabilityColorTemp uint16 = 1 << 4 // Supports Color Temperature )
ColorCapabilities bitmap values (attribute 0x400A)
const ( CmdThermostatSetpointRaiseLower uint8 = 0x00 // Raise/lower setpoint CmdThermostatSetWeeklySchedule uint8 = 0x01 // Set weekly schedule CmdThermostatGetWeeklySchedule uint8 = 0x02 // Get weekly schedule CmdThermostatClearWeeklySchedule uint8 = 0x03 // Clear weekly schedule )
Thermostat Cluster Commands (0x0201)
const ( TimeStatusMaster uint8 = 1 << 0 // Device is time master TimeStatusSynchronized uint8 = 1 << 1 // Time is synchronized TimeStatusMasterZoneDst uint8 = 1 << 2 // Master for timezone/DST TimeStatusSuperseding uint8 = 1 << 3 // Can supersede other masters )
TimeStatus bitmap flags.
const ( BinaryInputStatusFlagInAlarm uint8 = 1 << 0 // In alarm state BinaryInputStatusFlagFault uint8 = 1 << 1 // Fault detected BinaryInputStatusFlagOverridden uint8 = 1 << 2 // Value overridden BinaryInputStatusFlagOutOfService uint8 = 1 << 3 // Out of service )
Binary Input StatusFlags bitmap.
const ( BinaryOutputStatusFlagInAlarm uint8 = 1 << 0 // In alarm state BinaryOutputStatusFlagFault uint8 = 1 << 1 // Fault detected BinaryOutputStatusFlagOverridden uint8 = 1 << 2 // Value overridden BinaryOutputStatusFlagOutOfService uint8 = 1 << 3 // Out of service )
BinaryOutput StatusFlags bitmap.
const ( BinaryValueStatusFlagInAlarm uint8 = 1 << 0 // In alarm state BinaryValueStatusFlagFault uint8 = 1 << 1 // Fault detected BinaryValueStatusFlagOverridden uint8 = 1 << 2 // Value overridden BinaryValueStatusFlagOutOfService uint8 = 1 << 3 // Out of service )
BinaryValue StatusFlags bitmap.
const ( MultistateInputStatusFlagInAlarm uint8 = 1 << 0 // In alarm state MultistateInputStatusFlagFault uint8 = 1 << 1 // Fault detected MultistateInputStatusFlagOverridden uint8 = 1 << 2 // Value overridden MultistateInputStatusFlagOutOfService uint8 = 1 << 3 // Out of service )
MultistateInput StatusFlags bitmap.
const ( MultistateOutputStatusFlagInAlarm uint8 = 1 << 0 // In alarm state MultistateOutputStatusFlagFault uint8 = 1 << 1 // Fault detected MultistateOutputStatusFlagOverridden uint8 = 1 << 2 // Value overridden MultistateOutputStatusFlagOutOfService uint8 = 1 << 3 // Out of service )
MultistateOutput StatusFlags bitmap.
const ( MultistateValueStatusFlagInAlarm uint8 = 1 << 0 // In alarm state MultistateValueStatusFlagFault uint8 = 1 << 1 // Fault detected MultistateValueStatusFlagOverridden uint8 = 1 << 2 // Value overridden MultistateValueStatusFlagOutOfService uint8 = 1 << 3 // Out of service )
MultistateValue StatusFlags bitmap.
const ( IASZoneStatusAlarm1 uint16 = 1 << 0 // Zone alarm 1 IASZoneStatusAlarm2 uint16 = 1 << 1 // Zone alarm 2 IASZoneStatusTamper uint16 = 1 << 2 // Tamper detected IASZoneStatusBattery uint16 = 1 << 3 // Low battery IASZoneStatusSupervision uint16 = 1 << 4 // Supervision reports enabled IASZoneStatusRestoreReports uint16 = 1 << 5 // Restore reports enabled IASZoneStatusTrouble uint16 = 1 << 6 // Trouble/failure detected IASZoneStatusACMains uint16 = 1 << 7 // AC mains fault IASZoneStatusTest uint16 = 1 << 8 // Sensor in test mode IASZoneStatusBatteryDefect uint16 = 1 << 9 // Battery defect )
IAS Zone Status bitmap flags.
const ( // Server to Client (notifications from device) CmdIASZoneStatusChangeNotification uint8 = 0x00 // Zone status change notification CmdIASZoneEnrollRequest uint8 = 0x01 // Enroll request from device // Client to Server (commands to device) CmdIASZoneEnrollResponse uint8 = 0x00 // Enroll response to device )
IAS Zone Cluster Commands (0x0500)
const ( DRLCDeviceClassHVAC uint16 = 1 << 0 // HVAC compressor or furnace DRLCDeviceClassStrip uint16 = 1 << 1 // Strip/baseboard heater DRLCDeviceClassWaterHeater uint16 = 1 << 2 // Water heater DRLCDeviceClassPoolPump uint16 = 1 << 3 // Pool pump/spa/jacuzzi DRLCDeviceClassSmartAppliance uint16 = 1 << 4 // Smart appliance DRLCDeviceClassIrrigation uint16 = 1 << 5 // Irrigation pump DRLCDeviceClassManagedCI uint16 = 1 << 6 // Managed commercial & industrial loads DRLCDeviceClassSimpleMiscLoads uint16 = 1 << 7 // Simple misc loads DRLCDeviceClassExteriorLighting uint16 = 1 << 8 // Exterior lighting DRLCDeviceClassInteriorLighting uint16 = 1 << 9 // Interior lighting DRLCDeviceClassEV uint16 = 1 << 10 // Electric vehicle DRLCDeviceClassGeneration uint16 = 1 << 11 // Generation systems )
DRLC Device Class bitmap values. These identify the type of load control device.
const ( CmdDRLCLoadControlEvent uint8 = 0x00 // Load control event notification CmdDRLCCancelLoadControlEvent uint8 = 0x01 // Cancel a load control event CmdDRLCCancelAllLoadControl uint8 = 0x02 // Cancel all load control events )
DRLC Cluster Commands - Server to Client (0x0701)
const ( CmdDRLCReportEventStatus uint8 = 0x00 // Report event status CmdDRLCGetScheduledEvents uint8 = 0x01 // Get scheduled events )
DRLC Cluster Commands - Client to Server (0x0701)
const ( CmdPricePublishPrice uint8 = 0x00 // Publish price information CmdPricePublishBlockPeriod uint8 = 0x01 // Publish block period info )
Price Cluster Commands - Server to Client (0x0700)
const ( CmdPriceGetCurrentPrice uint8 = 0x00 // Request current price CmdPriceGetScheduledPrices uint8 = 0x01 // Request scheduled prices )
Price Cluster Commands - Client to Server (0x0700)
const ( CmdOTAQueryNextImageRequest uint8 = 0x01 // Request info about available upgrade CmdOTAImageBlockRequest uint8 = 0x03 // Request a block of image data CmdOTAImagePageRequest uint8 = 0x04 // Request a page of image data CmdOTAUpgradeEndRequest uint8 = 0x06 // Notify server of upgrade completion )
OTA Upgrade Cluster Commands (0x0019) - Client to Server
const ( CmdOTAImageNotify uint8 = 0x00 // Notify client of available upgrade CmdOTAQueryNextImageResponse uint8 = 0x02 // Response to query CmdOTAImageBlockResponse uint8 = 0x05 // Response with image block CmdOTAUpgradeEndResponse uint8 = 0x07 // Response to upgrade end )
OTA Upgrade Cluster Commands (0x0019) - Server to Client
const ( SEMsgCtrlTransmissionNormal uint8 = 0x00 // Normal transmission SEMsgCtrlTransmissionAnonymous uint8 = 0x01 << 0 // Anonymous/inter-PAN transmission SEMsgCtrlImportanceLow uint8 = 0x00 // Low importance SEMsgCtrlImportanceMedium uint8 = 0x01 << 2 // Medium importance SEMsgCtrlImportanceHigh uint8 = 0x02 << 2 // High importance SEMsgCtrlImportanceCritical uint8 = 0x03 << 2 // Critical importance SEMsgCtrlConfirmationRequired uint8 = 0x01 << 7 // Confirmation required )
MessageControl bitmap for Smart Energy Messaging cluster.
const ( CmdSEMessagingDisplayMessage uint8 = 0x00 // Display a message on device CmdSEMessagingCancelMessage uint8 = 0x01 // Cancel a displayed message CmdSEMessagingDisplayProtectedMessage uint8 = 0x02 // Display protected message CmdSEMessagingCancelAllMessages uint8 = 0x03 // Cancel all messages )
Messaging Cluster Commands - Server to Client (0x0703)
const ( CmdSEMessagingGetLastMessage uint8 = 0x00 // Request last message CmdSEMessagingMessageConfirmation uint8 = 0x01 // Confirm message receipt )
Messaging Cluster Commands - Client to Server (0x0703)
const ( CmdOnOffOff uint8 = 0x00 CmdOnOffOn uint8 = 0x01 CmdOnOffToggle uint8 = 0x02 CmdOnOffOffWithEffect uint8 = 0x40 CmdOnOffOnWithRecallGlobalScene uint8 = 0x41 CmdOnOffOnWithTimedOff uint8 = 0x42 )
On/Off Cluster Commands
const ( CmdLevelMoveToLevel uint8 = 0x00 CmdLevelMove uint8 = 0x01 CmdLevelStep uint8 = 0x02 CmdLevelStop uint8 = 0x03 CmdLevelMoveToLevelWithOnOff uint8 = 0x04 CmdLevelMoveWithOnOff uint8 = 0x05 CmdLevelStepWithOnOff uint8 = 0x06 CmdLevelStopWithOnOff uint8 = 0x07 CmdLevelMoveToClosestFreq uint8 = 0x08 )
Level Control Cluster Commands
const ( CmdIASWDStartWarning uint8 = 0x00 // Start warning (siren/strobe) CmdIASWDSquawk uint8 = 0x01 // Squawk (brief sound for arming/disarming) )
IAS Warning Device Cluster Commands (0x0502)
const (
CmdBasicResetToFactoryDefaults uint8 = 0x00 // Reset all attribute values to factory defaults.
)
Basic Cluster Commands (0x0000).
const (
CmdPollControlCheckIn uint8 = 0x00 // Device check-in notification.
)
PollControl Cluster Commands - Server to Client (from sleepy device).
const (
StatusUnsupportedAttr = StatusUnsupportedAttribute
)
Deprecated: Use Status constants instead
Variables ¶
var ( // GamutA is used by older Hue bulbs (A19 1st gen, BR30, etc.) GamutA = Gamut{ Red: Point{X: 0.704, Y: 0.296}, Green: Point{X: 0.2151, Y: 0.7106}, Blue: Point{X: 0.138, Y: 0.08}, } // GamutB is used by some Hue bulbs (A19 2nd gen, BR30 2nd gen, etc.) GamutB = Gamut{ Red: Point{X: 0.675, Y: 0.322}, Green: Point{X: 0.409, Y: 0.518}, Blue: Point{X: 0.167, Y: 0.04}, } // GamutC is used by newer Hue bulbs (A19 3rd gen+, LightStrips Plus, etc.) GamutC = Gamut{ Red: Point{X: 0.6915, Y: 0.3083}, Green: Point{X: 0.17, Y: 0.7}, Blue: Point{X: 0.1532, Y: 0.0475}, } )
Common Philips Hue color gamuts for different generations of bulbs.
Functions ¶
func ClampToGamut ¶
ClampToGamut clamps an XY color point to be within the specified gamut triangle. If the point is already within the gamut, it returns the original point. If the point is outside, it returns the nearest point on the gamut triangle.
func KelvinToMireds ¶
KelvinToMireds converts color temperature from Kelvin to mireds. Mireds (micro reciprocal degrees) = 1,000,000 / Kelvin
func MiredsToKelvin ¶
MiredsToKelvin converts color temperature from mireds to Kelvin. Kelvin = 1,000,000 / mireds
func MustBool ¶ added in v0.2.0
MustBool returns the bool value or the provided default. Also handles uint8 values (0 = false, non-zero = true).
func MustString ¶ added in v0.2.0
MustString returns the string value or the provided default.
func MustUint16 ¶ added in v0.2.0
MustUint16 returns the uint16 value or the provided default.
func MustUint32 ¶ added in v0.2.0
MustUint32 returns the uint32 value or the provided default.
func RGBToXY ¶
RGBToXY converts RGB color values to CIE 1931 XY color space coordinates. RGB values are in range 0-255, output XY values are in range 0-65279 (uint16). This function applies sRGB gamma correction and uses the sRGB to XYZ transformation.
func ReadValue ¶
ReadValue reads a value of the given type from a byte slice. Returns the value and the number of bytes consumed.
func ToBool ¶ added in v0.2.0
ToBool safely converts an interface{} to bool. Returns the value and true if successful, or false and false otherwise.
func ToBoolFromUint8 ¶ added in v0.2.0
ToBoolFromUint8 converts a uint8 value to bool (0 = false, non-zero = true). This is useful for ZCL boolean attributes that are encoded as uint8. Returns the boolean value and true if the input was uint8 or bool.
func ToBytes ¶ added in v0.2.0
ToBytes safely converts an interface{} to []byte. Returns the value and true if successful, or nil and false otherwise.
func ToFloat32 ¶ added in v0.2.0
ToFloat32 safely converts an interface{} to float32. Returns the value and true if successful, or 0 and false otherwise.
func ToFloat64 ¶ added in v0.2.0
ToFloat64 safely converts an interface{} to float64. Returns the value and true if successful, or 0 and false otherwise.
func ToInt8 ¶ added in v0.2.0
ToInt8 safely converts an interface{} to int8. Returns the value and true if successful, or 0 and false otherwise.
func ToInt16 ¶ added in v0.2.0
ToInt16 safely converts an interface{} to int16. Returns the value and true if successful, or 0 and false otherwise.
func ToInt32 ¶ added in v0.2.0
ToInt32 safely converts an interface{} to int32. Returns the value and true if successful, or 0 and false otherwise.
func ToInt64 ¶ added in v0.2.0
ToInt64 safely converts an interface{} to int64. Returns the value and true if successful, or 0 and false otherwise.
func ToString ¶ added in v0.2.0
ToString safely converts an interface{} to string. Returns the value and true if successful, or "" and false otherwise.
func ToUint8 ¶ added in v0.2.0
ToUint8 safely converts an interface{} to uint8. Returns the value and true if successful, or 0 and false otherwise.
func ToUint16 ¶ added in v0.2.0
ToUint16 safely converts an interface{} to uint16. Returns the value and true if successful, or 0 and false otherwise.
func ToUint32 ¶ added in v0.2.0
ToUint32 safely converts an interface{} to uint32. Returns the value and true if successful, or 0 and false otherwise.
func ToUint64 ¶ added in v0.2.0
ToUint64 safely converts an interface{} to uint64. Returns the value and true if successful, or 0 and false otherwise.
func WriteValue ¶
WriteValue writes a value to a byte slice for the given type.
Types ¶
type ArrayValue ¶
type ArrayValue struct {
ElementType DataType
Elements []interface{}
}
ArrayValue represents a ZCL array with element type and values.
type AttributeID ¶
type AttributeID uint16
AttributeID type for attribute IDs.
const ( AttrBasicZCLVersion AttributeID = 0x0000 AttrBasicAppVersion AttributeID = 0x0001 AttrBasicStackVersion AttributeID = 0x0002 AttrBasicHWVersion AttributeID = 0x0003 AttrBasicManufacturerName AttributeID = 0x0004 AttrBasicModelIdentifier AttributeID = 0x0005 AttrBasicDateCode AttributeID = 0x0006 AttrBasicPowerSource AttributeID = 0x0007 AttrBasicProductCode AttributeID = 0x000A AttrBasicProductURL AttributeID = 0x000B AttrBasicManufacturerVersionDetails AttributeID = 0x000C AttrBasicSerialNumber AttributeID = 0x000D AttrBasicProductLabel AttributeID = 0x000E AttrBasicLocationDescription AttributeID = 0x0010 AttrBasicPhysicalEnvironment AttributeID = 0x0011 AttrBasicDeviceEnabled AttributeID = 0x0012 AttrBasicAlarmMask AttributeID = 0x0013 AttrBasicDisableLocalConfig AttributeID = 0x0014 AttrBasicSWBuildID AttributeID = 0x4000 AttrBasicGenericDeviceClass AttributeID = 0xFFFD AttrBasicGenericDeviceType AttributeID = 0xFFFE )
Basic Cluster Attributes (0x0000).
const ( // Mains Information. AttrPowerMainsVoltage AttributeID = 0x0000 // uint16 in 0.1V. AttrPowerMainsFrequency AttributeID = 0x0001 // uint8 in 2Hz increments. AttrPowerMainsAlarmMask AttributeID = 0x0010 // bitmap8. AttrPowerMainsVoltageMinThreshold AttributeID = 0x0011 // uint16. AttrPowerMainsVoltageMaxThreshold AttributeID = 0x0012 // uint16. AttrPowerMainsVoltageDwellTripPnt AttributeID = 0x0013 // uint16. // Battery Information Set 1. AttrPowerBatteryVoltage AttributeID = 0x0020 // uint8 in 0.1V. AttrPowerBatteryPercentage AttributeID = 0x0021 // uint8 in 0.5% (0-200). AttrPowerBatteryManufacturer AttributeID = 0x0030 // string. AttrPowerBatterySize AttributeID = 0x0031 // enum8. AttrPowerBatteryAHrRating AttributeID = 0x0032 // uint16. AttrPowerBatteryQuantity AttributeID = 0x0033 // uint8. AttrPowerBatteryRatedVoltage AttributeID = 0x0034 // uint8. AttrPowerBatteryAlarmMask AttributeID = 0x0035 // bitmap8. AttrPowerBatteryVoltageMinThreshold AttributeID = 0x0036 // uint8. AttrPowerBatteryVoltageThreshold1 AttributeID = 0x0037 // uint8. AttrPowerBatteryVoltageThreshold2 AttributeID = 0x0038 // uint8. AttrPowerBatteryVoltageThreshold3 AttributeID = 0x0039 // uint8. AttrPowerBatteryPercentageMinThreshold AttributeID = 0x003A // uint8. AttrPowerBatteryPercentageThreshold1 AttributeID = 0x003B // uint8. AttrPowerBatteryPercentageThreshold2 AttributeID = 0x003C // uint8. AttrPowerBatteryPercentageThreshold3 AttributeID = 0x003D // uint8. AttrPowerBatteryAlarmState AttributeID = 0x003E // bitmap32. // Battery Information Set 2. AttrPowerBattery2Voltage AttributeID = 0x0040 // uint8 in 0.1V. AttrPowerBattery2Percentage AttributeID = 0x0041 // uint8 in 0.5% (0-200). AttrPowerBattery2Manufacturer AttributeID = 0x0050 // string. AttrPowerBattery2Size AttributeID = 0x0051 // enum8. AttrPowerBattery2AHrRating AttributeID = 0x0052 // uint16. AttrPowerBattery2Quantity AttributeID = 0x0053 // uint8. AttrPowerBattery2RatedVoltage AttributeID = 0x0054 // uint8. AttrPowerBattery2AlarmMask AttributeID = 0x0055 // bitmap8. AttrPowerBattery2VoltageMinThreshold AttributeID = 0x0056 // uint8. AttrPowerBattery2VoltageThreshold1 AttributeID = 0x0057 // uint8. AttrPowerBattery2VoltageThreshold2 AttributeID = 0x0058 // uint8. AttrPowerBattery2VoltageThreshold3 AttributeID = 0x0059 // uint8. AttrPowerBattery2PercentageMinThreshold AttributeID = 0x005A // uint8. AttrPowerBattery2PercentageThreshold1 AttributeID = 0x005B // uint8. AttrPowerBattery2PercentageThreshold2 AttributeID = 0x005C // uint8. AttrPowerBattery2PercentageThreshold3 AttributeID = 0x005D // uint8. AttrPowerBattery2AlarmState AttributeID = 0x005E // bitmap32. // Battery Information Set 3. AttrPowerBattery3Voltage AttributeID = 0x0060 // uint8 in 0.1V. AttrPowerBattery3Percentage AttributeID = 0x0061 // uint8 in 0.5% (0-200). AttrPowerBattery3Manufacturer AttributeID = 0x0070 // string. AttrPowerBattery3Size AttributeID = 0x0071 // enum8. AttrPowerBattery3AHrRating AttributeID = 0x0072 // uint16. AttrPowerBattery3Quantity AttributeID = 0x0073 // uint8. AttrPowerBattery3RatedVoltage AttributeID = 0x0074 // uint8. AttrPowerBattery3AlarmMask AttributeID = 0x0075 // bitmap8. AttrPowerBattery3VoltageMinThreshold AttributeID = 0x0076 // uint8. AttrPowerBattery3VoltageThreshold1 AttributeID = 0x0077 // uint8. AttrPowerBattery3VoltageThreshold2 AttributeID = 0x0078 // uint8. AttrPowerBattery3VoltageThreshold3 AttributeID = 0x0079 // uint8. AttrPowerBattery3PercentageMinThreshold AttributeID = 0x007A // uint8. AttrPowerBattery3PercentageThreshold1 AttributeID = 0x007B // uint8. AttrPowerBattery3PercentageThreshold2 AttributeID = 0x007C // uint8. AttrPowerBattery3PercentageThreshold3 AttributeID = 0x007D // uint8. AttrPowerBattery3AlarmState AttributeID = 0x007E // bitmap32. )
Power Configuration Attributes (0x0001).
const ( AttrScenesSceneCount AttributeID = 0x0000 // Number of scenes stored. AttrScenesCurrentScene AttributeID = 0x0001 // Currently active scene ID. AttrScenesCurrentGroup AttributeID = 0x0002 // Currently active group ID. AttrScenesSceneValid AttributeID = 0x0003 // Whether current scene is valid. AttrScenesNameSupport AttributeID = 0x0004 // Whether scene names are supported. )
Scenes Cluster Attributes (0x0005).
const ( AttrPollControlCheckInInterval AttributeID = 0x0000 // uint32: check-in interval in quarter seconds. AttrPollControlLongPollInterval AttributeID = 0x0001 // uint32: long poll interval in quarter seconds. AttrPollControlShortPollInterval AttributeID = 0x0002 // uint16: short poll interval in quarter seconds. AttrPollControlFastPollTimeout AttributeID = 0x0003 // uint16: fast poll timeout in quarter seconds. AttrPollControlCheckInIntervalMin AttributeID = 0x0004 // uint32: minimum check-in interval. AttrPollControlLongPollIntervalMin AttributeID = 0x0005 // uint32: minimum long poll interval. AttrPollControlFastPollTimeoutMax AttributeID = 0x0006 // uint16: maximum fast poll timeout. )
PollControl Cluster Attributes (0x0020).
const ( AttrOnOff AttributeID = 0x0000 AttrGlobalSceneCtrl AttributeID = 0x4000 AttrOnTime AttributeID = 0x4001 AttrOffWaitTime AttributeID = 0x4002 AttrStartUpOnOff AttributeID = 0x4003 )
On/Off Cluster Attributes (0x0006).
const ( AttrLevelCurrentLevel AttributeID = 0x0000 // Current brightness level (0-254). AttrLevelRemainingTime AttributeID = 0x0001 // Time remaining in transition (1/10s). AttrLevelMinLevel AttributeID = 0x0002 // Minimum allowed level. AttrLevelMaxLevel AttributeID = 0x0003 // Maximum allowed level. AttrLevelCurrentFrequency AttributeID = 0x0004 // Current frequency (Hz). AttrLevelMinFrequency AttributeID = 0x0005 // Minimum frequency (Hz). AttrLevelMaxFrequency AttributeID = 0x0006 // Maximum frequency (Hz). AttrLevelOptions AttributeID = 0x000F // Behavior options bitmap. AttrLevelOnOffTransTime AttributeID = 0x0010 // Transition time for On/Off (1/10s). AttrLevelOnLevel AttributeID = 0x0011 // Level when turned on (0xFF=restore). AttrLevelOnTransTime AttributeID = 0x0012 // Transition time for on (1/10s). AttrLevelOffTransTime AttributeID = 0x0013 // Transition time for off (1/10s). AttrLevelDefaultMoveRate AttributeID = 0x0014 // Default rate for Move command. AttrLevelStartupLevel AttributeID = 0x4000 // Level on power-up (0xFF=previous). )
Level Control Cluster Attributes (0x0008).
const ( // Lock Information. AttrDoorLockState AttributeID = 0x0000 // enum8 (locked, unlocked, etc.). AttrDoorLockType AttributeID = 0x0001 // enum8. AttrDoorLockActuatorEnabled AttributeID = 0x0002 // boolean. AttrDoorLockDoorState AttributeID = 0x0003 // enum8 (open, closed). AttrDoorLockDoorOpenEvents AttributeID = 0x0004 // uint32. AttrDoorLockDoorClosedEvents AttributeID = 0x0005 // uint32. AttrDoorLockOpenPeriod AttributeID = 0x0006 // uint16. // User Settings. AttrDoorLockNumLogRecords AttributeID = 0x0010 // uint16. AttrDoorLockNumTotalUsers AttributeID = 0x0011 // uint16. AttrDoorLockNumPINUsers AttributeID = 0x0012 // uint16. AttrDoorLockNumRFIDUsers AttributeID = 0x0013 // uint16. AttrDoorLockMaxPINLen AttributeID = 0x0017 // uint8. AttrDoorLockMinPINLen AttributeID = 0x0018 // uint8. AttrDoorLockMaxRFIDLen AttributeID = 0x0019 // uint8. AttrDoorLockMinRFIDLen AttributeID = 0x001A // uint8. // Operating Settings. AttrDoorLockEnableLogging AttributeID = 0x0020 // boolean. AttrDoorLockLanguage AttributeID = 0x0021 // string. AttrDoorLockLEDSettings AttributeID = 0x0022 // uint8. AttrDoorLockAutoRelockTime AttributeID = 0x0023 // uint32. AttrDoorLockSoundVolume AttributeID = 0x0024 // uint8. AttrDoorLockOperatingMode AttributeID = 0x0025 // enum8. AttrDoorLockSupportedModes AttributeID = 0x0026 // bitmap16. AttrDoorLockDefaultConfigReg AttributeID = 0x0027 // bitmap16. AttrDoorLockEnableLocalProg AttributeID = 0x0028 // boolean. AttrDoorLockEnableOneTouchLocking AttributeID = 0x0029 // boolean. AttrDoorLockEnablePrivacyButton AttributeID = 0x002B // boolean. AttrDoorLockWrongCodeEntryLimit AttributeID = 0x0030 // uint8. AttrDoorLockUserCodeTempDisable AttributeID = 0x0031 // uint8. AttrDoorLockSendPINOverTheAir AttributeID = 0x0032 // boolean AttrDoorLockRequirePINForRF AttributeID = 0x0033 // boolean )
DoorLock Cluster Attributes (0x0101).
const ( // Information Attributes AttrWindowCoveringType AttributeID = 0x0000 // enum8. AttrWindowCoveringPhysicalClosedLimitLift AttributeID = 0x0001 // uint16. AttrWindowCoveringPhysicalClosedLimitTilt AttributeID = 0x0002 // uint16. AttrWindowCoveringCurrentPositionLift AttributeID = 0x0003 // uint16. AttrWindowCoveringCurrentPositionTilt AttributeID = 0x0004 // uint16. AttrWindowCoveringNumActuationsLift AttributeID = 0x0005 // uint16. AttrWindowCoveringNumActuationsTilt AttributeID = 0x0006 // uint16. AttrWindowCoveringConfigStatus AttributeID = 0x0007 // bitmap8: Configuration status AttrWindowCoveringCurrentPositionLiftPercent AttributeID = 0x0008 // uint8 (0-100%) AttrWindowCoveringCurrentPositionTiltPercent AttributeID = 0x0009 // uint8 (0-100%) AttrWindowCoveringOperationalStatus AttributeID = 0x000A // bitmap8: Current operation status AttrWindowCoveringTargetPositionLiftPct AttributeID = 0x000B // uint8: Target lift position % AttrWindowCoveringTargetPositionTiltPct AttributeID = 0x000C // uint8: Target tilt position % // Settings Attributes AttrWindowCoveringInstalledOpenLimitLift AttributeID = 0x0010 // uint16. AttrWindowCoveringInstalledClosedLimitLift AttributeID = 0x0011 // uint16. AttrWindowCoveringInstalledOpenLimitTilt AttributeID = 0x0012 // uint16. AttrWindowCoveringInstalledClosedLimitTilt AttributeID = 0x0013 // uint16. AttrWindowCoveringVelocityLift AttributeID = 0x0014 // uint16. AttrWindowCoveringAccelerationTimeLift AttributeID = 0x0015 // uint16. AttrWindowCoveringDecelerationTimeLift AttributeID = 0x0016 // uint16. AttrWindowCoveringMode AttributeID = 0x0017 // bitmap8: Mode AttrWindowCoveringIntermediateSetpointsLift AttributeID = 0x0018 // octet string AttrWindowCoveringIntermediateSetpointsTilt AttributeID = 0x0019 // octet string )
WindowCovering Cluster Attributes (0x0102)
const ( AttrColorCurrentHue AttributeID = 0x0000 AttrColorCurrentSaturation AttributeID = 0x0001 AttrColorRemainingTime AttributeID = 0x0002 AttrColorCurrentX AttributeID = 0x0003 AttrColorCurrentY AttributeID = 0x0004 AttrColorTempMireds AttributeID = 0x0007 // Color temperature in mireds AttrColorMode AttributeID = 0x0008 // 0=HS, 1=XY, 2=ColorTemp AttrColorTempMin AttributeID = 0x400B // Min color temp in mireds AttrColorTempMax AttributeID = 0x400C // Max color temp in mireds // Enhanced Color Control attributes (ZCL 6+) AttrColorCapabilities AttributeID = 0x400A // bitmap16: Supported color features (MANDATORY) AttrColorEnhancedCurrentHue AttributeID = 0x4000 // uint16: Enhanced hue (0-65535) AttrColorEnhancedColorMode AttributeID = 0x4001 // enum8: Enhanced color mode AttrColorColorLoopActive AttributeID = 0x4002 // uint8: Color loop active AttrColorColorLoopDirection AttributeID = 0x4003 // uint8: Color loop direction AttrColorColorLoopTime AttributeID = 0x4004 // uint16: Color loop time AttrColorColorLoopStartEnhancedHue AttributeID = 0x4005 // uint16. AttrColorColorLoopStoredEnhancedHue AttributeID = 0x4006 // uint16. )
Color Control Cluster Attributes (0x0300)
const ( // Thermostat Information Set AttrThermostatLocalTemp AttributeID = 0x0000 // int16 in 0.01°C AttrThermostatOutdoorTemp AttributeID = 0x0001 // int16 in 0.01°C AttrThermostatOccupancy AttributeID = 0x0002 // bitmap8. AttrThermostatAbsMinHeatSetpoint AttributeID = 0x0003 // int16 in 0.01°C AttrThermostatAbsMaxHeatSetpoint AttributeID = 0x0004 // int16 in 0.01°C AttrThermostatAbsMinCoolSetpoint AttributeID = 0x0005 // int16 in 0.01°C AttrThermostatAbsMaxCoolSetpoint AttributeID = 0x0006 // int16 in 0.01°C AttrThermostatPICoolingDemand AttributeID = 0x0007 // uint8 (0-100%) AttrThermostatPIHeatingDemand AttributeID = 0x0008 // uint8 (0-100%) // Thermostat Settings Set AttrThermostatLocalTempCalibration AttributeID = 0x0010 // int8 in 0.1°C AttrThermostatOccupiedCoolingSetpoint AttributeID = 0x0011 // int16 in 0.01°C AttrThermostatOccupiedHeatingSetpoint AttributeID = 0x0012 // int16 in 0.01°C AttrThermostatUnoccupiedCoolingSetpoint AttributeID = 0x0013 // int16 in 0.01°C AttrThermostatUnoccupiedHeatingSetpoint AttributeID = 0x0014 // int16 in 0.01°C AttrThermostatMinHeatSetpointLimit AttributeID = 0x0015 // int16 in 0.01°C AttrThermostatMaxHeatSetpointLimit AttributeID = 0x0016 // int16 in 0.01°C AttrThermostatMinCoolSetpointLimit AttributeID = 0x0017 // int16 in 0.01°C AttrThermostatMaxCoolSetpointLimit AttributeID = 0x0018 // int16 in 0.01°C AttrThermostatMinSetpointDeadBand AttributeID = 0x0019 // int8 AttrThermostatControlSeqOfOper AttributeID = 0x001B // enum8. AttrThermostatSystemMode AttributeID = 0x001C // enum8. AttrThermostatRunningMode AttributeID = 0x001E // enum8. AttrThermostatRunningState AttributeID = 0x0029 // bitmap16 )
Thermostat Cluster Attributes (0x0201)
const ( AttrFanMode AttributeID = 0x0000 // enum8: current fan mode AttrFanModeSequence AttributeID = 0x0001 // enum8: supported fan mode sequence AttrFanPercentSetting AttributeID = 0x0002 // uint8: fan speed as percentage (0-100%) AttrFanPercentCurrent AttributeID = 0x0003 // uint8: current fan speed percentage (0-100%) AttrFanSpeedMax AttributeID = 0x0004 // uint8: maximum fan speed AttrFanSpeedSetting AttributeID = 0x0005 // uint8: fan speed setting AttrFanSpeedCurrent AttributeID = 0x0006 // uint8: current fan speed )
Fan Cluster Attributes (0x0202)
const ( AttrTimeTime AttributeID = 0x0000 // uint32: UTC time in seconds since Jan 1, 2000 AttrTimeStatus AttributeID = 0x0001 // bitmap8: status flags AttrTimeZone AttributeID = 0x0002 // int32: offset from UTC in seconds AttrTimeDstStart AttributeID = 0x0003 // uint32: DST start time AttrTimeDstEnd AttributeID = 0x0004 // uint32: DST end time AttrTimeDstShift AttributeID = 0x0005 // int32: DST shift in seconds AttrTimeStandardTime AttributeID = 0x0006 // uint32: standard time AttrTimeLocalTime AttributeID = 0x0007 // uint32: local time AttrTimeLastSetTime AttributeID = 0x0008 // uint32: last time Time was set AttrTimeValidUntilTime AttributeID = 0x0009 // uint32: time until which Time is valid )
Time Cluster Attributes (0x000A)
const ( AttrBinaryInputActiveText AttributeID = 0x0004 // string: text for active state AttrBinaryInputDescription AttributeID = 0x001C // string: description of input AttrBinaryInputInactiveText AttributeID = 0x002E // string: text for inactive state AttrBinaryInputOutOfService AttributeID = 0x0051 // boolean: out of service flag AttrBinaryInputPolarity AttributeID = 0x0054 // enum8: 0=normal, 1=reversed AttrBinaryInputPresentValue AttributeID = 0x0055 // boolean: current input value AttrBinaryInputReliability AttributeID = 0x0067 // enum8: reliability state AttrBinaryInputStatusFlags AttributeID = 0x006F // bitmap8: status flags )
Binary Input Cluster Attributes (0x000F)
const ( AttrAnalogInputDescription AttributeID = 0x001C // string: description of input AttrAnalogInputMaxPresentValue AttributeID = 0x0041 // single (float32): max value AttrAnalogInputMinPresentValue AttributeID = 0x0045 // single (float32): min value AttrAnalogInputOutOfService AttributeID = 0x0051 // boolean: out of service AttrAnalogInputPresentValue AttributeID = 0x0055 // single (float32): current analog value AttrAnalogInputReliability AttributeID = 0x0067 // enum8: reliability (IOReliability) AttrAnalogInputResolution AttributeID = 0x006A // single (float32): resolution AttrAnalogInputStatusFlags AttributeID = 0x006F // bitmap8: status flags AttrAnalogInputEngineeringUnits AttributeID = 0x0075 // enum16: engineering units )
AnalogInput Cluster Attributes (0x000C)
const ( AttrAnalogOutputDescription AttributeID = 0x001C // string: description of output AttrAnalogOutputMaxPresentValue AttributeID = 0x0041 // single (float32): max value AttrAnalogOutputMinPresentValue AttributeID = 0x0045 // single (float32): min value AttrAnalogOutputOutOfService AttributeID = 0x0051 // boolean: out of service AttrAnalogOutputPresentValue AttributeID = 0x0055 // single (float32): current output value (writable) AttrAnalogOutputReliability AttributeID = 0x0067 // enum8: reliability (IOReliability) AttrAnalogOutputRelinquishDefault AttributeID = 0x0068 // single (float32): default when released AttrAnalogOutputResolution AttributeID = 0x006A // single (float32): resolution AttrAnalogOutputStatusFlags AttributeID = 0x006F // bitmap8: status flags AttrAnalogOutputEngineeringUnits AttributeID = 0x0075 // enum16: engineering units )
AnalogOutput Cluster Attributes (0x000D)
const ( AttrAnalogValueDescription AttributeID = 0x001C // string: description AttrAnalogValueOutOfService AttributeID = 0x0051 // boolean: out of service AttrAnalogValuePresentValue AttributeID = 0x0055 // single (float32): current analog value (read/write) AttrAnalogValueReliability AttributeID = 0x0067 // enum8: reliability (IOReliability) AttrAnalogValueRelinquishDefault AttributeID = 0x0068 // single (float32): default when released AttrAnalogValueStatusFlags AttributeID = 0x006F // bitmap8: status flags AttrAnalogValueEngineeringUnits AttributeID = 0x0075 // enum16: engineering units )
AnalogValue Cluster Attributes (0x000E)
const ( AttrBinaryOutputActiveText AttributeID = 0x0004 // string: text for active state AttrBinaryOutputDescription AttributeID = 0x001C // string: description AttrBinaryOutputInactiveText AttributeID = 0x002E // string: text for inactive state AttrBinaryOutputMinimumOffTime AttributeID = 0x0042 // uint32: minimum off time in ms AttrBinaryOutputMinimumOnTime AttributeID = 0x0043 // uint32: minimum on time in ms AttrBinaryOutputOutOfService AttributeID = 0x0051 // boolean: out of service AttrBinaryOutputPolarity AttributeID = 0x0054 // enum8: 0=normal, 1=reversed AttrBinaryOutputPresentValue AttributeID = 0x0055 // boolean: current output value (writable) AttrBinaryOutputReliability AttributeID = 0x0067 // enum8: reliability (IOReliability) AttrBinaryOutputRelinquishDefault AttributeID = 0x0068 // boolean: default when released AttrBinaryOutputStatusFlags AttributeID = 0x006F // bitmap8: status flags )
BinaryOutput Cluster Attributes (0x0010)
const ( AttrBinaryValueActiveText AttributeID = 0x0004 // string: text for active state AttrBinaryValueDescription AttributeID = 0x001C // string: description AttrBinaryValueInactiveText AttributeID = 0x002E // string: text for inactive state AttrBinaryValueMinimumOffTime AttributeID = 0x0042 // uint32: minimum off time in milliseconds AttrBinaryValueMinimumOnTime AttributeID = 0x0043 // uint32: minimum on time in milliseconds AttrBinaryValueOutOfService AttributeID = 0x0051 // boolean: out of service flag AttrBinaryValuePresentValue AttributeID = 0x0055 // boolean: current value (read/write) AttrBinaryValueReliability AttributeID = 0x0067 // enum8: reliability (IOReliability) AttrBinaryValueRelinquishDef AttributeID = 0x0068 // boolean: default value when released AttrBinaryValueStatusFlags AttributeID = 0x006F // bitmap8: status flags )
BinaryValue Cluster Attributes (0x0011)
const ( AttrMultistateInputStateText AttributeID = 0x000E // array of strings: text for each state AttrMultistateInputDescription AttributeID = 0x001C // string: description AttrMultistateInputNumberOfStates AttributeID = 0x004A // uint16: number of possible states AttrMultistateInputOutOfService AttributeID = 0x0051 // boolean: out of service flag AttrMultistateInputPresentValue AttributeID = 0x0055 // uint16: current state value (1-based) AttrMultistateInputReliability AttributeID = 0x0067 // enum8: reliability (IOReliability) AttrMultistateInputStatusFlags AttributeID = 0x006F // bitmap8: status flags )
MultistateInput Cluster Attributes (0x0012)
const ( AttrMultistateOutputDescription AttributeID = 0x001C // string: description AttrMultistateOutputNumberOfStates AttributeID = 0x004A // uint16: number of states AttrMultistateOutputOutOfService AttributeID = 0x0051 // boolean: out of service AttrMultistateOutputPresentValue AttributeID = 0x0055 // uint16: current state (writable) AttrMultistateOutputReliability AttributeID = 0x0067 // enum8: reliability (IOReliability) AttrMultistateOutputRelinquishDefault AttributeID = 0x0068 // uint16: default when released AttrMultistateOutputStatusFlags AttributeID = 0x006F // bitmap8: status flags )
MultistateOutput Cluster Attributes (0x0013)
const ( AttrMultistateValueDescription AttributeID = 0x001C // string: description AttrMultistateValueNumberOfStates AttributeID = 0x004A // uint16: number of states AttrMultistateValueOutOfService AttributeID = 0x0051 // boolean: out of service AttrMultistateValuePresentValue AttributeID = 0x0055 // uint16: current value (read/write) AttrMultistateValueReliability AttributeID = 0x0067 // enum8: reliability (IOReliability) AttrMultistateValueRelinquishDefault AttributeID = 0x0068 // uint16: default when released AttrMultistateValueStatusFlags AttributeID = 0x006F // bitmap8: status flags )
MultistateValue Cluster Attributes (0x0014)
const ( AttrTempMeasuredValue AttributeID = 0x0000 AttrTempMinMeasuredValue AttributeID = 0x0001 AttrTempMaxMeasuredValue AttributeID = 0x0002 AttrTempTolerance AttributeID = 0x0003 )
Temperature Measurement Attributes (0x0402)
const ( AttrHumidityMeasuredValue AttributeID = 0x0000 AttrHumidityMinMeasuredValue AttributeID = 0x0001 AttrHumidityMaxMeasuredValue AttributeID = 0x0002 AttrHumidityTolerance AttributeID = 0x0003 )
Humidity Measurement Attributes (0x0405)
const ( AttrFlowMeasuredValue AttributeID = 0x0000 // uint16: Measured flow in 0.1 m³/h AttrFlowMinMeasuredValue AttributeID = 0x0001 // uint16: Min measurable value AttrFlowMaxMeasuredValue AttributeID = 0x0002 // uint16: Max measurable value AttrFlowTolerance AttributeID = 0x0003 // uint16: Tolerance )
Flow Measurement Cluster Attributes (0x0404)
const ( AttrPressureMeasuredValue AttributeID = 0x0000 // int16 in 10 Pa (0.1 hPa) AttrPressureMinMeasuredValue AttributeID = 0x0001 // int16 in 10 Pa (0.1 hPa) AttrPressureMaxMeasuredValue AttributeID = 0x0002 // int16 in 10 Pa (0.1 hPa) AttrPressureTolerance AttributeID = 0x0003 // uint16 in 10 Pa (0.1 hPa) AttrPressureScaledValue AttributeID = 0x0010 // int16 scaled value AttrPressureMinScaledValue AttributeID = 0x0011 // int16 scaled value AttrPressureMaxScaledValue AttributeID = 0x0012 // int16 scaled value AttrPressureScaledTolerance AttributeID = 0x0013 // uint16 scaled tolerance AttrPressureScale AttributeID = 0x0014 // int8 (10^scale multiplier) )
Pressure Measurement Attributes (0x0403)
const ( AttrIlluminanceMeasuredValue AttributeID = 0x0000 AttrIlluminanceMinMeasuredValue AttributeID = 0x0001 AttrIlluminanceMaxMeasuredValue AttributeID = 0x0002 AttrIlluminanceTolerance AttributeID = 0x0003 )
Illuminance Measurement Attributes (0x0400)
const ( AttrCOMeasuredValue AttributeID = 0x0000 // single (float32) - ppm AttrCOMinMeasuredValue AttributeID = 0x0001 // single AttrCOMaxMeasuredValue AttributeID = 0x0002 // single AttrCOTolerance AttributeID = 0x0003 // single )
Carbon Monoxide Concentration Measurement Attributes (0x040C)
const ( AttrCO2MeasuredValue AttributeID = 0x0000 // single (float32) - ppm AttrCO2MinMeasuredValue AttributeID = 0x0001 // single AttrCO2MaxMeasuredValue AttributeID = 0x0002 // single AttrCO2Tolerance AttributeID = 0x0003 // single )
Carbon Dioxide Concentration Measurement Attributes (0x040D)
const ( AttrPM25MeasuredValue AttributeID = 0x0000 // single (float32) - µg/m³ AttrPM25MinMeasuredValue AttributeID = 0x0001 // single AttrPM25MaxMeasuredValue AttributeID = 0x0002 // single AttrPM25Tolerance AttributeID = 0x0003 // single )
PM2.5 Measurement Attributes (0x042A)
const ( AttrFormaldehydeMeasuredValue AttributeID = 0x0000 // single (float32) - ppm AttrFormaldehydeMinMeasuredValue AttributeID = 0x0001 // single AttrFormaldehydeMaxMeasuredValue AttributeID = 0x0002 // single AttrFormaldehydeTolerance AttributeID = 0x0003 // single )
Formaldehyde Measurement Attributes (0x042B)
const ( AttrOccupancyValue AttributeID = 0x0000 AttrOccupancyType AttributeID = 0x0001 AttrOccupancyPIROccupiedToUnoccupiedDelay AttributeID = 0x0010 AttrOccupancyPIRUnoccupiedToOccupiedDelay AttributeID = 0x0011 AttrOccupancyPIRUnoccupiedToOccupiedThreshold AttributeID = 0x0012 )
Occupancy Sensing Attributes (0x0406)
const ( AttrIASZoneState AttributeID = 0x0000 // enum8: 0=not enrolled, 1=enrolled AttrIASZoneType AttributeID = 0x0001 // enum16: type of zone AttrIASZoneStatus AttributeID = 0x0002 // bitmap16: current zone status AttrIASZoneCIEAddr AttributeID = 0x0010 // IEEE address of CIE (coordinator) AttrIASZoneID AttributeID = 0x0011 // uint8: zone ID (0-254) AttrIASZoneNumZoneSensitivityLevels AttributeID = 0x0012 // uint8: number of sensitivity levels AttrIASZoneCurrentZoneSensitivityLevel AttributeID = 0x0013 // uint8: current sensitivity level )
IAS Zone Attributes (0x0500)
const ( // Basic Information AttrElecMeasType AttributeID = 0x0000 // Bitmap of measurement types supported // AC (Non-phase specific) Measurements AttrElecACFrequency AttributeID = 0x0300 // Frequency in 0.01 Hz AttrElecACFrequencyMin AttributeID = 0x0301 AttrElecACFrequencyMax AttributeID = 0x0302 AttrElecACFrequencyDivisor AttributeID = 0x0400 // Divisor for frequency AttrElecPowerMultiplier AttributeID = 0x0402 // Multiplier for power AttrElecPowerDivisor AttributeID = 0x0403 // Divisor for power // AC Single Phase Measurements AttrElecRMSVoltage AttributeID = 0x0505 // RMS voltage in volts (with divisor) AttrElecRMSVoltageMin AttributeID = 0x0506 AttrElecRMSVoltageMax AttributeID = 0x0507 AttrElecRMSCurrent AttributeID = 0x0508 // RMS current in amps (with divisor) AttrElecRMSCurrentMin AttributeID = 0x0509 AttrElecRMSCurrentMax AttributeID = 0x050A AttrElecActivePower AttributeID = 0x050B // Active power in watts (with divisor) AttrElecActivePowerMin AttributeID = 0x050C AttrElecActivePowerMax AttributeID = 0x050D AttrElecReactivePower AttributeID = 0x050E // Reactive power in VAR AttrElecApparentPower AttributeID = 0x050F // Apparent power in VA AttrElecPowerFactor AttributeID = 0x0510 // Power factor (-100 to 100, in %) AttrElecACVoltageMulti AttributeID = 0x0600 // Multiplier for voltage AttrElecACVoltageDivisor AttributeID = 0x0601 // Divisor for voltage AttrElecACCurrentMulti AttributeID = 0x0602 // Multiplier for current AttrElecACCurrentDivisor AttributeID = 0x0603 // Divisor for current AttrElecACPowerMulti AttributeID = 0x0604 // Multiplier for power AttrElecACPowerDivisor AttributeID = 0x0605 // Divisor for power )
Electrical Measurement Cluster Attributes (0x0B04) These provide real-time instantaneous electrical measurements.
const ( // Reading Information Set AttrMeterCurrentSummation AttributeID = 0x0000 // Total energy consumed (with formatting) AttrMeterCurrentTier1 AttributeID = 0x0100 // Tier 1 consumption AttrMeterCurrentTier2 AttributeID = 0x0102 // Tier 2 consumption // Meter Status AttrMeterStatus AttributeID = 0x0200 // Metering device status // Formatting AttrMeterUnitOfMeasure AttributeID = 0x0300 // Unit (0=kWh, 1=m3, etc.) AttrMeterMultiplier AttributeID = 0x0301 // Multiplier for summation AttrMeterDivisor AttributeID = 0x0302 // Divisor for summation AttrMeterSummationFormat AttributeID = 0x0303 // Format of summation (decimal places) AttrMeterDemandFormat AttributeID = 0x0304 // Format of demand AttrMeterHistoricalFormat AttributeID = 0x0305 // Format of historical data // Historical Consumption AttrMeterInstantDemand AttributeID = 0x0400 // Instantaneous demand (watts) AttrMeterCurrentDayConsume AttributeID = 0x0401 // Today's consumption AttrMeterPrevDayConsume AttributeID = 0x0403 // Yesterday's consumption )
Simple Metering Cluster Attributes (0x0702) These provide cumulative energy consumption readings.
const ( AttrDRLCUtilityEnrolmentGroup AttributeID = 0x0000 // uint8: utility enrolment group AttrDRLCStartRandomizeMinutes AttributeID = 0x0001 // uint8: randomize start time AttrDRLCDurationRandomizeMinutes AttributeID = 0x0002 // uint8: randomize duration AttrDRLCDeviceClassValue AttributeID = 0x0003 // uint16: device class bitmap )
DRLC (Demand Response and Load Control) Cluster Attributes (0x0701)
const ( // Tier Label Attributes - names for pricing tiers AttrPriceTierLabel1 AttributeID = 0x0000 // string: tier 1 label AttrPriceTierLabel2 AttributeID = 0x0001 // string: tier 2 label AttrPriceTierLabel3 AttributeID = 0x0002 // string: tier 3 label AttrPriceTierLabel4 AttributeID = 0x0003 // string: tier 4 label AttrPriceTierLabel5 AttributeID = 0x0004 // string: tier 5 label AttrPriceTierLabel6 AttributeID = 0x0005 // string: tier 6 label AttrPriceTierLabel7 AttributeID = 0x0006 // string: tier 7 label AttrPriceTierLabel8 AttributeID = 0x0007 // string: tier 8 label AttrPriceTierLabel9 AttributeID = 0x0008 // string: tier 9 label AttrPriceTierLabel10 AttributeID = 0x0009 // string: tier 10 label AttrPriceTierLabel11 AttributeID = 0x000A // string: tier 11 label AttrPriceTierLabel12 AttributeID = 0x000B // string: tier 12 label AttrPriceTierLabel13 AttributeID = 0x000C // string: tier 13 label AttrPriceTierLabel14 AttributeID = 0x000D // string: tier 14 label AttrPriceTierLabel15 AttributeID = 0x000E // string: tier 15 label AttrPriceTierLabel16 AttributeID = 0x000F // string: tier 16 label // Block Threshold Attributes - consumption thresholds for each block AttrPriceBlock1Threshold AttributeID = 0x0100 // uint48: threshold for block 1 AttrPriceBlock2Threshold AttributeID = 0x0101 // uint48: threshold for block 2 AttrPriceBlock3Threshold AttributeID = 0x0102 // uint48: threshold for block 3 AttrPriceBlock4Threshold AttributeID = 0x0103 // uint48: threshold for block 4 AttrPriceBlock5Threshold AttributeID = 0x0104 // uint48: threshold for block 5 AttrPriceBlock6Threshold AttributeID = 0x0105 // uint48: threshold for block 6 AttrPriceBlock7Threshold AttributeID = 0x0106 // uint48: threshold for block 7 AttrPriceBlock8Threshold AttributeID = 0x0107 // uint48: threshold for block 8 AttrPriceBlock9Threshold AttributeID = 0x0108 // uint48: threshold for block 9 AttrPriceBlock10Threshold AttributeID = 0x0109 // uint48: threshold for block 10 AttrPriceBlock11Threshold AttributeID = 0x010A // uint48: threshold for block 11 AttrPriceBlock12Threshold AttributeID = 0x010B // uint48: threshold for block 12 AttrPriceBlock13Threshold AttributeID = 0x010C // uint48: threshold for block 13 AttrPriceBlock14Threshold AttributeID = 0x010D // uint48: threshold for block 14 AttrPriceBlock15Threshold AttributeID = 0x010E // uint48: threshold for block 15 AttrPriceBlock16Threshold AttributeID = 0x010F // uint48: threshold for block 16 // Block Period Attributes AttrPriceStartOfBlockPeriod AttributeID = 0x0200 // uint32: UTC time of block period start AttrPriceBlockPeriodDuration AttributeID = 0x0201 // uint24: duration in minutes AttrPriceThresholdMultiplier AttributeID = 0x0202 // uint24: multiplier for thresholds AttrPriceThresholdDivisor AttributeID = 0x0203 // uint24: divisor for thresholds AttrPriceBlockPeriodDurationType AttributeID = 0x0204 // enum8: duration type // Current Tier Summation Attributes (most commonly used) AttrPriceCurrentTier1SummationDelivered AttributeID = 0x0100 // uint48: tier 1 delivered AttrPriceCurrentTier2SummationDelivered AttributeID = 0x0102 // uint48: tier 2 delivered AttrPriceCurrentTier3SummationDelivered AttributeID = 0x0104 // uint48: tier 3 delivered AttrPriceCurrentTier4SummationDelivered AttributeID = 0x0106 // uint48: tier 4 delivered AttrPriceCurrentTier5SummationDelivered AttributeID = 0x0108 // uint48: tier 5 delivered AttrPriceCurrentTier6SummationDelivered AttributeID = 0x010A // uint48: tier 6 delivered )
Price Cluster Attributes (0x0700) Part of the Smart Energy profile for pricing information.
const ( AttrOTAUpgradeServerID AttributeID = 0x0000 // IEEE address of OTA server AttrOTAFileOffset AttributeID = 0x0001 // uint32: current file offset AttrOTACurrentFileVersion AttributeID = 0x0002 // uint32: current firmware version AttrOTACurrentZigBeeStackVersion AttributeID = 0x0003 // uint16: current stack version AttrOTADownloadedFileVersion AttributeID = 0x0004 // uint32: downloaded file version AttrOTADownloadedZigBeeStackVersion AttributeID = 0x0005 // uint16: downloaded stack version AttrOTAImageUpgradeStatus AttributeID = 0x0006 // enum8: upgrade status AttrOTAManufacturerID AttributeID = 0x0007 // uint16: manufacturer ID AttrOTAImageTypeID AttributeID = 0x0008 // uint16: image type ID AttrOTAMinBlockRequestDelay AttributeID = 0x0009 // uint16: min delay between blocks (ms) AttrOTAImageStamp AttributeID = 0x000A // uint32: image stamp )
OTA Upgrade Cluster Attributes (0x0019) - Server side
const (
AttrAlarmCount AttributeID = 0x0000 // Number of alarm entries currently in the alarm log (uint16).
)
Alarms Cluster Attributes (0x0009).
const (
AttrIASWDMaxDuration AttributeID = 0x0000 // Maximum warning duration in seconds (uint16)
)
IAS Warning Device Cluster Attributes (0x0502)
const (
AttrIdentifyTime AttributeID = 0x0000 // Time remaining in identify mode (seconds).
)
Identify Cluster Attributes (0x0003).
const (
AttrTuyaEnergyReset AttributeID = 0xD004 // Some Tuya plugs use this to reset energy
)
Tuya-specific attributes for energy reset (cluster 0xE001)
type AttributeValue ¶
type AttributeValue struct {
Type DataType
Value interface{}
}
AttributeValue represents an attribute with its type and value.
type BatterySize ¶
type BatterySize uint8
BatterySize represents the size/type of battery installed.
const ( BatterySizeNoBattery BatterySize = 0x00 // No battery BatterySizeBuiltIn BatterySize = 0x01 // Built-in, non-replaceable BatterySizeOther BatterySize = 0x02 // Other BatterySizeAA BatterySize = 0x03 // AA battery BatterySizeAAA BatterySize = 0x04 // AAA battery BatterySizeC BatterySize = 0x05 // C battery BatterySizeD BatterySize = 0x06 // D battery BatterySizeCR2 BatterySize = 0x07 // CR2 battery BatterySizeCR123A BatterySize = 0x08 // CR123A battery BatterySizeUnknown BatterySize = 0xFF // Unknown )
func (BatterySize) String ¶
func (b BatterySize) String() string
String returns human-readable battery size name.
type ClusterID ¶
type ClusterID uint16
ClusterID defines standard Zigbee cluster IDs.
const ( ClusterBasic ClusterID = 0x0000 ClusterPowerConfig ClusterID = 0x0001 ClusterDeviceTemp ClusterID = 0x0002 ClusterIdentify ClusterID = 0x0003 ClusterGroups ClusterID = 0x0004 ClusterScenes ClusterID = 0x0005 ClusterOnOff ClusterID = 0x0006 ClusterOnOffConfig ClusterID = 0x0007 ClusterLevelControl ClusterID = 0x0008 ClusterAlarms ClusterID = 0x0009 ClusterDoorLock ClusterID = 0x0101 ClusterWindowCovering ClusterID = 0x0102 ClusterColorControl ClusterID = 0x0300 ClusterTime ClusterID = 0x000A ClusterAnalogInput ClusterID = 0x000C ClusterAnalogOutput ClusterID = 0x000D ClusterAnalogValue ClusterID = 0x000E ClusterBinaryInput ClusterID = 0x000F ClusterBinaryOutput ClusterID = 0x0010 ClusterBinaryValue ClusterID = 0x0011 ClusterMultistateInput ClusterID = 0x0012 ClusterMultistateOutput ClusterID = 0x0013 ClusterMultistateValue ClusterID = 0x0014 ClusterOTAUpgrade ClusterID = 0x0019 ClusterPollControl ClusterID = 0x0020 ClusterElectricalMeas ClusterID = 0x0B04 ClusterPrice ClusterID = 0x0700 ClusterDRLC ClusterID = 0x0701 ClusterMeteringSimple ClusterID = 0x0702 ClusterSEMessaging ClusterID = 0x0703 ClusterTempMeasurement ClusterID = 0x0402 ClusterPressureMeas ClusterID = 0x0403 ClusterFlowMeasurement ClusterID = 0x0404 ClusterHumidityMeas ClusterID = 0x0405 ClusterIlluminanceMeas ClusterID = 0x0400 ClusterCarbonMonoxide ClusterID = 0x040C ClusterCarbonDioxide ClusterID = 0x040D ClusterPM25Measurement ClusterID = 0x042A ClusterFormaldehydeMeasurement ClusterID = 0x042B ClusterThermostat ClusterID = 0x0201 ClusterFan ClusterID = 0x0202 ClusterOccupancySensing ClusterID = 0x0406 ClusterIASZone ClusterID = 0x0500 ClusterIASWD ClusterID = 0x0502 )
type ConfigureReportingResult ¶
type ConfigureReportingResult struct {
Status Status // 0x00 = success
Direction uint8 // Only present if status != 0x00
AttributeID AttributeID // Only present if status != 0x00
}
ConfigureReportingResult represents a single attribute result in a configure reporting response.
func ParseConfigureReportingResponse ¶
func ParseConfigureReportingResponse(payload []byte) ([]ConfigureReportingResult, error)
ParseConfigureReportingResponse parses a configure reporting response. Format: [status:1][direction:1 if status!=0][attrID:2 if status!=0]...
type DataType ¶
type DataType uint8
DataType defines ZCL data types.
const ( TypeNoData DataType = 0x00 TypeData8 DataType = 0x08 TypeData16 DataType = 0x09 TypeData24 DataType = 0x0A TypeData32 DataType = 0x0B TypeData40 DataType = 0x0C TypeData48 DataType = 0x0D TypeData56 DataType = 0x0E TypeData64 DataType = 0x0F TypeBoolean DataType = 0x10 TypeBitmap8 DataType = 0x18 TypeBitmap16 DataType = 0x19 TypeBitmap24 DataType = 0x1A TypeBitmap32 DataType = 0x1B TypeBitmap40 DataType = 0x1C TypeBitmap48 DataType = 0x1D TypeBitmap56 DataType = 0x1E TypeBitmap64 DataType = 0x1F TypeUint8 DataType = 0x20 TypeUint16 DataType = 0x21 TypeUint24 DataType = 0x22 TypeUint32 DataType = 0x23 TypeUint40 DataType = 0x24 TypeUint48 DataType = 0x25 TypeUint56 DataType = 0x26 TypeUint64 DataType = 0x27 TypeInt8 DataType = 0x28 TypeInt16 DataType = 0x29 TypeInt24 DataType = 0x2A TypeInt32 DataType = 0x2B TypeInt40 DataType = 0x2C TypeInt48 DataType = 0x2D TypeInt56 DataType = 0x2E TypeInt64 DataType = 0x2F TypeEnum8 DataType = 0x30 TypeEnum16 DataType = 0x31 TypeSingle DataType = 0x39 // float32 TypeDouble DataType = 0x3A // float64 TypeOctetString DataType = 0x41 TypeCharString DataType = 0x42 TypeLongOctet DataType = 0x43 // Long octet string (2-byte length) TypeLongChar DataType = 0x44 // Long char string (2-byte length) TypeArray DataType = 0x48 TypeStruct DataType = 0x4C TypeSet DataType = 0x50 TypeBag DataType = 0x51 TypeTimeOfDay DataType = 0xE0 TypeDate DataType = 0xE1 TypeUTCTime DataType = 0xE2 TypeClusterID DataType = 0xE8 TypeAttrID DataType = 0xE9 TypeIEEEAddr DataType = 0xF0 TypeSecKey DataType = 0xF1 )
type DoorLockState ¶
type DoorLockState uint8
DoorLockState represents the current state of the door lock.
const ( DoorLockStateNotFullyLocked DoorLockState = 0x00 // Lock is not fully locked DoorLockStateLocked DoorLockState = 0x01 // Lock is locked DoorLockStateUnlocked DoorLockState = 0x02 // Lock is unlocked DoorLockStateUndefined DoorLockState = 0xFF // Lock state is undefined )
func (DoorLockState) String ¶
func (d DoorLockState) String() string
String returns human-readable door lock state name.
type EngineeringUnits ¶
type EngineeringUnits uint16
const ( EngineeringUnitsSquareMeters EngineeringUnits = 0 // Area (m²) EngineeringUnitsCubicMeters EngineeringUnits = 2 // Volume (m³) EngineeringUnitsAmperes EngineeringUnits = 3 // Electric current (A) EngineeringUnitsVolts EngineeringUnits = 5 // Electric potential (V) EngineeringUnitsWatts EngineeringUnits = 47 // Power (W) EngineeringUnitsKilowatts EngineeringUnits = 48 // Power (kW) EngineeringUnitsDegreesCelsius EngineeringUnits = 62 // Temperature (°C) EngineeringUnitsDegreesFahrenheit EngineeringUnits = 64 // Temperature (°F) EngineeringUnitsLiters EngineeringUnits = 75 // Volume (L) EngineeringUnitsNoUnits EngineeringUnits = 95 // Dimensionless EngineeringUnitsPercent EngineeringUnits = 98 // Percent (%) )
EngineeringUnits values for common measurements.
func (EngineeringUnits) String ¶
func (e EngineeringUnits) String() string
String returns human-readable engineering units name.
type FanMode ¶
type FanMode uint8
FanMode represents the operating mode of a fan.
const ( FanModeOff FanMode = 0x00 // Fan is off FanModeLow FanMode = 0x01 // Low speed FanModeMedium FanMode = 0x02 // Medium speed FanModeHigh FanMode = 0x03 // High speed FanModeOn FanMode = 0x04 // On (device determines speed) FanModeAuto FanMode = 0x05 // Automatic mode FanModeSmart FanMode = 0x06 // Smart mode )
type FanModeSequence ¶
type FanModeSequence uint8
FanModeSequence represents the sequence of fan modes available.
const ( FanSequenceLowMedHigh FanModeSequence = 0x00 // Low, Medium, High FanSequenceLowHigh FanModeSequence = 0x01 // Low, High FanSequenceLowMedHighAuto FanModeSequence = 0x02 // Low, Medium, High, Auto FanSequenceLowHighAuto FanModeSequence = 0x03 // Low, High, Auto FanSequenceOnAuto FanModeSequence = 0x04 // On, Auto )
func (FanModeSequence) String ¶
func (f FanModeSequence) String() string
String returns human-readable fan mode sequence name.
type Frame ¶
type Frame struct {
Control FrameControl
ManufCode uint16 // Only present if ManufacturerSpecific
TransSeqNum uint8
CommandID uint8
Payload []byte
}
Frame represents a ZCL frame.
func BuildClusterCommand ¶
BuildClusterCommand creates a cluster-specific command frame.
func BuildConfigureReportingRequest ¶
func BuildConfigureReportingRequest(seqNum uint8, configs []ReportingConfig) (*Frame, error)
BuildConfigureReportingRequest creates a configure reporting request frame. For most use cases, use direction=0x00 (device reports to coordinator). reportableChange should match the data type (e.g., int16 for temperature).
func BuildReadAttributesRequest ¶
func BuildReadAttributesRequest(seqNum uint8, attributeIDs ...AttributeID) *Frame
BuildReadAttributesRequest creates a read attributes request frame.
func BuildReadReportingConfigRequest ¶
func BuildReadReportingConfigRequest(seqNum uint8, records []ReadReportingConfigRecord) *Frame
BuildReadReportingConfigRequest creates a read reporting configuration request frame. This queries the device for its current reporting configuration for the specified attributes.
func BuildWriteAttributesRequest ¶
func BuildWriteAttributesRequest(seqNum uint8, values map[AttributeID]AttributeValue) (*Frame, error)
BuildWriteAttributesRequest creates a write attributes request. values is a map of attribute ID to AttributeValue pairs. Returns an error if any attribute value cannot be encoded.
func ParseFrame ¶
ParseFrame decodes a ZCL frame from bytes.
type FrameControl ¶
type FrameControl struct {
FrameType FrameType
ManufacturerSpecific bool
Direction Direction
DisableDefaultResponse bool
}
FrameControl defines the ZCL frame control byte.
func ParseFrameControl ¶
func ParseFrameControl(b uint8) FrameControl
ParseFrameControl decodes frame control from a byte.
func (FrameControl) ToByte ¶
func (fc FrameControl) ToByte() uint8
ToByte encodes frame control to a byte.
type Gamut ¶
Gamut defines a color gamut triangle using three primary color points. Each gamut represents the range of colors a specific device can produce.
type GlobalCommand ¶
type GlobalCommand uint8
GlobalCommand defines profile-wide ZCL commands.
const ( CmdReadAttributes GlobalCommand = 0x00 CmdReadAttributesResponse GlobalCommand = 0x01 CmdWriteAttributes GlobalCommand = 0x02 CmdWriteAttributesUndivided GlobalCommand = 0x03 CmdWriteAttributesResponse GlobalCommand = 0x04 CmdWriteAttributesNoResp GlobalCommand = 0x05 CmdConfigureReporting GlobalCommand = 0x06 CmdConfigureReportingResp GlobalCommand = 0x07 CmdReadReportingConfig GlobalCommand = 0x08 CmdReadReportingConfigResp GlobalCommand = 0x09 CmdReportAttributes GlobalCommand = 0x0A CmdDefaultResponse GlobalCommand = 0x0B CmdDiscoverAttributes GlobalCommand = 0x0C CmdDiscoverAttributesResp GlobalCommand = 0x0D // Extended discovery commands (ZCL 6+) CmdDiscoverCommandsReceived GlobalCommand = 0x11 CmdDiscoverCommandsReceivedResp GlobalCommand = 0x12 CmdDiscoverCommandsGenerated GlobalCommand = 0x13 CmdDiscoverCommandsGeneratedResp GlobalCommand = 0x14 CmdDiscoverAttributesExtended GlobalCommand = 0x15 CmdDiscoverAttributesExtendedResp GlobalCommand = 0x16 )
type IASZoneType ¶
type IASZoneType uint16
IASZoneType represents the type of IAS Zone device.
const ( IASZoneTypeStandardCIE IASZoneType = 0x0000 // Standard CIE IASZoneTypeMotionSensor IASZoneType = 0x000D // Motion sensor IASZoneTypeContactSwitch IASZoneType = 0x0015 // Contact switch IASZoneTypeDoorWindow IASZoneType = 0x0016 // Door/Window sensor (same as contact) IASZoneTypeFireSensor IASZoneType = 0x0028 // Fire sensor IASZoneTypeWaterSensor IASZoneType = 0x002A // Water sensor IASZoneTypeCOSensor IASZoneType = 0x002B // Carbon monoxide sensor IASZoneTypePersonalEmergency IASZoneType = 0x002C // Personal emergency device IASZoneTypeVibrationMovement IASZoneType = 0x002D // Vibration/Movement sensor IASZoneTypeRemoteControl IASZoneType = 0x010F // Remote control IASZoneTypeKeyFob IASZoneType = 0x0115 // Key fob IASZoneTypeKeypad IASZoneType = 0x021D // Keypad IASZoneTypeStandardWarning IASZoneType = 0x0225 // Standard warning device IASZoneTypeGlassBreak IASZoneType = 0x0226 // Glass break sensor IASZoneTypeSecurityRepeater IASZoneType = 0x0229 // Security repeater IASZoneTypeInvalidZone IASZoneType = 0xFFFF // Invalid zone type )
func (IASZoneType) String ¶
func (z IASZoneType) String() string
String returns human-readable zone type name.
type IOReliability ¶
type IOReliability uint8
IOReliability represents the reliability status of input/output values. This enum is used by Binary Input, Analog Input, and other I/O clusters.
const ( IOReliabilityNoFaultDetected IOReliability = 0x00 // No fault detected IOReliabilityNoSensor IOReliability = 0x01 // No sensor present IOReliabilityOverRange IOReliability = 0x02 // Value over range IOReliabilityUnderRange IOReliability = 0x03 // Value under range IOReliabilityOpenLoop IOReliability = 0x04 // Open loop detected IOReliabilityShortedLoop IOReliability = 0x05 // Shorted loop detected IOReliabilityNoOutput IOReliability = 0x06 // No output IOReliabilityUnreliableOther IOReliability = 0x07 // Unreliable other reason )
func (IOReliability) String ¶
func (r IOReliability) String() string
String returns human-readable reliability name.
type OTAUpgradeStatus ¶
type OTAUpgradeStatus uint8
OTAUpgradeStatus represents the current status of an OTA upgrade.
const ( OTAStatusNormal OTAUpgradeStatus = 0x00 // Normal operation OTAStatusDownloadInProgress OTAUpgradeStatus = 0x01 // Download in progress OTAStatusDownloadComplete OTAUpgradeStatus = 0x02 // Download complete OTAStatusWaitingToUpgrade OTAUpgradeStatus = 0x03 // Waiting to upgrade OTAStatusCountDown OTAUpgradeStatus = 0x04 // Count down to upgrade OTAStatusWaitForMore OTAUpgradeStatus = 0x05 // Wait for more data )
func (OTAUpgradeStatus) String ¶
func (o OTAUpgradeStatus) String() string
String returns human-readable OTA upgrade status name.
type PowerSource ¶
type PowerSource uint8
PowerSource values for Basic cluster.
const ( PowerSourceUnknown PowerSource = 0x00 PowerSourceMains PowerSource = 0x01 PowerSourceBattery PowerSource = 0x03 PowerSourceDC PowerSource = 0x04 PowerSourceEmergencyMains PowerSource = 0x05 PowerSourceEmergencyDC PowerSource = 0x06 )
func (PowerSource) String ¶
func (p PowerSource) String() string
String returns human-readable power source name.
type ReadAttributeResult ¶
type ReadAttributeResult struct {
AttributeID AttributeID
Status Status
DataType DataType
Value interface{}
}
ReadAttributeResult represents a single attribute in a read response.
func ParseReadAttributesResponse ¶
func ParseReadAttributesResponse(payload []byte) ([]ReadAttributeResult, error)
ParseReadAttributesResponse parses a read attributes response. Format: [attrID:2][status:1][dataType:1 if success][value if success]...
type ReadReportingConfigRecord ¶
type ReadReportingConfigRecord struct {
Direction uint8 // 0x00 = reported (device sends reports), 0x01 = received
AttributeID AttributeID
}
ReadReportingConfigRecord specifies which attribute's reporting config to read.
type ReportAttributeResult ¶
type ReportAttributeResult struct {
AttributeID AttributeID
DataType DataType
Value interface{}
}
ReportAttributeResult represents a single attribute in a report.
func ParseReportAttributesPayload ¶
func ParseReportAttributesPayload(payload []byte) ([]ReportAttributeResult, error)
ParseReportAttributesPayload parses a report attributes payload. Format: [attrID:2][dataType:1][value]... Unlike read response, reports don't include status (implicitly success).
type ReportingConfig ¶
type ReportingConfig struct {
Direction uint8 // 0x00 = reported (send reports), 0x01 = received (receive reports)
AttributeID AttributeID
DataType DataType // Only for direction 0x00
MinInterval uint16 // Minimum reporting interval in seconds (only for direction 0x00)
MaxInterval uint16 // Maximum reporting interval in seconds (only for direction 0x00)
ReportableChange interface{} // Reportable change value (only for analog types, direction 0x00)
}
ReportingConfig represents the configuration for a single attribute reporting.
type ReportingConfigRecord ¶
type ReportingConfigRecord struct {
Status Status // 0x00 = success
Direction uint8 // 0x00 = reported, 0x01 = received
AttributeID AttributeID
DataType DataType // Only present if Direction == 0x00 and Status == 0x00
MinInterval uint16 // Only present if Direction == 0x00 and Status == 0x00
MaxInterval uint16 // Only present if Direction == 0x00 and Status == 0x00
ReportableChange interface{} // Only present for analog types, Direction == 0x00 and Status == 0x00
TimeoutPeriod uint16 // Only present if Direction == 0x01 and Status == 0x00
}
ReportingConfigRecord represents a single attribute's reporting configuration from the response.
func ParseReadReportingConfigResponse ¶
func ParseReadReportingConfigResponse(payload []byte) ([]ReportingConfigRecord, error)
ParseReadReportingConfigResponse parses a read reporting configuration response. Format varies based on status and direction.
type SirenLevel ¶
type SirenLevel uint8
SirenLevel represents the loudness level of the siren.
const ( SirenLevelLow SirenLevel = 0x00 // Low volume SirenLevelMedium SirenLevel = 0x01 // Medium volume SirenLevelHigh SirenLevel = 0x02 // High volume SirenLevelVeryHigh SirenLevel = 0x03 // Very high volume )
func (SirenLevel) String ¶
func (s SirenLevel) String() string
String returns human-readable siren level name.
type StartUpOnOff ¶
type StartUpOnOff uint8
StartUpOnOff defines the startup behavior for OnOff cluster devices.
const ( StartUpOnOffOff StartUpOnOff = 0x00 // Turn off when powered on StartUpOnOffOn StartUpOnOff = 0x01 // Turn on when powered on StartUpOnOffToggle StartUpOnOff = 0x02 // Toggle state when powered on StartUpOnOffPrevious StartUpOnOff = 0xFF // Restore previous state when powered on )
func (StartUpOnOff) String ¶
func (s StartUpOnOff) String() string
String returns human-readable startup behavior name.
type Status ¶ added in v0.2.0
type Status uint8
Status defines ZCL status codes.
const ( StatusSuccess Status = 0x00 StatusFailure Status = 0x01 StatusNotAuthorized Status = 0x7E StatusReservedFieldNotZero Status = 0x7F StatusMalformedCommand Status = 0x80 StatusUnsupClusterCommand Status = 0x81 StatusUnsupGeneralCommand Status = 0x82 StatusUnsupManufClusterCmd Status = 0x83 StatusUnsupManufGeneralCmd Status = 0x84 StatusInvalidField Status = 0x85 StatusUnsupportedAttribute Status = 0x86 StatusInvalidValue Status = 0x87 StatusReadOnly Status = 0x88 StatusInsufficientSpace Status = 0x89 StatusDuplicateExists Status = 0x8A StatusNotFound Status = 0x8B StatusUnreportableAttribute Status = 0x8C StatusInvalidDataType Status = 0x8D StatusInvalidSelector Status = 0x8E StatusWriteOnly Status = 0x8F StatusInconsistentStartupState Status = 0x90 StatusDefinedOutOfBand Status = 0x91 StatusInconsistent Status = 0x92 StatusActionDenied Status = 0x93 StatusTimeout Status = 0x94 StatusAbort Status = 0x95 StatusInvalidImage Status = 0x96 StatusWaitForData Status = 0x97 StatusNoImageAvailable Status = 0x98 StatusRequireMoreImage Status = 0x99 StatusNotificationPending Status = 0x9A StatusHardwareFailure Status = 0xC0 StatusSoftwareFailure Status = 0xC1 StatusCalibrationError Status = 0xC2 StatusUnsupportedCluster Status = 0xC3 )
ZCL Status codes (complete set per ZCL 8 spec)
type StepMode ¶
type StepMode uint8
StepMode defines the direction for Step commands (same as MoveMode).
type StrobeLevel ¶
type StrobeLevel uint8
StrobeLevel represents the brightness level of the strobe light.
const ( StrobeLevelLow StrobeLevel = 0x00 // Low brightness StrobeLevelMedium StrobeLevel = 0x01 // Medium brightness StrobeLevelHigh StrobeLevel = 0x02 // High brightness StrobeLevelVeryHigh StrobeLevel = 0x03 // Very high brightness )
func (StrobeLevel) String ¶
func (s StrobeLevel) String() string
String returns human-readable strobe level name.
type StructField ¶
type StructField struct {
Type DataType
Value interface{}
}
StructField represents a single field in a ZCL struct.
type StructValue ¶
type StructValue struct {
Fields []StructField
}
StructValue represents a ZCL struct with typed fields.
type ThermostatSystemMode ¶
type ThermostatSystemMode uint8
ThermostatSystemMode represents the operating mode of a thermostat.
const ( ThermostatModeOff ThermostatSystemMode = 0x00 // Thermostat is off ThermostatModeAuto ThermostatSystemMode = 0x01 // Auto mode (heat/cool as needed) ThermostatModeCool ThermostatSystemMode = 0x03 // Cooling mode ThermostatModeHeat ThermostatSystemMode = 0x04 // Heating mode ThermostatModeEmergencyHeat ThermostatSystemMode = 0x05 // Emergency heating mode ThermostatModePrecooling ThermostatSystemMode = 0x06 // Precooling mode ThermostatModeFanOnly ThermostatSystemMode = 0x07 // Fan only mode ThermostatModeDry ThermostatSystemMode = 0x08 // Dry/dehumidify mode ThermostatModeSleep ThermostatSystemMode = 0x09 // Sleep mode )
func (ThermostatSystemMode) String ¶
func (m ThermostatSystemMode) String() string
String returns human-readable thermostat system mode name.
type WarningMode ¶
type WarningMode uint8
WarningMode represents the type of warning for IASWD devices.
const ( WarningModeStop WarningMode = 0x00 // Stop warning WarningModeBurglar WarningMode = 0x01 // Burglar alarm WarningModeFire WarningMode = 0x02 // Fire alarm WarningModeEmergency WarningMode = 0x03 // Emergency alarm WarningModePolicePanic WarningMode = 0x04 // Police panic WarningModeFirePanic WarningMode = 0x05 // Fire panic WarningModeEmergencyPanic WarningMode = 0x06 // Emergency panic )
func (WarningMode) String ¶
func (w WarningMode) String() string
String returns human-readable warning mode name.
type WindowCoveringType ¶
type WindowCoveringType uint8
WindowCoveringType defines the type of window covering device.
const ( WindowCoveringTypeRollerShade WindowCoveringType = 0x00 WindowCoveringTypeRollerShade2Motor WindowCoveringType = 0x01 WindowCoveringTypeRollerShadeExterior WindowCoveringType = 0x02 WindowCoveringTypeRollerShadeExterior2Motor WindowCoveringType = 0x03 WindowCoveringTypeDrapery WindowCoveringType = 0x04 WindowCoveringTypeAwning WindowCoveringType = 0x05 WindowCoveringTypeShutter WindowCoveringType = 0x06 WindowCoveringTypeTiltBlindTiltOnly WindowCoveringType = 0x07 WindowCoveringTypeTiltBlindLiftAndTilt WindowCoveringType = 0x08 WindowCoveringTypeProjectorScreen WindowCoveringType = 0x09 WindowCoveringTypeUnknown WindowCoveringType = 0xFF )
func (WindowCoveringType) String ¶
func (w WindowCoveringType) String() string
String returns human-readable window covering type name.
type WriteAttributeResult ¶
type WriteAttributeResult struct {
Status Status
AttributeID AttributeID // Only present if status != 0
}
WriteAttributeResult represents a write result in a write response.
func ParseWriteAttributesResponse ¶
func ParseWriteAttributesResponse(payload []byte) ([]WriteAttributeResult, error)
ParseWriteAttributesResponse parses a write attributes response. Format: [status:1][attrID:2 if status != 0]...