Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb3dfb11

Browse files
author
Stefan Kuper
committed
services
1 parent39619de commitb3dfb11

7 files changed

+366
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
'use strict';
2+
3+
varhomebridge;
4+
varCharacteristic;
5+
6+
constATMOSPHERIC_PRESSURE_STYPE_ID="B77831FD-D66A-46A4-B66D-FD7EE8DFE3CE";
7+
//Elgato
8+
constATMOSPHERIC_PRESSURE_CTYPE_ID="E863F10F-079E-48FF-8F27-9C2605A29F52";
9+
//const ATMOSPHERIC_PRESSURE_CTYPE_ID = "28FDA6BC-9C2A-4DEA-AAFD-B49DB6D155AB";
10+
11+
/*
12+
const ATMOSPHERIC_PRESSURE_STYPE_ID = "B77831FD-D66A-46A4-B66D-FD7EE8DFE3CE";
13+
const ATMOSPHERIC_PRESSURE_CTYPE_ID = "28FDA6BC-9C2A-4DEA-AAFD-B49DB6D155AB";
14+
var EVE_WEATHER_SERVICE_STYPE_ID = 'E863F001-079E-48FF-8F27-9C2605A29F52';
15+
var EVE_AIR_PRESSURE_CTYPE_ID = "E863F10F-079E-48FF-8F27-9C2605A29F52";
16+
*/
17+
18+
module.exports=function(pHomebridge){
19+
if(pHomebridge&&!homebridge){
20+
homebridge=pHomebridge;
21+
Characteristic=homebridge.hap.Characteristic;
22+
}
23+
24+
classAtmosphericPressureCharacteristicextendsCharacteristic{
25+
constructor(accessory){
26+
super('Atmospheric Pressure',ATMOSPHERIC_PRESSURE_CTYPE_ID);
27+
this.setProps({
28+
format:Characteristic.Formats.UINT8,
29+
unit:"hPA",
30+
minValue:500,
31+
maxValue:2000,
32+
minStep:0.1,
33+
perms:[
34+
Characteristic.Perms.READ,
35+
Characteristic.Perms.NOTIFY
36+
]
37+
});
38+
this.value=this.getDefaultValue();
39+
}
40+
}
41+
42+
classAirPressureServiceextendshomebridge.hap.Service{
43+
constructor(accessory){
44+
super(accessory.name+" Air Pressure",ATMOSPHERIC_PRESSURE_STYPE_ID);
45+
this.accessory=accessory;
46+
47+
this.addCharacteristic(AtmosphericPressureCharacteristic)
48+
.on('get',this.getAtmosphericPressure.bind(this))
49+
.eventEnabled=true;
50+
51+
// this.addOptionalCharacteristic(Characteristic.StatusActive);
52+
// this.addOptionalCharacteristic(Characteristic.StatusFault);
53+
this.addOptionalCharacteristic(Characteristic.Name);
54+
55+
}
56+
57+
updateCharacteristics(){
58+
this.getCharacteristic(AtmosphericPressureCharacteristic)
59+
.updateValue(this.accessory.airPressure);
60+
}
61+
62+
getAtmosphericPressure(callback){
63+
this.accessory.refreshData(function(err,data){
64+
callback(err,this.accessory.airPressure);
65+
}.bind(this));
66+
}
67+
68+
}
69+
70+
returnAirPressureService;
71+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
'use strict';
2+
3+
varhomebridge;
4+
varCharacteristic;
5+
6+
module.exports=function(pHomebridge){
7+
if(pHomebridge&&!homebridge){
8+
homebridge=pHomebridge;
9+
Characteristic=homebridge.hap.Characteristic;
10+
}
11+
12+
classAirQualityServiceextendshomebridge.hap.Service.AirQualitySensor{
13+
constructor(accessory){
14+
super(accessory.name+" Air Quality");
15+
this.accessory=accessory;
16+
17+
this.getCharacteristic(Characteristic.AirQuality)
18+
.on('get',this.getAirQuality.bind(this))
19+
.eventEnabled=true;
20+
21+
}
22+
23+
updateCharacteristics(){
24+
this.getCharacteristic(Characteristic.AirQuality)
25+
.updateValue(this.transformCO2ToAirQuality());
26+
}
27+
28+
getAirQuality(callback){
29+
this.accessory.refreshData(function(err,data){
30+
callback(err,this.transformCO2ToAirQuality());
31+
}.bind(this));
32+
}
33+
34+
transformCO2ToAirQuality(){
35+
varlevel=this.accessory.co2;
36+
varquality=Characteristic.AirQuality.UNKNOWN;
37+
38+
if(level>2000)quality=Characteristic.AirQuality.POOR;
39+
elseif(level>1500)quality=Characteristic.AirQuality.INFERIOR;
40+
elseif(level>1000)quality=Characteristic.AirQuality.FAIR;
41+
elseif(level>500)quality=Characteristic.AirQuality.GOOD;
42+
elseif(level>0)quality=Characteristic.AirQuality.EXCELLENT;
43+
44+
returnquality;
45+
}
46+
47+
}
48+
49+
returnAirQualityService;
50+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
'use strict';
2+
3+
varhomebridge;
4+
varCharacteristic;
5+
6+
module.exports=function(pHomebridge){
7+
if(pHomebridge&&!homebridge){
8+
homebridge=pHomebridge;
9+
Characteristic=homebridge.hap.Characteristic;
10+
}
11+
12+
classBatteryServiceextendshomebridge.hap.Service.BatteryService{
13+
constructor(accessory){
14+
super(accessory.name+" Thermostat");
15+
this.accessory=accessory;
16+
17+
this.getCharacteristic(Characteristic.BatteryLevel)
18+
.on('get',this.getBatteryLevel.bind(this))
19+
.eventEnabled=true;
20+
this.getCharacteristic(Characteristic.StatusLowBattery)
21+
.on('get',this.getStatusLowBattery.bind(this))
22+
.eventEnabled=true;
23+
this.getCharacteristic(Characteristic.ChargingState)
24+
.on('get',this.getChargingState.bind(this));
25+
}
26+
27+
getBatteryLevel(callback){
28+
this.accessory.refreshData(function(err,data){
29+
callback(err,this.accessory.batteryPercent);
30+
}.bind(this));
31+
}
32+
33+
getStatusLowBattery(callback){
34+
this.accessory.refreshData(function(err,data){
35+
callback(err,this.accessory.lowBattery ?Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW :Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL);
36+
}.bind(this));
37+
}
38+
39+
getChargingState(callback){
40+
callback(null,Characteristic.ChargingState.NOT_CHARGING);
41+
}
42+
43+
updateCharacteristics(){
44+
this.getCharacteristic(Characteristic.BatteryLevel)
45+
.updateValue(this.accessory.batteryPercent);
46+
this.getCharacteristic(Characteristic.StatusLowBattery)
47+
.updateValue(this.accessory.lowBattery ?Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW :Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL);
48+
}
49+
}
50+
51+
returnBatteryService;
52+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'use strict';
2+
3+
varhomebridge;
4+
varCharacteristic;
5+
6+
module.exports=function(pHomebridge){
7+
if(pHomebridge&&!homebridge){
8+
homebridge=pHomebridge;
9+
Characteristic=homebridge.hap.Characteristic;
10+
}
11+
12+
classCarbonDioxideServiceextendshomebridge.hap.Service.CarbonDioxideSensor{
13+
constructor(accessory){
14+
super(accessory.name+" Carbon Dioxide");
15+
this.accessory=accessory;
16+
17+
this.getCharacteristic(Characteristic.CarbonDioxideDetected)
18+
.on('get',this.getCarbonDioxideDetected.bind(this))
19+
.eventEnabled=true;
20+
21+
varco2LevelCharacteristic=this.getCharacteristic(Characteristic.CarbonDioxideLevel)
22+
||this.addCharacteristic(Characteristic.CarbonDioxideLevel);
23+
24+
co2LevelCharacteristic.on('get',this.getCarbonDioxideLevel.bind(this))
25+
.eventEnabled=true;
26+
}
27+
28+
updateCharacteristics(){
29+
this.getCharacteristic(Characteristic.CarbonDioxideDetected)
30+
.updateValue(this.transformCO2ToCarbonDioxideDetected());
31+
this.getCharacteristic(Characteristic.CarbonDioxideLevel)
32+
.updateValue(this.accessory.co2);
33+
}
34+
35+
getCarbonDioxideDetected(callback){
36+
this.accessory.refreshData(function(err,data){
37+
callback(err,this.transformCO2ToCarbonDioxideDetected());
38+
}.bind(this));
39+
}
40+
41+
getCarbonDioxideLevel(callback){
42+
this.accessory.refreshData(function(err,data){
43+
callback(err,this.accessory.co2);
44+
}.bind(this));
45+
}
46+
47+
transformCO2ToCarbonDioxideDetected(){
48+
return(this.accessory.co2>1000 ?Characteristic.CarbonDioxideDetected.CO2_LEVELS_ABNORMAL :Characteristic.CarbonDioxideDetected.CO2_LEVELS_NORMAL);
49+
}
50+
}
51+
52+
returnCarbonDioxideService;
53+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
varhomebridge;
4+
varCharacteristic;
5+
6+
module.exports=function(pHomebridge){
7+
if(pHomebridge&&!homebridge){
8+
homebridge=pHomebridge;
9+
Characteristic=homebridge.hap.Characteristic;
10+
}
11+
12+
classHumidityServiceextendshomebridge.hap.Service.HumiditySensor{
13+
constructor(accessory){
14+
super(accessory.name+" Humidity");
15+
this.accessory=accessory;
16+
17+
this.getCharacteristic(Characteristic.CurrentRelativeHumidity)
18+
.on('get',this.getCurrentRelativeHumidity.bind(this))
19+
.eventEnabled=true;
20+
}
21+
22+
updateCharacteristics(){
23+
this.getCharacteristic(Characteristic.CurrentRelativeHumidity)
24+
.updateValue(this.accessory.humidity);
25+
}
26+
27+
getCurrentRelativeHumidity(callback){
28+
this.accessory.refreshData(function(err,data){
29+
callback(err,this.accessory.humidity);
30+
}.bind(this));
31+
}
32+
}
33+
34+
returnHumidityService;
35+
}
36+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
'use strict';
2+
3+
varhomebridge;
4+
varCharacteristic;
5+
6+
constNOISE_LEVEL_STYPE_ID="8C85FD40-EB20-45EE-86C5-BCADC773E580";
7+
constNOISE_LEVEL_CTYPE_ID="2CD7B6FD-419A-4740-8995-E3BFE43735AB";
8+
9+
module.exports=function(pHomebridge){
10+
if(pHomebridge&&!homebridge){
11+
homebridge=pHomebridge;
12+
Characteristic=homebridge.hap.Characteristic;
13+
}
14+
15+
classNoiseLevelCharacteristicextendsCharacteristic{
16+
constructor(accessory){
17+
super('Noise Level',NOISE_LEVEL_CTYPE_ID);
18+
this.setProps({
19+
format:Characteristic.Formats.UINT8,
20+
unit:"dB",
21+
minValue:0,
22+
maxValue:200,
23+
minStep:1,
24+
perms:[
25+
Characteristic.Perms.READ,
26+
Characteristic.Perms.NOTIFY
27+
]
28+
});
29+
this.value=this.getDefaultValue();
30+
}
31+
}
32+
33+
classNoiseLevelServiceextendshomebridge.hap.Service{
34+
constructor(accessory){
35+
super(accessory.name+" Noise Level",NOISE_LEVEL_STYPE_ID);
36+
this.accessory=accessory;
37+
38+
this.addCharacteristic(NoiseLevelCharacteristic)
39+
.on('get',this.getNoiseLevel.bind(this))
40+
.eventEnabled=true;
41+
42+
// this.addOptionalCharacteristic(Characteristic.StatusActive);
43+
// this.addOptionalCharacteristic(Characteristic.StatusFault);
44+
// this.addOptionalCharacteristic(Characteristic.StatusTampered);
45+
this.addOptionalCharacteristic(Characteristic.Name);
46+
}
47+
48+
updateCharacteristics(){
49+
this.getCharacteristic(NoiseLevelCharacteristic)
50+
.updateValue(this.accessory.noiseLevel);
51+
}
52+
53+
getNoiseLevel(callback){
54+
this.accessory.refreshData(function(err,data){
55+
callback(err,this.accessory.noiseLevel);
56+
}.bind(this));
57+
}
58+
59+
}
60+
61+
returnNoiseLevelService;
62+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'use strict';
2+
3+
varhomebridge;
4+
varCharacteristic;
5+
6+
module.exports=function(pHomebridge){
7+
if(pHomebridge&&!homebridge){
8+
homebridge=pHomebridge;
9+
Characteristic=homebridge.hap.Characteristic;
10+
}
11+
12+
classTemperatureServiceextendshomebridge.hap.Service.TemperatureSensor{
13+
constructor(accessory){
14+
super(accessory.name+" Temperature");
15+
this.accessory=accessory;
16+
17+
this.getCharacteristic(Characteristic.CurrentTemperature)
18+
.on('get',this.getCurrentTemperature.bind(this))
19+
.eventEnabled=true;
20+
21+
}
22+
23+
updateCharacteristics(){
24+
this.getCharacteristic(Characteristic.CurrentTemperature)
25+
.updateValue(this.accessory.currentTemperature);
26+
}
27+
28+
getCurrentTemperature(callback){
29+
this.accessory.refreshData(function(err,data){
30+
callback(err,this.accessory.currentTemperature);
31+
}.bind(this));
32+
}
33+
}
34+
35+
returnTemperatureService;
36+
}
37+
38+
/*
39+
if(stationData.data_type.indexOf('Temperature') > -1) {
40+
services.push(this.buildTemperatureSensor(accessory, stationData));
41+
}
42+
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp