device.py 332 B

123456789101112131415161718192021222324
  1. from machine import Pin
  2. # 设备类型
  3. model = '01001'
  4. # 版本
  5. version = 1.0
  6. led = Pin(4, Pin.OUT)
  7. def command(com):
  8. """
  9. 执行命令
  10. """
  11. if com == 'on':
  12. led.on()
  13. elif com == 'off':
  14. led.off()
  15. def status():
  16. """
  17. 上报状态
  18. """
  19. return {
  20. 'status': led.value() == 1
  21. }