<commit_before>const verbose = require('debug')('ha:door:verbose')
const info = require('debug')('ha:door:info')
const error = require('debug')('ha:door:error')

const config = require('./config')
const diehard = require('diehard')
const PIN_DOOR_STATE = config.pins.readDoorState
const Promise = require('bluebird')
const gpio = require('rpi-gpio')
const gpiop = gpio.promise
const request = require('http-as-promised')
const url = require('url')
const JWTGenerator = require('jwt-generator')
const jwtGenerator = new JWTGenerator({
  loginUrl: config.loginUrl,
  privateKey: config.privateKey,
  useRetry: true
})

let intervalHandler

class Door {
  _sendState (state, isRetry = false) {
    const self = this

    info('sendState called.', 'isRetry:', isRetry)
    return Promise
      .try(() => {
        return isRetry
          ? jwtGenerator.makeNewToken({subject: '/doors', audience: 'urn:home-automation/garage'})
          : jwtGenerator.makeToken({subject: '/doors', audience: 'urn:home-automation/garage'})
      })
      .then(token => {
        info('token generated.  token:', !!token)<commit_msg>log door state<commit_after>const verbose = require('debug')('ha:door:verbose')
const info = require('debug')('ha:door:info')
const error = require('debug')('ha:door:error')

const config = require('./config')
const diehard = require('diehard')
const PIN_DOOR_STATE = config.pins.readDoorState
const Promise = require('bluebird')
const gpio = require('rpi-gpio')
const gpiop = gpio.promise
const request = require('http-as-promised')
const url = require('url')
const JWTGenerator = require('jwt-generator')
const jwtGenerator = new JWTGenerator({
  loginUrl: config.loginUrl,
  privateKey: config.privateKey,
  useRetry: true
})

let intervalHandler

class Door {
  _sendState (state, isRetry = false) {
    const self = this

    info('sendState called.', 'state:', state, 'isRetry:', isRetry)
    return Promise
      .try(() => {
        return isRetry
          ? jwtGenerator.makeNewToken({subject: '/doors', audience: 'urn:home-automation/garage'})
          : jwtGenerator.makeToken({subject: '/doors', audience: 'urn:home-automation/garage'})
      })
      .then(token => {
        info('token generated.  token:', !!token)
{'fraction_non_alphanumeric': 0.15182546749777381, 'fraction_numerical': 0.0, 'mean_word_length': 4.414457831325302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7604816', 'n_tokens_mistral': 695, 'n_tokens_neox': 695, 'n_words': 161}