XBOS Docs
Search…
Light
Interface: i.xbos.light
Description: Standard XBOS lighting interface
PONUM: 2.1.1.1

Properties

Name
Type
Description
Units
Required
brightness
integer
Current brightness of the light; 100 is maximum brightness
percentage
false
state
boolean
Whether or not the light is on
on/off
true
time
integer
nanoseconds since the Unix epoch
ns
false

Signals

    info:
      state
      brightness
      time

Slots

    state:
      state
      brightness

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