mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2024-11-15 17:10:46 +00:00
36 lines
778 B
Python
36 lines
778 B
Python
import logging
|
|
|
|
import vban_cmd
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
|
|
class App:
|
|
def __init__(self, vban):
|
|
self.vban = vban
|
|
# register your app as event observer
|
|
self.vban.observer.add(self)
|
|
|
|
# define an 'on_update' callback function to receive event updates
|
|
def on_update(self, event):
|
|
if event == "pdirty":
|
|
print("pdirty!")
|
|
elif event == "ldirty":
|
|
for bus in self.vban.bus:
|
|
if bus.levels.isdirty:
|
|
print(bus, bus.levels.all)
|
|
|
|
|
|
def main():
|
|
KIND_ID = "banana"
|
|
|
|
with vban_cmd.api(KIND_ID, pdirty=True, ldirty=True) as vban:
|
|
App(vban)
|
|
|
|
while cmd := input("Press <Enter> to exit\n"):
|
|
pass
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|