Merge from old Gitea
This commit is contained in:
47
examples/example.py
Normal file
47
examples/example.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import asyncio
|
||||
import time
|
||||
from esasdk import Machine
|
||||
|
||||
async def main():
|
||||
# Connect to a machine
|
||||
machine = Machine("ws://localhost:5424")
|
||||
await machine.connect()
|
||||
|
||||
# Get machine info
|
||||
name = await machine.name()
|
||||
print(f"Machine Name: {name}")
|
||||
|
||||
# Get machine info
|
||||
info = await machine.info()
|
||||
print(f"Machine Info: {info}")
|
||||
|
||||
# Get machine size
|
||||
size = await machine.size()
|
||||
print(f"Machine Size: {size}")
|
||||
|
||||
# get versions
|
||||
sw = await machine.software_version()
|
||||
print(f"SW: {sw}")
|
||||
sw1 = await machine.software_version(1)
|
||||
print(f"SW1: {sw1}")
|
||||
|
||||
# Get machine volume
|
||||
volume = await machine.volume()
|
||||
print(f"Machine Volume: {volume}")
|
||||
# Set machine volume
|
||||
volume = await machine.volume(50)
|
||||
print(f"Machine Volume: {volume}")
|
||||
|
||||
# Get machine brightness
|
||||
brightness = await machine.brightness()
|
||||
print(f"Machine Brightness: {brightness}")
|
||||
|
||||
# Get machine power
|
||||
power = await machine.power()
|
||||
print(f"Machine Power (Volts): {power}")
|
||||
|
||||
# Close connection
|
||||
await machine.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user