Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. // Testing of the getSysInfo command for the LB1xx light bulb
  2.  
  3. /*
  4. ************* Notes *************
  5. This script uses the upreviously developed, unmodified HS100 API. It was completed as an exercise to fully understand how the system is controlled.
  6.  
  7. Issue: The program sometimes fails when the light is OFF. Works when ON and right after turning off.
  8. */
  9.  
  10. const Hs100Api = require('hs100-api')
  11. const client = new Hs100Api.Client()
  12.  
  13. // Define the bulb, using the HS100 API
  14. const BRLight = client.getPlug({host: '192.168.0.131'})
  15.  
  16. // Get the System Information and parsing into Attributes
  17. var j = Promise.resolve(BRLight.getSysInfo())
  18. j.then(function(data){
  19. var sysinfo = (data);
  20. sw_ver = sysinfo.sw_ver;
  21. hw_ver = sysinfo.hw_ver;
  22. model = sysinfo.model;
  23. description = sysinfo.description; //Description of bulb
  24. alias = sysinfo.alias; // local name for bulb
  25. mic_type = sysinfo.mic_type
  26. dev_state = sysinfo.dev_state
  27. mic_mac = sysinfo.mic_mac //MAC of bulb
  28. devId = sysinfo.devId
  29. oemId = sysinfo.oemId
  30. hwId = sysinfo.hwId
  31. disco_ver = sysinfo.disco_ver
  32. prot_name = sysinfo.ctrl_protocols.name
  33. prot_version = sysinfo.ctrl_protocols.version
  34. on_off = sysinfo.light_state.on_off
  35. mode = sysinfo.light_state.mode
  36. brightness = sysinfo.light_state.brightness
  37. color_temp = sysinfo.light_state.color_temp
  38. hue = sysinfo.light_state.hue
  39. saturation = sysinfo.light_state.saturation
  40.  
  41. // Display the full set of attributes collected onto the console
  42. console.log("**** LB1XX Bulb Information ")
  43. console.log(" Alias: " + alias)
  44. console.log(" Model: " + model)
  45. console.log(" Description: " + description)
  46. console.log(" Device Type: " + mic_type)
  47. console.log(" Device State: " + dev_state)
  48. console.log("Device MAC Adress: " + mic_mac)
  49. console.log(" SW Version: " + sw_ver)
  50. console.log(" HW Version: " + hw_ver)
  51. console.log(" ")
  52. console.log(" Currrent Bulb State ")
  53. console.log(" Light On/off: " + on_off)
  54. console.log(" Bulb Mode: " + mode)
  55. console.log(" Bulb Brightness: " + brightness)
  56. console.log("Color_Temperature: " + color_temp)
  57. console.log(" Color Hue: "+ hue)
  58. console.log(" Color Saturation: " + saturation)
  59. console.log(" ")
  60. console.log(" LB1XX Bulb Other Information ****")
  61. // A repository for additional attributes as I decide to capture them
  62. console.log(" Device ID: " + devId)
  63. console.log(" OEM ID: " + oemId)
  64. console.log(" HW ID: " + hwId)
  65. console.log(" Disco Version: " + disco_ver)
  66. console.log("Control Protocol: " + prot_name +" Ver "+ prot_version)
  67. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement