<commit_before>var hue = require('node-hue-api'),
    HueApi = hue.HueApi,
    lightState = hue.lightState;
var Generator = require('./generator').Generator;

var node = new (require('./../node'))();
node.start('home.lighting', 'hue', function () {
  var api = new HueApi(node.config.ip, node.config.user);

  var state;

  function setNightlight() {
    api.setGroupLightState(0, lightState.create().brightness(1));
    api.setLightState(1, lightState.create().off());
    api.setLightState(2, lightState.create().on().brightness(1)); // one living light
    api.setLightState(3, lightState.create().off());
    api.setLightState(4, lightState.create().off());
    api.setLightState(5, lightState.create().off());
    api.setLightState(6, lightState.create().on().brightness(1)); // hallway light
  }

  var sleepTimer;

  function stateMachine() {
    if (sleepTimer) {
      clearTimeout(sleepTimer);
      sleepTimer = null;
    }

    switch (state) {

    case 'sleeping':
      console.log('==>', 'Setting night mode');
      sleepTimer = setTimeout(setNightlight, 5*60*1000);

      api.setGroupLightState(0, lightState.create().brightness(25));
      break;

    case 'active_night':
      console.log('==>', 'Lights to full power');
      api.setGroupLightState(0, lightState.create().on().brightness(85));
      
      if (new Date().getHours() > 12) {
        api.setLightState(4, lightState.create().brightness(40));
        api.setLightState(5, lightState.create().brightness(40));
        api.setLightState(6, lightState.create().brightness(20));
      }
      break;

    default:
      console.log('==>', 'Turning off lights - unknown state', state);
      api.setGroupLightState(0, lightState.create().off());<commit_msg>Maybe add an alert for sleep mode<commit_after>var hue = require('node-hue-api'),
    HueApi = hue.HueApi,
    lightState = hue.lightState;
var Generator = require('./generator').Generator;

var node = new (require('./../node'))();
node.start('home.lighting', 'hue', function () {
  var api = new HueApi(node.config.ip, node.config.user);

  var state;

  function setNightlight() {
    api.setGroupLightState(0, lightState.create().brightness(1));
    api.setLightState(1, lightState.create().off());
    api.setLightState(2, lightState.create().on().brightness(1)); // one living light
    api.setLightState(3, lightState.create().off());
    api.setLightState(4, lightState.create().off());
    api.setLightState(5, lightState.create().off());
    api.setLightState(6, lightState.create().on().brightness(1)); // hallway light
  }

  var sleepTimer;

  function stateMachine() {
    if (sleepTimer) {
      clearTimeout(sleepTimer);
      sleepTimer = null;
    }

    switch (state) {

    case 'sleeping':
      console.log('==>', 'Setting night mode');
      sleepTimer = setTimeout(function () {
        api.setGroupLightState(0, lightState.create().alert());

        sleepTimer = setTimeout(function () {
          api.setGroupLightState(0, lightState.create().brightness(25));

          sleepTimer = setTimeout(setNightlight, 2.5*60*1000);
        }, 5*60*1000);
      }, 10*1000);

      api.setGroupLightState(0, lightState.create().brightness(25));
      break;

    case 'active_night':
      console.log('==>', 'Lights to full power');
      api.setGroupLightState(0, lightState.create().on().brightness(85));

      if (new Date().getHours() > 12) {
        api.setLightState(4, lightState.create().brightness(40));
        api.setLightState(5, lightState.create().brightness(40));
        api.setLightState(6, lightState.create().brightness(20));
      }
      break;

    default:
      console.log('==>', 'Turning off lights - unknown state', state);
      api.setGroupLightState(0, lightState.create().off());
{'fraction_non_alphanumeric': 0.17245953833908198, 'fraction_numerical': 0.023348368267444946, 'mean_word_length': 3.5095693779904304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1589258', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1171, 'n_words': 211}