-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more loggin for the weather station sensor
- Loading branch information
Showing
4 changed files
with
348 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
const assert = require('assert') | ||
const path = require('path') | ||
const Logger = require(path.join(__dirname, '..', 'lib', 'logger.js')) | ||
const Server = require(path.join(__dirname, '..', 'lib', 'Server.js')) | ||
const Characteristic = require('hap-nodejs').Characteristic | ||
const expect = require('expect.js') | ||
|
||
const fs = require('fs') | ||
let log = new Logger('HAP Test') | ||
log.setDebugEnabled(false) | ||
|
||
const testCase = 'HmIP-SWO-B.json' | ||
|
||
describe('HAP-Homematic Tests ' + testCase, () => { | ||
let that = this | ||
|
||
before(async () => { | ||
log.debug('preparing tests') | ||
let datapath = path.join(__dirname, 'devices', testCase) | ||
let strData = fs.readFileSync(datapath).toString() | ||
if (strData) { | ||
that.data = JSON.parse(strData) | ||
|
||
that.server = new Server(log) | ||
|
||
await that.server.simulate(undefined, {config: { | ||
channels: Object.keys(that.data.ccu) | ||
}, | ||
devices: that.data.devices}) | ||
} else { | ||
assert.ok(false, 'Unable to load Test data') | ||
} | ||
}) | ||
|
||
after(() => { | ||
Object.keys(that.server._publishedAccessories).map(key => { | ||
let accessory = that.server._publishedAccessories[key] | ||
accessory.shutdown() | ||
}) | ||
}) | ||
|
||
it('HAP-Homematic check test mode', (done) => { | ||
expect(that.server.isTestMode).to.be(true) | ||
done() | ||
}) | ||
|
||
it('HAP-Homematic check number of ccu devices', (done) => { | ||
expect(that.server._ccu.getCCUDevices().length).to.be(1) | ||
done() | ||
}) | ||
|
||
it('HAP-Homematic check number of mappend devices', (done) => { | ||
expect(Object.keys(that.server._publishedAccessories).length).to.be(1) | ||
done() | ||
}) | ||
|
||
it('HAP-Homematic check assigned services', (done) => { | ||
Object.keys(that.server._publishedAccessories).map(key => { | ||
let accessory = that.server._publishedAccessories[key] | ||
expect(accessory.serviceClass).to.be(that.data.ccu[accessory.address()]) | ||
}) | ||
done() | ||
}) | ||
|
||
it('HAP-Homematic check ACTUAL_TEMPERATURE 10', (done) => { | ||
that.server._ccu.fireEvent('HmIP.1916894937ABCD:1.ACTUAL_TEMPERATURE', 10.0) | ||
let accessory = that.server._publishedAccessories[Object.keys(that.server._publishedAccessories)[0]] | ||
let service = accessory.getService(accessory.eveWeatherProg.Service.EveWeather, 'TestDevice', false, '', true) | ||
assert.ok(service, 'WeatherStation Service not found') | ||
let ch = service.getCharacteristic(Characteristic.CurrentTemperature) | ||
assert.ok(ch, 'CurrentTemperature State Characteristics not found') | ||
ch.getValue((context, value) => { | ||
try { | ||
expect(value).to.be(10) | ||
done() | ||
} catch (e) { | ||
done(e) | ||
} | ||
}) | ||
}) | ||
|
||
it('HAP-Homematic check HUMIDITY 34', (done) => { | ||
that.server._ccu.fireEvent('HmIP.1916894937ABCD:1.HUMIDITY', 34.0) | ||
let accessory = that.server._publishedAccessories[Object.keys(that.server._publishedAccessories)[0]] | ||
let service = accessory.getService(accessory.eveWeatherProg.Service.EveWeather) | ||
assert.ok(service, 'WeatherStation Service not found') | ||
let ch = service.getCharacteristic(Characteristic.CurrentRelativeHumidity) | ||
assert.ok(ch, 'CurrentRelativeHumidity State Characteristics not found') | ||
ch.getValue((context, value) => { | ||
try { | ||
expect(value).to.be(34) | ||
done() | ||
} catch (e) { | ||
done(e) | ||
} | ||
}) | ||
}) | ||
|
||
it('HAP-Homematic check ILLUMINATION 140', (done) => { | ||
that.server._ccu.fireEvent('HmIP.1916894937ABCD:1.ILLUMINATION', 140) | ||
let accessory = that.server._publishedAccessories[Object.keys(that.server._publishedAccessories)[0]] | ||
let service = accessory.getService(accessory.eveWeatherProg.Service.EveWeather) | ||
assert.ok(service, 'WeatherStation Service not found') | ||
let ch = service.getCharacteristic(Characteristic.CurrentAmbientLightLevel) | ||
assert.ok(ch, 'CurrentAmbientLightLevel State Characteristics not found') | ||
ch.getValue((context, value) => { | ||
try { | ||
expect(value).to.be(140) | ||
done() | ||
} catch (e) { | ||
done(e) | ||
} | ||
}) | ||
}) | ||
|
||
it('HAP-Homematic check SUNSHINEDURATION 340 min which are 5.6 hours', (done) => { | ||
that.server._ccu.setVariable('svHmIPSunshineCounterToday_1002', 340.0) | ||
let accessory = that.server._publishedAccessories[Object.keys(that.server._publishedAccessories)[0]] | ||
let service = accessory.getService(accessory.eveWeatherProg.Service.EveWeather) | ||
assert.ok(service, 'WeatherStation Service not found') | ||
let ch = service.getCharacteristic(accessory.eveWeatherProg.Characteristic.SunShineDuration) | ||
assert.ok(ch, 'SunShineDuration State Characteristics not found') | ||
ch.getValue((context, value) => { | ||
try { | ||
expect(value).to.be(5.6) | ||
done() | ||
} catch (e) { | ||
done(e) | ||
} | ||
}) | ||
}) | ||
|
||
it('HAP-Homematic check WIND_SPEED 98', (done) => { | ||
that.server._ccu.fireEvent('HmIP.1916894937ABCD:1.WIND_SPEED', 98) | ||
let accessory = that.server._publishedAccessories[Object.keys(that.server._publishedAccessories)[0]] | ||
let service = accessory.getService(accessory.eveWeatherProg.Service.EveWeather) | ||
assert.ok(service, 'WeatherStation Service not found') | ||
let ch = service.getCharacteristic(accessory.eveWeatherProg.Characteristic.WindSpeed) | ||
assert.ok(ch, 'WindSpeedCharacteristic State Characteristics not found') | ||
ch.getValue((context, value) => { | ||
try { | ||
expect(value).to.be(98) | ||
done() | ||
} catch (e) { | ||
done(e) | ||
} | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
const assert = require('assert') | ||
const path = require('path') | ||
const Logger = require(path.join(__dirname, '..', 'lib', 'logger.js')) | ||
const Server = require(path.join(__dirname, '..', 'lib', 'Server.js')) | ||
const Characteristic = require('hap-nodejs').Characteristic | ||
const expect = require('expect.js') | ||
const Service = require('hap-nodejs').Service | ||
|
||
const fs = require('fs') | ||
let log = new Logger('HAP Test') | ||
log.setDebugEnabled(false) | ||
|
||
const testCase = 'HmIP-SWO-B.json' | ||
|
||
describe('HAP-Homematic Tests (Apple Config) ' + testCase, () => { | ||
let that = this | ||
|
||
before(async () => { | ||
log.debug('preparing tests') | ||
let datapath = path.join(__dirname, 'devices', testCase) | ||
let strData = fs.readFileSync(datapath).toString() | ||
if (strData) { | ||
that.data = JSON.parse(strData) | ||
|
||
that.server = new Server(log) | ||
|
||
await that.server.simulate(undefined, {config: { | ||
channels: Object.keys(that.data.ccu) | ||
}, | ||
devices: that.data.devices, | ||
mappings: that.data.mappings}) | ||
} else { | ||
assert.ok(false, 'Unable to load Test data') | ||
} | ||
}) | ||
|
||
after(() => { | ||
Object.keys(that.server._publishedAccessories).map(key => { | ||
let accessory = that.server._publishedAccessories[key] | ||
accessory.shutdown() | ||
}) | ||
}) | ||
|
||
it('HAP-Homematic check test mode', (done) => { | ||
expect(that.server.isTestMode).to.be(true) | ||
done() | ||
}) | ||
|
||
it('HAP-Homematic check number of ccu devices', (done) => { | ||
expect(that.server._ccu.getCCUDevices().length).to.be(1) | ||
done() | ||
}) | ||
|
||
it('HAP-Homematic check number of mappend devices', (done) => { | ||
expect(Object.keys(that.server._publishedAccessories).length).to.be(1) | ||
done() | ||
}) | ||
|
||
it('HAP-Homematic check assigned services', (done) => { | ||
Object.keys(that.server._publishedAccessories).map(key => { | ||
let accessory = that.server._publishedAccessories[key] | ||
expect(accessory.serviceClass).to.be(that.data.ccu[accessory.address()]) | ||
}) | ||
done() | ||
}) | ||
|
||
it('HAP-Homematic check ACTUAL_TEMPERATURE 10', (done) => { | ||
that.server._ccu.fireEvent('HmIP.1916894937ABCD:1.ACTUAL_TEMPERATURE', 10.0) | ||
let accessory = that.server._publishedAccessories[Object.keys(that.server._publishedAccessories)[0]] | ||
let service = accessory.getService(Service.TemperatureSensor, 'TestDevice', false, '', true) | ||
assert.ok(service, 'TemperatureSensor Service not found') | ||
let ch = service.getCharacteristic(Characteristic.CurrentTemperature) | ||
assert.ok(ch, 'CurrentTemperature State Characteristics not found') | ||
ch.getValue((context, value) => { | ||
try { | ||
expect(value).to.be(10) | ||
done() | ||
} catch (e) { | ||
done(e) | ||
} | ||
}) | ||
}) | ||
|
||
it('HAP-Homematic check HUMIDITY 34', (done) => { | ||
that.server._ccu.fireEvent('HmIP.1916894937ABCD:1.HUMIDITY', 34.0) | ||
let accessory = that.server._publishedAccessories[Object.keys(that.server._publishedAccessories)[0]] | ||
let service = accessory.getService(Service.HumiditySensor) | ||
assert.ok(service, 'HumiditySensor Service not found') | ||
let ch = service.getCharacteristic(Characteristic.CurrentRelativeHumidity) | ||
assert.ok(ch, 'CurrentRelativeHumidity State Characteristics not found') | ||
ch.getValue((context, value) => { | ||
try { | ||
expect(value).to.be(34) | ||
done() | ||
} catch (e) { | ||
done(e) | ||
} | ||
}) | ||
}) | ||
|
||
it('HAP-Homematic check ILLUMINATION 140', (done) => { | ||
that.server._ccu.fireEvent('HmIP.1916894937ABCD:1.ILLUMINATION', 140) | ||
let accessory = that.server._publishedAccessories[Object.keys(that.server._publishedAccessories)[0]] | ||
let service = accessory.getService(Service.LightSensor) | ||
assert.ok(service, 'LightSensor Service not found') | ||
let ch = service.getCharacteristic(Characteristic.CurrentAmbientLightLevel) | ||
assert.ok(ch, 'CurrentAmbientLightLevel State Characteristics not found') | ||
ch.getValue((context, value) => { | ||
try { | ||
expect(value).to.be(140) | ||
done() | ||
} catch (e) { | ||
done(e) | ||
} | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
"devices": [ | ||
{ | ||
"id": 1000, | ||
"intf": 0, | ||
"intfName": "HmIP", | ||
"name": "HmIP-SWO-B", | ||
"address": "1916894937ABCD", | ||
"type": "HmIP-SWO-B", | ||
"channels": [ | ||
{ | ||
"id": 1001, | ||
"name": "1916894937ABCD:0", | ||
"intf": 0, | ||
"address": "1916894937ABCD:0", | ||
"type": "MAINTENANCE", | ||
"access": 255 | ||
}, | ||
{ | ||
"id": 1002, | ||
"name": "1916894937ABCD:1", | ||
"intf": 0, | ||
"address": "1916894937ABCD:1", | ||
"type": "WEATHER_TRANSMIT", | ||
"access": 255 | ||
}, | ||
{ | ||
"id": 1003, | ||
"name": "1916894937ABCD:2", | ||
"intf": 0, | ||
"address": "1916894937ABCD:2", | ||
"type": "COND_SWITCH_TRANSMITTER_WIND_SPEED", | ||
"access": 255 | ||
}, | ||
{ | ||
"id": 1004, | ||
"name": "1916894937ABCD:3", | ||
"intf": 0, | ||
"address": "1916894937ABCD:3", | ||
"type": "COND_SWITCH_TRANSMITTER_TEMPERATURE", | ||
"access": 255 | ||
}, | ||
{ | ||
"id": 1005, | ||
"name": "1916894937ABCD:4", | ||
"intf": 0, | ||
"address": "1916894937ABCD:4", | ||
"type": "COND_SWITCH_TRANSMITTER_HUMIDITY", | ||
"access": 255 | ||
}, | ||
{ | ||
"id": 1006, | ||
"name": "1916894937ABCD:5", | ||
"intf": 0, | ||
"address": "1916894937ABCD:5", | ||
"type": "COND_SWITCH_TRANSMITTER_BRIGHTNESS", | ||
"access": 255 | ||
} | ||
] | ||
} | ||
], | ||
"ccu": { | ||
"1916894937ABCD:1": "HomeMaticWeatherStationAccessory" | ||
}, | ||
"mappings": { | ||
"1916894937ABCD:1": { | ||
"Service":"HomeMaticWeatherStationAccessory", | ||
"settings": { | ||
"applHome":true | ||
} | ||
} | ||
} | ||
} |