mirror of
https://github.com/mtan93/homebridge.git
synced 2026-05-10 22:06:48 +01:00
fixed racecondition
This commit is contained in:
+8
-8
@@ -541,7 +541,7 @@ FHEMAccessory.prototype = {
|
|||||||
} else if( reading == 'pct' ) {
|
} else if( reading == 'pct' ) {
|
||||||
value = parseInt( value );
|
value = parseInt( value );
|
||||||
|
|
||||||
} else if(reading.match(/motor$/)) {
|
} else if(reading == 'motor') {
|
||||||
if( value.match(/^opening/))
|
if( value.match(/^opening/))
|
||||||
value = 1;
|
value = 1;
|
||||||
else if( value.match(/^up/))
|
else if( value.match(/^up/))
|
||||||
@@ -551,7 +551,7 @@ FHEMAccessory.prototype = {
|
|||||||
else if( value.match(/^down/))
|
else if( value.match(/^down/))
|
||||||
value = 0;
|
value = 0;
|
||||||
else
|
else
|
||||||
value = 2;
|
value = 2;
|
||||||
|
|
||||||
value = parseInt(value);
|
value = parseInt(value);
|
||||||
|
|
||||||
@@ -718,7 +718,7 @@ FHEMAccessory.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
query: function(reading, callback) {
|
query: function(reading, callback) {
|
||||||
this.log("query: " + this.name + ": " + reading);
|
this.log("query: " + this.name + "-" + reading);
|
||||||
|
|
||||||
var result = FHEM_cached[this.device + '-' + reading];
|
var result = FHEM_cached[this.device + '-' + reading];
|
||||||
if( result != undefined ) {
|
if( result != undefined ) {
|
||||||
@@ -729,6 +729,7 @@ FHEMAccessory.prototype = {
|
|||||||
} else
|
} else
|
||||||
this.log(" not cached" );
|
this.log(" not cached" );
|
||||||
|
|
||||||
|
var query_reading = reading;
|
||||||
if( reading == 'hue' && !this.hasHue && this.hasRGB ) {
|
if( reading == 'hue' && !this.hasHue && this.hasRGB ) {
|
||||||
query_reading = this.hasRGB;
|
query_reading = this.hasRGB;
|
||||||
|
|
||||||
@@ -740,9 +741,7 @@ FHEMAccessory.prototype = {
|
|||||||
|
|
||||||
} else if( reading == 'pct' && !this.hasPct && this.hasDim ) {
|
} else if( reading == 'pct' && !this.hasPct && this.hasDim ) {
|
||||||
query_reading = 'state';
|
query_reading = 'state';
|
||||||
|
}
|
||||||
} else
|
|
||||||
query_reading = reading;
|
|
||||||
|
|
||||||
var cmd = '{ReadingsVal("'+this.device+'","'+query_reading+'","")}';
|
var cmd = '{ReadingsVal("'+this.device+'","'+query_reading+'","")}';
|
||||||
var url = encodeURI( this.connection.base_url + "/fhem?cmd=" + cmd + "&XHR=1");
|
var url = encodeURI( this.connection.base_url + "/fhem?cmd=" + cmd + "&XHR=1");
|
||||||
@@ -761,7 +760,7 @@ FHEMAccessory.prototype = {
|
|||||||
if( reading != query_reading ) {
|
if( reading != query_reading ) {
|
||||||
if( reading == 'pct'
|
if( reading == 'pct'
|
||||||
&& query_reading == 'state') {
|
&& query_reading == 'state') {
|
||||||
FHEM_update( that.device+'-'+query_reading, value );
|
//FHEM_update( that.device+'-'+query_reading, that.reading2homekit(query_reading, value) );
|
||||||
|
|
||||||
if( match = value.match(/dim(\d*)%/ ) )
|
if( match = value.match(/dim(\d*)%/ ) )
|
||||||
value = parseInt( match[1] );
|
value = parseInt( match[1] );
|
||||||
@@ -786,8 +785,9 @@ FHEMAccessory.prototype = {
|
|||||||
value = parseInt( FHEM_rgb2hsv(value)[2] * 100 );
|
value = parseInt( FHEM_rgb2hsv(value)[2] * 100 );
|
||||||
|
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
value = that.reading2homekit(reading, value);
|
value = that.reading2homekit(reading, value);
|
||||||
|
}
|
||||||
|
|
||||||
that.log(" mapped: " + value);
|
that.log(" mapped: " + value);
|
||||||
FHEM_update( that.device + '-' + reading, value, true );
|
FHEM_update( that.device + '-' + reading, value, true );
|
||||||
|
|||||||
Reference in New Issue
Block a user