device.py 308 B

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