@@ -4,6 +4,7 @@ var homebridge;
4
4
var Characteristic ;
5
5
6
6
const RAIN_LEVEL_STYPE_ID = "D92D5391-92AF-4824-AF4A-356F25F25EA1" ;
7
+ const RAIN_LEVEL_CTYPE_ID = "C53F35CE-C615-4AA4-9112-EBF679C5EB14" ;
7
8
const RAIN_LEVEL_SUM_1H_CTYPE_ID = "10c88f40-7ec4-478c-8d5a-bd0c3cce14b7" ;
8
9
const RAIN_LEVEL_SUM_24H_CTYPE_ID = "ccc04890-565b-4376-b39a-3113341d9e0f" ;
9
10
@@ -12,6 +13,24 @@ module.exports = function(pHomebridge) {
12
13
homebridge = pHomebridge ;
13
14
Characteristic = homebridge . hap . Characteristic ;
14
15
}
16
+
17
+ class RainLevelCharacteristic extends Characteristic {
18
+ constructor ( accessory ) {
19
+ super ( 'Rain Level' , RAIN_LEVEL_CTYPE_ID ) ;
20
+ this . setProps ( {
21
+ format : Characteristic . Formats . FLOAT ,
22
+ unit : "mm" ,
23
+ minValue : 0 ,
24
+ maxValue : 1000 ,
25
+ minStep : 0.001 ,
26
+ perms : [
27
+ Characteristic . Perms . READ ,
28
+ Characteristic . Perms . NOTIFY
29
+ ]
30
+ } ) ;
31
+ this . value = this . getDefaultValue ( ) ;
32
+ }
33
+ }
15
34
16
35
class RainLevelSum1Characteristic extends Characteristic {
17
36
constructor ( accessory ) {
@@ -54,6 +73,9 @@ module.exports = function(pHomebridge) {
54
73
super ( accessory . name , RAIN_LEVEL_STYPE_ID ) ;
55
74
this . accessory = accessory ;
56
75
76
+ this . addCharacteristic ( RainLevelCharacteristic )
77
+ . on ( 'get' , this . getRainLevel . bind ( this ) )
78
+ . eventEnabled = true ;
57
79
this . addCharacteristic ( RainLevelSum1Characteristic )
58
80
. on ( 'get' , this . getRainLevelSum1 . bind ( this ) )
59
81
. eventEnabled = true ;
@@ -63,12 +85,20 @@ module.exports = function(pHomebridge) {
63
85
}
64
86
65
87
updateCharacteristics ( ) {
88
+ this . getCharacteristic ( RainLevelCharacteristic )
89
+ . updateValue ( this . accessory . rainLevel ) ;
66
90
this . getCharacteristic ( RainLevelSum1Characteristic )
67
91
. updateValue ( this . accessory . rainLevelSum1 ) ;
68
92
this . getCharacteristic ( RainLevelSum24Characteristic )
69
93
. updateValue ( this . accessory . rainLevelSum24 ) ;
70
94
}
71
95
96
+ getRainLevel ( callback ) {
97
+ this . accessory . refreshData ( function ( err , data ) {
98
+ callback ( err , this . accessory . rainLevel ) ;
99
+ } . bind ( this ) ) ;
100
+ }
101
+
72
102
getRainLevelSum1 ( callback ) {
73
103
this . accessory . refreshData ( function ( err , data ) {
74
104
callback ( err , this . accessory . rainLevelSum1 ) ;
0 commit comments