XBOS Docs
Search…
Weather Station
Interface: i.xbos.weather_station
Description: XBOS weather station
PONUM: 2.1.1.8

Properties

Name
Type
Description
Units
Required
relative_humidity
double
Current relative humidity
percent
false
temperature
double
Current temperature reading
Fahrenheit
true
time
integer
nanoseconds since the Unix epoch
ns
false
wind_speed
double
Current wind speed in miles per hour
mph
false

Signals

    info:
      temperature
      relative_humidity
      wind_speed
      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 := "Weather Station uri goes here ending in i.xbos.weather_station"
14
15
// subscribe
16
type signal struct {
17
Temperature float64 `msgpack:"temperature"`
18
Relative_humidity float64 `msgpack:"relative_humidity"`
19
Wind_speed float64 `msgpack:"wind_speed"`
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.8/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,8):
14
print msgpack.unpackb(po.content)
15
16
bw_client.subscribe("Weather Station uri ending in i.xbos.weather_station/signal/info", onMessage)
17
18
print "Subscribing. Ctrl-C to quit."
19
while True:
20
time.sleep(10000)
Copied!
Last modified 1yr ago