Skip to content

Commit

Permalink
Use hashed accessory name for fakegato file
Browse files Browse the repository at this point in the history
  • Loading branch information
hannseman committed Apr 20, 2018
1 parent 5f0e5d0 commit 100dfbf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/accessory.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
const crypto = require('crypto');

const { Scanner } = require('./scanner');
const { version } = require('../package.json');

let Service;
let Characteristic;
let FakeGatoHistoryService;

const defaultTimeout = 15;

class HygrothermographAccessory {
constructor(log, config) {
this.log = log;
this.config = config;
this.displayName = config.accessory;
this.displayName = config.name;

this.latestTemperature = undefined;
this.latestHumidity = undefined;
Expand Down Expand Up @@ -138,7 +141,10 @@ class HygrothermographAccessory {
if (!this.fakeGatoEnabled) {
return undefined;
}
return new FakeGatoHistoryService('room', this, { storage: 'fs' });
const displayName = this.displayName || '';
const hashedAccessoryName = crypto.createHash('sha256').update(displayName).digest('hex');
const filename = `history_${hashedAccessoryName}.json`;
return new FakeGatoHistoryService('room', this, { filename, storage: 'fs' });
}

getInformationService() {
Expand Down

0 comments on commit 100dfbf

Please sign in to comment.