xpl

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPacket = errors.New("invalid xpl packet")
View Source
var HADiscovery = make(map[string][]string)
View Source
var XPLPort = 3865

Functions

func EncodePacket

func EncodePacket(pkt XPLPacket) string

func ProcessMqtt

func ProcessMqtt(client mqtt.Client, msg mqtt.Message, srv *Server)

func ProcessMqttDiscovery added in v0.0.4

func ProcessMqttDiscovery(c mqtt.Client, m mqtt.Message)

func ProcessXPL

func ProcessXPL(pkt *XPLPacket, mqtt *mqtt.Client)

Types

type HAConfig

type HAConfig struct {
	Name                   string   `json:"name,omitempty"`
	UniqueID               string   `json:"unique_id,omitempty"`
	DeviceClass            string   `json:"device_class,omitempty"`
	StateTopic             string   `json:"state_topic,omitempty"`
	Unit                   string   `json:"unit_of_measurement,omitempty"`
	CommandTopic           string   `json:"command_topic,omitempty"`
	BrightnessScale        int      `json:"brightness_scale,omitempty"`
	BrightnessStateTopic   string   `json:"brightness_state_topic,omitempty"`
	BrightnessCommandTopic string   `json:"brightness_command_topic,omitempty"`
	Icon                   string   `json:"icon,omitempty"`
	Device                 HADevice `json:"device,omitempty"`
	SupportedFeatures      []string `json:"supported_features,omitempty"`
	CodeArmRequired        bool     `json:"code_arm_required,omitempty"`
	CodeDisarmRequired     bool     `json:"code_disarm_required,omitempty"`
	CodeTriggerRequired    bool     `json:"code_trigger_required,omitempty"`
}

type HADevice

type HADevice struct {
	Identifiers  []string `json:"identifiers,omitempty"`
	Manifacturer string   `json:"manufacturer"`
	Name         string   `json:"name"`
	Model        string   `json:"model"`
}

type Server

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

func NewServer

func NewServer(port int, client *mqtt.Client) *Server

func (*Server) Run

func (p *Server) Run() error

func (*Server) Stop

func (p *Server) Stop()

func (*Server) Write

func (p *Server) Write(pkt *XPLPacket, addr *net.UDPAddr, nbPackets int) error

type Topic

type Topic struct {
	MessageType string
	DeviceType  string
	DeviceID    string
	DeviceParam string
	Action      string
}

xpl2mqtt/messagetype/device_type/device_id/device_parameter/action ex: xpl2mqtt/sensor.basic/th-1/0x12345678/temp/state

func (*Topic) Parse

func (t *Topic) Parse(topic string) error

func (*Topic) String

func (t *Topic) String() string

func (*Topic) StringO

func (t *Topic) StringO(o Topic) string

type XPLPacket

type XPLPacket struct {
	Type        XPLType
	Hop         int
	Source      string
	Target      string
	MessageType string
	Data        map[string]string
}

func DecodePacket

func DecodePacket(data string) (XPLPacket, error)

type XPLType

type XPLType string
const (
	TypeCmnd XPLType = "xpl-cmnd"
	TypeStat XPLType = "xpl-stat"
	TypeTrig XPLType = "xpl-trig"
)

Jump to

Keyboard shortcuts

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