File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,9 @@ The configuration can contain the following properties:
46
46
It currently expects the http server to return a float ranging from 0-100 (step 0.1) leaving out any html markup.
47
47
* ` pullInterval ` \< integer\> ** optional** : The property expects an interval in ** milliseconds** in which the plugin
48
48
pulls updates from your http device. For more information read [ pulling updates] ( #the-pull-way ) .
49
- * ` debug ` \< boolean\> ** optional** : Enable debug mode and write more logs.
49
+ * ` debug ` \< boolean\> ** optional** : Enable debug mode and write more logs.
50
+ * ` minValue ` \< float>\> ** optional** : Minimum lux value the sensor can return. Defaults to BH1750 light sensor module value: 2^16 -1 = 65535.
51
+ * ` maxValue ` \< float>\> ** optional** : Maximum lux value the sensor can return. Default to 0.0.
50
52
51
53
Below are two example configurations. One is using a simple string url and the other is using a simple urlObject.
52
54
Both configs can be used for a basic plugin configuration.
@@ -78,6 +80,24 @@ Both configs can be used for a basic plugin configuration.
78
80
}
79
81
```
80
82
83
+ Specifying a custom min and max value for an 8 bit sensor:
84
+
85
+ ``` json
86
+ {
87
+ "accessories" : [
88
+ {
89
+ "accessory" : " HttpAmbientLightSensor" ,
90
+ "name" : " Outdoor Light Sensor" ,
91
+
92
+ "getUrl" : " http://localhost/api/lux" ,
93
+
94
+ "minValue" : 1.0 ,
95
+ "maxValue" : 255
96
+ }
97
+ ]
98
+ }
99
+ ```
100
+
81
101
#### UrlObject
82
102
83
103
A urlObject can have the following properties:
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ const MODEL = PACKAGE_JSON.name;
23
23
const FIRMWARE_REVISION = PACKAGE_JSON . version ;
24
24
25
25
const MIN_LUX_VALUE = 0.0 ;
26
- const MAX_LUX_VALUE = Math . pow ( 2 , 16 ) - 1.0 ;
26
+ const MAX_LUX_VALUE = Math . pow ( 2 , 16 ) - 1.0 ; // Default BH1750 max 16bit lux value.
27
27
28
28
// -----------------------------------------------------------------------------
29
29
// Exports
@@ -46,6 +46,8 @@ function HttpAmbientLightSensor(log, config) {
46
46
this . log = log ;
47
47
this . name = config . name ;
48
48
this . debug = config . debug || false ;
49
+ this . minSensorValue = config . minValue || MIN_LUX_VALUE ;
50
+ this . maxSensorValue = config . maxValue || MAX_LUX_VALUE ;
49
51
50
52
if ( config . getUrl ) {
51
53
try {
@@ -65,8 +67,8 @@ function HttpAmbientLightSensor(log, config) {
65
67
this . homebridgeService = new Service . LightSensor ( this . name ) ;
66
68
this . homebridgeService . getCharacteristic ( Characteristic . CurrentAmbientLightLevel )
67
69
. setProps ( {
68
- minValue : MIN_LUX_VALUE ,
69
- maxValue : MAX_LUX_VALUE
70
+ minValue : this . minSensorValue ,
71
+ maxValue : this . maxSensorValue
70
72
} )
71
73
. on ( "get" , this . getSensorValue . bind ( this ) ) ;
72
74
You can’t perform that action at this time.
0 commit comments