XBOS Docs
Search…
Meter
Interface: i.xbos.meter
Description: Standard XBOS electric meter interface
PONUM: 2.1.1.4

Properties

Name
Type
Description
Units
Required
apparent_power
double
Current apparent power reading
kVA
false
power
double
Current measured power
kW
true
time
integer
nanoseconds since the Unix epoch
ns
true
voltage
double
Current voltage reading
V
false

Signals

    info:
      power
      voltage
      apparent_power
      time

Slots

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 := "Meter uri goes here ending in i.xbos.meter"
14
15
// subscribe
16
type signal struct {
17
Power float64 `msgpack:"power"`
18
Voltage float64 `msgpack:"voltage"`
19
Apparent_power float64 `msgpack:"apparent_power"`
20
Time int64 `msgpack:"time"`
21
}
22
c, err := client.Subscribe(&bw2.SubscribeParams{
23
URI: base_uri + "/signal/info",
24
})
25
if err != nil {
26
panic(err)
27
}
28
29
for msg := range c {
30
var current_state signal
31
po := msg.GetOnePODF("2.1.1.4/32")
32
err := po.(bw2.MsgPackPayloadObject).ValueInto(&current_state)
33
if err != nil {
34
fmt.Println(err)
35
} else {
36
fmt.Println(current_state)
37
}
38
}
39
}
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,4):
14
print msgpack.unpackb(po.content)
15
16
bw_client.subscribe("Meter uri ending in i.xbos.meter/signal/info", onMessage)
17
18
print "Subscribing. Ctrl-C to quit."
19
while True:
20
time.sleep(10000)
Copied!
Last modified 1yr ago