eds

package
v0.0.0-...-147f0cf Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package eds with EDS OWServer API methods

Index

Constants

This section is empty.

Variables

View Source
var ActuatorTypeVocab = map[string]struct {
	ActuatorType string // sensor type from vocabulary
	Title        string
	DataType     string
}{

	"Relay": {ActuatorType: vocab.VocabRelay, Title: "Relay", DataType: vocab.WoTDataTypeBool},
}

ActuatorTypeVocab maps OWServer names to IoT vocabulary

View Source
var AttrVocab = map[string]string{
	"MACAddress": vocab.VocabMAC,

	"DeviceName": vocab.VocabName,
	"HostName":   vocab.VocabHostname,
	"Version":    vocab.VocabSoftwareVersion,

	"BarometricPressureHg":                           "",
	"BarometricPressureHgHighAlarmState":             "",
	"BarometricPressureHgHighAlarmValue":             "",
	"BarometricPressureHgHighConditionalSearchState": "",
	"BarometricPressureHgLowAlarmState":              "",
	"BarometricPressureHgLowAlarmValue":              "",
	"BarometricPressureHgLowConditionalSearchState":  "",
	"BarometricPressureMbHighConditionalSearchState": "",
	"BarometricPressureMbLowConditionalSearchState":  "",
	"Counter1":                              "",
	"Counter2":                              "",
	"DateTime":                              "",
	"DewPointHighConditionalSearchState":    "",
	"DewPointLowConditionalSearchState":     "",
	"HeatIndexHighConditionalSearchState":   "",
	"HeatIndexLowConditionalSearchState":    "",
	"Humidex":                               "",
	"HumidexHighAlarmState":                 "",
	"HumidexHighConditionalSearchState":     "",
	"HumidexLowAlarmState":                  "",
	"HumidexLowConditionalSearchState":      "",
	"HumidityHighConditionalSearchState":    "",
	"HumidityLowConditionalSearchState":     "",
	"LightHighConditionalSearchState":       "",
	"LightLowConditionalSearchState":        "",
	"TemperatureHighConditionalSearchState": "",
	"TemperatureLowConditionalSearchState":  "",
	"PollCount":                             "",
	"PrimaryValue":                          "",
	"RawData":                               "",
}

AttrVocab maps OWServer attribute names to IoT vocabulary

View Source
var SensorTypeVocab = map[string]struct {
	sensorType string // sensor type from vocabulary
	name       string
	dataType   string
	decimals   int // number of decimals accuracy for this value
}{

	"BarometricPressureMb":               {/* contains filtered or unexported fields */},
	"BarometricPressureMbHighAlarmState": {/* contains filtered or unexported fields */},
	"BarometricPressureMbLowAlarmState":  {/* contains filtered or unexported fields */},
	"DewPoint":                           {/* contains filtered or unexported fields */},
	"Health":                             {/* contains filtered or unexported fields */},
	"HeatIndex":                          {/* contains filtered or unexported fields */},
	"Humidity":                           {/* contains filtered or unexported fields */},
	"HumidityHighAlarmState":             {/* contains filtered or unexported fields */},
	"HumidityLowAlarmState":              {/* contains filtered or unexported fields */},
	"Light":                              {/* contains filtered or unexported fields */},
	"RelayState":                         {/* contains filtered or unexported fields */},
	"Temperature":                        {/* contains filtered or unexported fields */},
	"TemperatureHighAlarmState":          {/* contains filtered or unexported fields */},
	"TemperatureLowAlarmState":           {/* contains filtered or unexported fields */},
}

SensorTypeVocab maps OWServer sensor names to IoT vocabulary

View Source
var UnitNameVocab = map[string]string{
	"PercentRelativeHumidity": vocab.UnitNamePercent,
	"Millibars":               vocab.UnitNameMillibar,
	"Centigrade":              vocab.UnitNameCelcius,
	"Fahrenheit":              vocab.UnitNameFahrenheit,
	"InchesOfMercury":         vocab.UnitNameMercury,
	"Lux":                     vocab.UnitNameLux,
	"//":                      vocab.UnitNameCount,
	"Volt":                    vocab.UnitNameVolt,
}

UnitNameVocab maps OWServer unit names to IoT vocabulary

Functions

func Discover

func Discover(timeoutSec int) (addr string, err error)

Discover any EDS OWServer ENet-2 on the local network for 3 seconds This uses a UDP Broadcast on port 30303 as stated in the manual If found, this sets the service address for further use Returns the address or an error if not found

Types

type EdsAPI

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

EdsAPI EDS device API properties and methods

func NewEdsAPI

func NewEdsAPI(address string, loginName string, password string) *EdsAPI

NewEdsAPI creates a new NewEdsAPI instance

address is optional to override the discovery
loginName if needed, "" if not needed
password if needed, "" if not needed

func (*EdsAPI) PollNodes

func (edsAPI *EdsAPI) PollNodes() (nodeList []*OneWireNode, err error)

PollNodes polls the OWServer gateway for nodes and property values Returns a list of nodes and a map of device/node ID's containing a map of property name:value pairs.

func (*EdsAPI) WriteData

func (edsAPI *EdsAPI) WriteData(romID string, variable string, value string) error

WriteData writes a value to a variable this posts a request to devices.html?rom={romID}&variable={variable}&value={value}

type OneWireAttr

type OneWireAttr struct {
	ID         string // attribute raw instance ID
	Name       string // attribute Title for humans
	VocabType  string // attribute type from vocabulary, if any, eg 'temperature', ...
	Unit       string
	Writable   bool
	Value      string
	IsActuator bool
	IsSensor   bool   // sensors emit events on change
	DataType   string // vocab data type, "string", "number", "boolean", ""
}

OneWireAttr with info on each node attribute, property, event or action

type OneWireNode

type OneWireNode struct {
	DeviceType string
	// ThingID     string
	NodeID      string // ROM ID
	Name        string
	Description string
	Attr        map[string]OneWireAttr // attribute by ID
}

OneWireNode with info on each node

func ParseOneWireNodes

func ParseOneWireNodes(
	xmlNode *XMLNode, latency time.Duration, isRootNode bool) []*OneWireNode

ParseOneWireNodes parses the owserver xml data and returns a list of nodes, including the owserver gateway, and their parameters. This also converts sensor values to a proper decimals. Eg temperature isn't 4 digits but 1.

xmlNode is the node to parse, its attribute and possibly subnodes
latency to add to the root node (gateway device)
isRootNode is set for the first node, eg the gateway itself

type XMLNode

type XMLNode struct {
	XMLName xml.Name
	Attrs   []xml.Attr `xml:"-"`
	Content []byte     `xml:",innerxml"`
	Nodes   []XMLNode  `xml:",any"`
	// Possible attributes for subnodes, depending on the property name
	Description string `xml:"Description,attr"`
	Writable    string `xml:"Writable,attr"`
	Units       string `xml:"Units,attr"`
}

XMLNode XML parsing node. Pure magic... --- https://stackoverflow.com/questions/30256729/how-to-traverse-through-xml-data-in-golang

func ReadEds

func ReadEds(address, loginName, password string) (rootNode *XMLNode, err error)

ReadEds reads EDS gateway and return the result as an XML node If edsAPI.address starts with file:// then read from file, otherwise from http If no address is configured, one will be auto discovered the first time.

func (*XMLNode) UnmarshalXML

func (n *XMLNode) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML parse xml

Jump to

Keyboard shortcuts

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