How to use the node-hue-api.v3.api function in node-hue-api

To help you get started, we’ve selected a few node-hue-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ecaron / smart-nightlight-manager / utils / brightChecker.js View on Github external
db.event.on('loaded', function () {
  const bridgeInfo = db.settings.findOne({ type: 'hue' })

  if (!bridgeInfo) {
    console.warn('Did you forget to run Hue settings setup?')
    process.exit(1)
  }

  const LightState = hue.lightStates.LightState
  hue.api.createLocal(bridgeInfo.ip).connect(bridgeInfo.username).then(api => {
    let brightness = 0
    console.log('About to cycle through brightness, from 0% to 100%.')
    setInterval(async function () {
      const state = new LightState().on().brightness(brightness)
      console.log('Brightness at ' + brightness)
      if (brightness === 100) process.exit()
      brightness += 10
      state.rgb(hex2rgb('FFFFFF'))
      try {
        await api.lights.setLightState(process.argv[2], state)
      } catch (e) {
        console.warn(e)
        process.exit(1)
      }
    }, 5000)
  }).catch(err => {