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:
4646It currently expects the http server to return a float ranging from 0-100 (step 0.1) leaving out any html markup.
4747* ` pullInterval ` \< integer\> ** optional** : The property expects an interval in ** milliseconds** in which the plugin
4848pulls 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.
5052
5153Below are two example configurations. One is using a simple string url and the other is using a simple urlObject.
5254Both configs can be used for a basic plugin configuration.
@@ -78,6 +80,24 @@ Both configs can be used for a basic plugin configuration.
7880}
7981```
8082
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+
81101#### UrlObject
82102
83103A 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;
2323const FIRMWARE_REVISION = PACKAGE_JSON . version ;
2424
2525const 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.
2727
2828// -----------------------------------------------------------------------------
2929// Exports
@@ -46,6 +46,8 @@ function HttpAmbientLightSensor(log, config) {
4646 this . log = log ;
4747 this . name = config . name ;
4848 this . debug = config . debug || false ;
49+ this . minSensorValue = config . minValue || MIN_LUX_VALUE ;
50+ this . maxSensorValue = config . maxValue || MAX_LUX_VALUE ;
4951
5052 if ( config . getUrl ) {
5153 try {
@@ -65,8 +67,8 @@ function HttpAmbientLightSensor(log, config) {
6567 this . homebridgeService = new Service . LightSensor ( this . name ) ;
6668 this . homebridgeService . getCharacteristic ( Characteristic . CurrentAmbientLightLevel )
6769 . setProps ( {
68- minValue : MIN_LUX_VALUE ,
69- maxValue : MAX_LUX_VALUE
70+ minValue : this . minSensorValue ,
71+ maxValue : this . maxSensorValue
7072 } )
7173 . on ( "get" , this . getSensorValue . bind ( this ) ) ;
7274
You can’t perform that action at this time.
0 commit comments