XBOS Docs
Search…
Plug
Interface: i.xbos.plug
Description: Standard XBOS plug interface
PONUM: 2.1.1.2

Properties

Name
Type
Description
Units
Required
cumulative
double
an aggregation from some epoch of true power (Kilo Watt Hours)
kWh
false
current
double
current through the plug (Amperes)
A
false
power
double
true power through the plug (Kilo Watts)
W
false
state
boolean
Whether or not the plug is enabled
on/off
true
time
integer
nanoseconds since the Unix epoch
ns
false
voltage
double
voltage at the plug (Volts)
V
false

Signals

    info:
      state
      time
      voltage
      current
      power
      cumulative

Slots

    state:
      state

Interfacing in Go

1
package main
2
3
import (
4
"fmt"
5
bw2 "gopkg.in/immesys/bw2bind.v5"
6
)
7
8
func main() {
9
client := bw2.ConnectOrExit("")
10
client.OverrideAutoChainTo(true)
11
client.SetEntityFromEnvironOrExit()
12
13
base_uri := "Plug uri goes here ending in i.xbos.plug"
14
15
// subscribe
16
type signal struct {
17
State bool `msgpack:"state"`
18
Time int64 `msgpack:"time"`
19
Voltage float64 `msgpack:"voltage"`
20
Current float64 `msgpack:"current"`
21
Power float64 `msgpack:"power"`
22
Cumulative float64 `msgpack:"cumulative"`
23
}
24
c, err := client.Subscribe(&bw2.SubscribeParams{
25
URI: base_uri + "/signal/info",
26
})
27
if err != nil {
28
panic(err)
29
}
30
31
for msg := range c {
32
var current_state signal
33
po := msg.GetOnePODF("2.1.1.2/32")
34
err := po.(bw2.MsgPackPayloadObject).ValueInto(&current_state)
35
if err != nil {
36
fmt.Println(err)
37
} else {
38
fmt.Println(current_state)
39
}
40
}
41
}
Copied!

Interfacing in Python

1
import time
2
import msgpack
3
4
from bw2python.bwtypes import PayloadObject
5
from bw2python.client import Client
6
7
bw_client = Client()
8
bw_client.setEntityFromEnviron()
9
bw_client.overrideAutoChainTo(True)
10
11
def onMessage(bw_message):
12
for po in bw_message.payload_objects:
13
if po.type_dotted == (2,1,1,2):
14
print msgpack.unpackb(po.content)
15
16
bw_client.subscribe("Plug uri ending in i.xbos.plug/signal/info", onMessage)
17
18
print "Subscribing. Ctrl-C to quit."
19
while True:
20
time.sleep(10000)
Copied!
Last modified 1yr ago