Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Testing of the getSysInfo command for the LB1xx light bulb
- /*
- ************* Notes *************
- This script uses the upreviously developed, unmodified HS100 API. It was completed as an exercise to fully understand how the system is controlled.
- Issue: The program sometimes fails when the light is OFF. Works when ON and right after turning off.
- */
- const Hs100Api = require('hs100-api')
- const client = new Hs100Api.Client()
- // Define the bulb, using the HS100 API
- const BRLight = client.getPlug({host: '192.168.0.131'})
- // Get the System Information and parsing into Attributes
- var j = Promise.resolve(BRLight.getSysInfo())
- j.then(function(data){
- var sysinfo = (data);
- sw_ver = sysinfo.sw_ver;
- hw_ver = sysinfo.hw_ver;
- model = sysinfo.model;
- description = sysinfo.description; //Description of bulb
- alias = sysinfo.alias; // local name for bulb
- mic_type = sysinfo.mic_type
- dev_state = sysinfo.dev_state
- mic_mac = sysinfo.mic_mac //MAC of bulb
- devId = sysinfo.devId
- oemId = sysinfo.oemId
- hwId = sysinfo.hwId
- disco_ver = sysinfo.disco_ver
- prot_name = sysinfo.ctrl_protocols.name
- prot_version = sysinfo.ctrl_protocols.version
- on_off = sysinfo.light_state.on_off
- mode = sysinfo.light_state.mode
- brightness = sysinfo.light_state.brightness
- color_temp = sysinfo.light_state.color_temp
- hue = sysinfo.light_state.hue
- saturation = sysinfo.light_state.saturation
- // Display the full set of attributes collected onto the console
- console.log("**** LB1XX Bulb Information ")
- console.log(" Alias: " + alias)
- console.log(" Model: " + model)
- console.log(" Description: " + description)
- console.log(" Device Type: " + mic_type)
- console.log(" Device State: " + dev_state)
- console.log("Device MAC Adress: " + mic_mac)
- console.log(" SW Version: " + sw_ver)
- console.log(" HW Version: " + hw_ver)
- console.log(" ")
- console.log(" Currrent Bulb State ")
- console.log(" Light On/off: " + on_off)
- console.log(" Bulb Mode: " + mode)
- console.log(" Bulb Brightness: " + brightness)
- console.log("Color_Temperature: " + color_temp)
- console.log(" Color Hue: "+ hue)
- console.log(" Color Saturation: " + saturation)
- console.log(" ")
- console.log(" LB1XX Bulb Other Information ****")
- // A repository for additional attributes as I decide to capture them
- console.log(" Device ID: " + devId)
- console.log(" OEM ID: " + oemId)
- console.log(" HW ID: " + hwId)
- console.log(" Disco Version: " + disco_ver)
- console.log("Control Protocol: " + prot_name +" Ver "+ prot_version)
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement