Documentation ¶
Overview ¶
Package eds with EDS OWServer API methods
Index ¶
Constants ¶
This section is empty.
Variables ¶
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
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
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
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 ¶
Types ¶
type EdsAPI ¶
type EdsAPI struct {
// contains filtered or unexported fields
}
EdsAPI EDS device API properties and methods
func NewEdsAPI ¶
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.
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 ¶
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 ¶
UnmarshalXML parse xml