<commit_before>var inputs = {
  solar_elev: 0,
  sun_is_set: 0,

  people_home: 0,
  people_awake: 0
};

function change_input(input, newVal) {
  console.log('[statement]', 'Input', input, 'changed to', newVal);

  if (input == 'people_home' && !inputs.people_home && newVal) {
    console.log('Someone got home!');
    node.setProperty('occupied', true);
  } else if (input == 'people_home' && inputs.people_home && !newVal) {
    console.log('Everyone left!');
    node.setProperty('occupied', false);

  } else if (input == 'people_awake' && !inputs.people_awake && newVal) {
    console.log('Someone woke up!');
    node.setProperty('sleep_mode', false);
  } else if (input == 'people_awake' && inputs.people_awake && !newVal && inputs.people_home) {
    console.log('Everyone passed out');
    node.setProperty('sleep_mode', true);

  } else if (input == 'sun_is_set') {
    console.log('Sunset status:', newVal);
    node.setProperty('disable_lights', !newVal);

  }

  inputs[input] = newVal;
}

var node = new (require('./../node'))();
node.start('home', 'statement', function () {
  node.addProperty('occupied', 'number', false);
  node.addProperty('disable_lights', 'number', false);
  node.addProperty('sleep_mode', 'number', false);

  node.listNodes(function (data) {
    var occupancy = data['home.sensors.occupancy'];
    node.subscribe(occupancy, 'people_home', function (peopleHome) {
      change_input('people_home', peopleHome);
    });
    node.subscribe(occupancy, 'people_awake', function (peopleAwake) {
      change_input('people_awake', peopleAwake);
    });
<commit_msg>Don't wake up lights between midnight and 6am<commit_after>var inputs = {
  solar_elev: 0,
  sun_is_set: 0,

  people_home: 0,
  people_awake: 0
};

function change_input(input, newVal) {
  console.log('[statement]', 'Input', input, 'changed to', newVal);

  if (input == 'people_home' && !inputs.people_home && newVal) {
    console.log('Someone got home!');
    node.setProperty('occupied', true);
  } else if (input == 'people_home' && inputs.people_home && !newVal) {
    console.log('Everyone left!');
    node.setProperty('occupied', false);

  } else if (input == 'people_awake' && !inputs.people_awake && newVal && (new Date().getHours() < 6)) {
    console.log('Someone woke up!');
    node.setProperty('sleep_mode', false);
  } else if (input == 'people_awake' && inputs.people_awake && !newVal && inputs.people_home) {
    console.log('Everyone passed out');
    node.setProperty('sleep_mode', true);

  } else if (input == 'sun_is_set') {
    console.log('Sunset status:', newVal);
    node.setProperty('disable_lights', !newVal);

  }

  inputs[input] = newVal;
}

var node = new (require('./../node'))();
node.start('home', 'statement', function () {
  node.addProperty('occupied', 'number', false);
  node.addProperty('disable_lights', 'number', false);
  node.addProperty('sleep_mode', 'number', false);

  node.listNodes(function (data) {
    var occupancy = data['home.sensors.occupancy'];
    node.subscribe(occupancy, 'people_home', function (peopleHome) {
      change_input('people_home', peopleHome);
    });
    node.subscribe(occupancy, 'people_awake', function (peopleAwake) {
      change_input('people_awake', peopleAwake);
    });

{'fraction_non_alphanumeric': 0.1765428308259134, 'fraction_numerical': 0.003070310101320233, 'mean_word_length': 4.522033898305085, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '2713229', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1056, 'n_words': 222}