hanpa

blixt trådfri

Nov 6th, 2017
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. tradfri/blixt.py & tradfri/blixt2.py & tradfri/blixt3.py &
  2.  
  3. blixt.py:
  4.  
  5. #!/usr/bin/env python3
  6. import sys
  7. import time
  8. from credentials import ip, key
  9. from pytradfri import Gateway
  10. from pytradfri.api.libcoap_api import api_factory
  11.  
  12. api = api_factory(ip, key)
  13. gateway = Gateway()
  14. devices_command = gateway.get_devices()
  15. devices_commands = api(devices_command)
  16. devices = api(*devices_commands)
  17. lights = [dev for dev in devices if dev.has_light_control]
  18.  
  19.  
  20. for l in lights:
  21. if (l.name == 'm1b'):
  22. light=l
  23.  
  24. f=7
  25. p=1/f
  26. time.sleep (5.0)
  27. for i in range (0,181):
  28. dim_command = light.light_control.set_dimmer(254)
  29. api(dim_command)
  30. time.sleep (p/2*0.25)
  31. dim_command = light.light_control.set_dimmer(0)
  32. api(dim_command)
  33. time.sleep (p/2*0.75)
  34.  
  35. dim_command = light.light_control.set_dimmer(254)
  36. api(dim_command)
  37.  
  38. blixt2.py:
  39. #!/usr/bin/env python3
  40. import sys
  41. import time
  42. from credentials import ip, key
  43. from pytradfri import Gateway
  44. from pytradfri.api.libcoap_api import api_factory
  45.  
  46. api = api_factory(ip, key)
  47. gateway = Gateway()
  48. devices_command = gateway.get_devices()
  49. devices_commands = api(devices_command)
  50. devices = api(*devices_commands)
  51. lights = [dev for dev in devices if dev.has_light_control]
  52.  
  53.  
  54. for l in lights:
  55. if (l.name == 'm1a'):
  56. light=l
  57.  
  58. f=3
  59. p=1/f
  60. time.sleep (5.0)
  61. for i in range (0,95):
  62. dim_command = light.light_control.set_dimmer(254)
  63. api(dim_command)
  64. time.sleep (p/2*0.25)
  65. dim_command = light.light_control.set_dimmer(0)
  66. api(dim_command)
  67. time.sleep (p/2*0.75)
  68.  
  69. dim_command = light.light_control.set_dimmer(254)
  70. api(dim_command)
  71.  
  72. blixt3.py:
  73. #!/usr/bin/env python3
  74. import sys
  75. import time
  76. from credentials import ip, key
  77. from pytradfri import Gateway
  78. from pytradfri.api.libcoap_api import api_factory
  79.  
  80. api = api_factory(ip, key)
  81. gateway = Gateway()
  82. devices_command = gateway.get_devices()
  83. devices_commands = api(devices_command)
  84. devices = api(*devices_commands)
  85. lights = [dev for dev in devices if dev.has_light_control]
  86.  
  87.  
  88. for l in lights:
  89. if (l.name == 'm1c'):
  90. light=l
  91.  
  92. f=11
  93. p=1/f
  94. time.sleep (5.0)
  95. for i in range (0,120):
  96. dim_command = light.light_control.set_dimmer(254)
  97. api(dim_command)
  98. time.sleep (p/2*0.25)
  99. dim_command = light.light_control.set_dimmer(0)
  100. api(dim_command)
  101. time.sleep (p/2*0.75)
  102.  
  103. dim_command = light.light_control.set_dimmer(254)
  104. api(dim_command)
Advertisement
Add Comment
Please, Sign In to add comment